Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong values for %b and %B in ca_ES and ca_AD locales #82401

Closed
aseques mannequin opened this issue Sep 18, 2019 · 3 comments
Closed

Wrong values for %b and %B in ca_ES and ca_AD locales #82401

aseques mannequin opened this issue Sep 18, 2019 · 3 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@aseques
Copy link
Mannequin

aseques mannequin commented Sep 18, 2019

BPO 38220
Nosy @eryksun

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2019-09-19.05:27:39.350>
created_at = <Date 2019-09-18.21:03:06.324>
labels = ['3.7', 'type-bug', 'library']
title = 'Wrong values for %b and %B in ca_ES and ca_AD locales'
updated_at = <Date 2019-09-19.05:27:39.340>
user = 'https://bugs.python.org/aseques'

bugs.python.org fields:

activity = <Date 2019-09-19.05:27:39.340>
actor = 'eryksun'
assignee = 'none'
closed = True
closed_date = <Date 2019-09-19.05:27:39.350>
closer = 'eryksun'
components = ['Library (Lib)']
creation = <Date 2019-09-18.21:03:06.324>
creator = 'aseques'
dependencies = []
files = []
hgrepos = []
issue_num = 38220
keywords = []
message_count = 3.0
messages = ['352755', '352756', '352767']
nosy_count = 2.0
nosy_names = ['eryksun', 'aseques']
pr_nums = []
priority = 'normal'
resolution = 'third party'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue38220'
versions = ['Python 3.7']

@aseques
Copy link
Mannequin Author

aseques mannequin commented Sep 18, 2019

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.

@aseques aseques mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 18, 2019
@aseques
Copy link
Mannequin Author

aseques mannequin commented Sep 18, 2019

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)

@eryksun
Copy link
Contributor

eryksun commented Sep 19, 2019

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

@eryksun eryksun closed this as completed Sep 19, 2019
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant