This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong values for %b and %B in ca_ES and ca_AD locales
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: aseques, eryksun
Priority: normal Keywords:

Created on 2019-09-18 21:03 by aseques, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg352755 - (view) Author: Joan (aseques) Date: 2019-09-18 21:03
There's an incorrect behaviour in the output for the strftime values when in catalan.
On the documentation at https://docs.python.org/3.7/library/datetime.html#strftime-strptime-behavior:

- %b Month as locale’s abbreviated name. Jan, Feb, …, Dec (en_US)
- %B Month as locale’s full name. January, February, …, December (en_US);

It works also in es_ES an others, while in catalan there's an extra article on the month name (and a point in the abbreviated version) that shouldn't be there de "set." and "de setembre".

Where should I go to fix this and get the documented behaviour? I haven't been able to find a translation section on python site.
msg352756 - (view) Author: Joan (aseques) Date: 2019-09-18 21:09
Issue can be reproduced with this snippet:
---
import locale
from datetime import datetime
locale.setlocale(locale.LC_ALL, 'ca_AD.utf8')
locale.setlocale(locale.LC_ALL, 'ca_ES.utf8')
#locale.setlocale(locale.LC_ALL, 'es_ES.utf8')
now = datetime.now() # current date and time
date_time = now.strftime("|%b|%B|")
print("date and time:",date_time)   
---
msg352767 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2019-09-19 05:27
The result from strftime is platform dependent. In Windows, the result has a trailing "." for the abbreviated names that are less than four characters, but no "de" in either form:

    >>> months = [(2019, m) + (0,)*7 for m in range(1,13)]
    >>> locale.setlocale(locale.LC_ALL, 'ca_ES.utf8')
    'ca_ES.utf8'
    >>> print(*(time.strftime('%b|%B', m) for m in months), sep='\n')
    gen.|gener
    febr.|febrer
    març|març
    abr.|abril
    maig|maig
    juny|juny
    jul.|juliol
    ag.|agost
    set.|setembre
    oct.|octubre
    nov.|novembre
    des.|desembre

In Linux, the result uses the same base abbreviations as in Windows, including the trailing ".", but it also includes "de" or "d'" in both forms:

    >>> months = [(2019, m) + (0,)*7 for m in range(1,13)]
    >>> locale.setlocale(locale.LC_ALL, 'ca_ES.utf8')
    'ca_ES.utf8'
    >>> print(*(time.strftime('%b|%B', m) for m in months), sep='\n')
    de gen.|de gener
    de febr.|de febrer
    de març|de març
    d’abr.|d’abril
    de maig|de maig
    de juny|de juny
    de jul.|de juliol
    d’ag.|d’agost
    de set.|de setembre
    d’oct.|d’octubre
    de nov.|de novembre
    de des.|de desembre
History
Date User Action Args
2022-04-11 14:59:20adminsetgithub: 82401
2019-09-19 05:27:39eryksunsetstatus: open -> closed

nosy: + eryksun
messages: + msg352767

resolution: third party
stage: resolved
2019-09-18 21:09:52asequessetmessages: + msg352756
2019-09-18 21:03:06asequescreate