I am trying to use a self-defined formatting for format_date
. I want the month's name in upper case, and for that I am using MMMM yyyy
or LLLL yyyy
. I expect something along the lines of April 2007
. Here is my test program:
from datetime import date
from babel.dates import format_date
d = date(2007, 4, 1)
print format_date(d, 'MMMM yyyy', locale='es')
print format_date(d, 'LLLL yyyy', locale='es')
print format_date(d, 'MMMM yyyy', locale='it')
print format_date(d, 'LLLL yyyy', locale='it')
print format_date(d, 'MMMM yyyy', locale='en')
print format_date(d, 'LLLL yyyy', locale='en')
And here is the output:
abril 2007
abril 2007
aprile 2007
Aprile 2007
April 2007
April 2007
As you can see, the spanish (es
) version is wrong: the month's name is in lower case, both for MMMM
and LLLL
. Why is that? Is this a bug in Babel? From the Italian output, I expected MMMM
to mean lowercase, and LLLL
to mean uppercase. What is the formatting code for capitalized month names? (This is not stated clearly in the documentation)