Minor cleanup of formatDate function