Fix a bug in date fortmatting