pytz provides list of timezones in formats like America/Chicago, America/Los_Angeles, Asia/Kolkata or the tz abbreviation.
I want the full name for timezones.
Is this possible in Python?
The Unicode CLDR project contains many localized strings, including the human-readable names of time zones in many different languages.
A quick search for Python implementations of CLDR found the Babel library. An example shown in this part of the documentation is as follows:
>>> british = get_timezone('Europe/London')
>>> format_datetime(dt, 'H:mm zzzz', tzinfo=british, locale='en_US')
u'16:30 British Summer Time'
Here we can see that at the date and time specified by the dt
variable, and the IANA time zone (as used by pytz) of Europe/London
, the English display name is "British Summer Time".
There's also an example of how to get just the generic time zone name, without regard to a specific date:
>>> from babel import Locale
>>> from babel.dates import get_timezone_name, get_timezone
>>> tz = get_timezone('Europe/Berlin')
>>> get_timezone_name(tz, locale=Locale.parse('pt_PT'))
u'Hor\xe1rio Alemanha'
That is, the Europe/Berlin
time zone has the Portugese name of "Horário Alemanha".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With