refactoring: code duplication eliminated in date formatting