python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.32k stars 440 forks source link

Formatting date with Canadian Locale no longer returns date in Canadian format #987

Closed Ollymid closed 5 months ago

Ollymid commented 1 year ago

Overview Description

I have found that when passing Canadian Locale to the babel format_date function (using the latest version v2.12.1) the date gets formatted to US date format (Month/Day/Year) rather than Canadian date format, which is the same as the international standard format (Year-Month-Day).

We also use en_US and en_UK locales but they produced formatted dates as expected

Steps to Reproduce

>>> from babel import Locale
>>> locale = Locale.parse('en_CA')
>>> locale
Locale('en', territory='CA')

>>> from datetime import datetime
>>> DATE_TUPLE = (2023, 11, 12, 0, 0, 0)
>>> d = datetime(*DATE_TUPLE)
>>> d
datetime.datetime(2023, 11, 12, 0, 0)

>>> from babel.dates import format_date
>>> d = timestamp
>>> format = 'short'
>>> day = format_date(d, locale=locale, format=format)

Actual Results

Results with babel v2.12.1:

>>> day
'11/12/23'

Expected Results

Results with babel v2.11.0:

>>> day
'2023-11-12'

Reproducibility

Additional Information

akx commented 1 year ago

According to the delta this seems to have been a deliberate change in the CLDR data.

You could bring this up over on the CLDR channels: https://github.com/unicode-org/cldr/blob/main/docs/requesting_changes.md

Ollymid commented 1 year ago

Thanks @akx - Looks like someone else is already on to it https://github.com/unicode-org/cldr/pull/2759

Does babel always use the latest CLDR data or will it require a version update?

akx commented 1 year ago

It will require a Babel version update, since the CLDR data is parsed and converted during the build process.

srl295 commented 1 year ago

@akx Hi! beta version of CLDR coming soon. Do you pull from XML or JSON?

akx commented 1 year ago

@srl295 XML.

akx commented 5 months ago

This should have been fixed by now :)