refactor converting date formatting