You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
format_datetime prints "None" for the 'O' time zone field #1478
A date pattern with a single O (short localized GMT format, e.g. "GMT-8") prints the word None instead of the offset. OOOO works. The pattern is accepted without error, so the bad output is easy to miss.
UTS #35 defines O as the short localized GMT format: hours without a leading zero, minutes only when not zero (GMT-8, GMT+5:30), inside the locale's GMT format (UTC-8 in fr).
Reproducibility
Always. Babel 2.18.0 and master (aeca9fa), Python 3.13, Windows; with pytz or zoneinfo.
Additional Information
DateTimeFormat.format_timezone in babel/dates.py handles OOOO and then falls through for O (there is a # TODO: To add support for O:1 comment), so it returns None, which ends up in the string. PATTERN_CHARS lists 'O': [1, 4], so the pattern passes validation.
Open PR #1284 adds a private _get_timezone_gmt_short helper (used there for the z fallback) that produces exactly this format. Once that lands, O could call it with a one-line change in format_timezone. I'm happy to send that follow-up with tests if it helps.
Activity