small fixes for formatDate function