1

I'm trying to display the date formatted for the specified language and I'm little surprised to see that:

babel.dates.format_date(date(2017,1,1), 'MMM Y')

gives the expected value which is:

u'Jan 2017'

while:

babel.dates.format_date(date(2017,1,1), 'MMM Y', locale='fr_FR')

gives me:

u'janv. 2016'

Why is it 2016 not 2017?

Machavity
  • 30,841
  • 27
  • 92
  • 100
aguyngueran
  • 1,301
  • 10
  • 23

1 Answers1

8

This is because Y is giving you the week year. You need to use yyyy to get what you expect.

See https://github.com/python-babel/babel/issues/138

print format_date(date(2017,1,1), 'MMM yyyy')

print format_date(date(2017,1,1), 'MMM yyyy', locale='fr_FR')

Jan 2017
janv. 2017
ScottSmudger
  • 351
  • 2
  • 8
  • also see http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table –  Feb 05 '17 at 18:42