python-babel / babel

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

narrow non-breaking space (\u202f) usage in datetime formatting #1012

Closed joeyorlando closed 1 year ago

joeyorlando commented 1 year ago

Overview Description

On version 2.12.1, is it intended that "\u202f" would be included in an en localized datetime?

Steps to Reproduce

>>> import babel
>>> import datetime
>>> now = datetime.datetime.now()
>>> babel.dates.format_datetime(now, format="short", locale="en")
'6/13/23, 3:27\u202fPM'
joeyorlando commented 1 year ago

seems somewhat related to #1007 ?

akx commented 1 year ago

That formatting comes from the Unicode CLDR data, and Babel itself doesn't have an opinion.

The intention with an NBSP is that the AM/PM marker doesn't wrap onto a second line where it could, e.g. in

6/13/23, 3:27
PM

but remains attached to the time instead, and the user agent would wrap elsewhere:

6/13/23,
3:27 PM

The narrowness is likely a typographic choice.

I'll close this off, but let me know if you have further questions!