some refactoring of date formatting