Listing time zones

From IronPython Cookbook

The following code demonstrates how to list time zones known to the system along with the current system time translated to each of those time zones. This sample makes use of the System.TimeZoneInfo class that was introduced with .NET Framework 3.5.

import clr
clr.AddReference('System.Core') # .NET Framework 3.5 or later required

from System import DateTime, TimeZoneInfo

def main():
    now = DateTime.Now
    zones = TimeZoneInfo.GetSystemTimeZones()
    print '\n'.join(['%s %s' % (TimeZoneInfo.ConvertTime(now, zone).ToString('ddd hh:mm'), zone.DisplayName) for zone in zones])

if __name__ == '__main__':

Sample Output

Below is an example of what the output from the IronPython script could look like (running on a Windows Vista system).

Mon 11:29 (GMT) Casablanca, Monrovia, Reykjavik
Mon 11:29 (GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London
Tue 12:29 (GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
Tue 12:29 (GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague
Tue 12:29 (GMT+01:00) Brussels, Copenhagen, Madrid, Paris
Tue 12:29 (GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb
Tue 12:29 (GMT+01:00) West Central Africa
Tue 01:29 (GMT+02:00) Amman
Tue 01:29 (GMT+02:00) Athens, Bucharest, Istanbul
Tue 01:29 (GMT+02:00) Beirut
Tue 01:29 (GMT+02:00) Cairo
Tue 01:29 (GMT+02:00) Harare, Pretoria
Tue 01:29 (GMT+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius
Tue 01:29 (GMT+02:00) Jerusalem
Tue 01:29 (GMT+02:00) Minsk
Tue 01:29 (GMT+02:00) Windhoek
Tue 02:29 (GMT+03:00) Baghdad
Tue 02:29 (GMT+03:00) Kuwait, Riyadh
Tue 02:29 (GMT+03:00) Moscow, St. Petersburg, Volgograd
Tue 02:29 (GMT+03:00) Nairobi
Tue 02:29 (GMT+03:00) Tbilisi
Tue 02:59 (GMT+03:30) Tehran
Tue 03:29 (GMT+04:00) Abu Dhabi, Muscat
Tue 03:29 (GMT+04:00) Baku
Tue 03:29 (GMT+04:00) Yerevan
Tue 03:59 (GMT+04:30) Kabul
Tue 04:29 (GMT+05:00) Ekaterinburg
Tue 04:29 (GMT+05:00) Islamabad, Karachi, Tashkent
Tue 04:59 (GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi
Tue 04:59 (GMT+05:30) Sri Jayawardenepura
Tue 05:14 (GMT+05:45) Kathmandu
Tue 05:29 (GMT+06:00) Almaty, Novosibirsk
Tue 05:29 (GMT+06:00) Astana, Dhaka
Tue 05:59 (GMT+06:30) Yangon (Rangoon)
Tue 06:29 (GMT+07:00) Bangkok, Hanoi, Jakarta
Tue 06:29 (GMT+07:00) Krasnoyarsk
Tue 07:29 (GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi
Tue 07:29 (GMT+08:00) Irkutsk, Ulaan Bataar
Tue 07:29 (GMT+08:00) Kuala Lumpur, Singapore
Tue 08:29 (GMT+08:00) Perth
Tue 07:29 (GMT+08:00) Taipei
Tue 08:29 (GMT+09:00) Osaka, Sapporo, Tokyo
Tue 08:29 (GMT+09:00) Seoul
Tue 08:29 (GMT+09:00) Yakutsk
Tue 09:59 (GMT+09:30) Adelaide
Tue 08:59 (GMT+09:30) Darwin
Tue 09:29 (GMT+10:00) Brisbane
Tue 10:29 (GMT+10:00) Canberra, Melbourne, Sydney
Tue 09:29 (GMT+10:00) Guam, Port Moresby
Tue 10:29 (GMT+10:00) Hobart
Tue 09:29 (GMT+10:00) Vladivostok
Tue 10:29 (GMT+11:00) Magadan, Solomon Is., New Caledonia
Tue 12:29 (GMT+12:00) Auckland, Wellington
Tue 11:29 (GMT+12:00) Fiji, Kamchatka, Marshall Is.
Tue 12:29 (GMT+13:00) Nuku'alofa
Mon 10:29 (GMT-01:00) Azores
Mon 10:29 (GMT-01:00) Cape Verde Is.
Mon 09:29 (GMT-02:00) Mid-Atlantic
Mon 09:29 (GMT-03:00) Brasilia
Mon 08:29 (GMT-03:00) Buenos Aires, Georgetown
Mon 08:29 (GMT-03:00) Greenland
Mon 09:29 (GMT-03:00) Montevideo
Mon 07:59 (GMT-03:30) Newfoundland
Mon 07:29 (GMT-04:00) Atlantic Time (Canada)
Mon 07:29 (GMT-04:00) Caracas, La Paz
Mon 08:29 (GMT-04:00) Manaus
Mon 08:29 (GMT-04:00) Santiago
Mon 06:29 (GMT-05:00) Bogota, Lima, Quito, Rio Branco
Mon 06:29 (GMT-05:00) Eastern Time (US & Canada)
Mon 06:29 (GMT-05:00) Indiana (East)
Mon 05:29 (GMT-06:00) Central America
Mon 05:29 (GMT-06:00) Central Time (US & Canada)
Mon 05:29 (GMT-06:00) Guadalajara, Mexico City, Monterrey
Mon 05:29 (GMT-06:00) Saskatchewan
Mon 04:29 (GMT-07:00) Arizona
Mon 04:29 (GMT-07:00) Chihuahua, La Paz, Mazatlan
Mon 04:29 (GMT-07:00) Mountain Time (US & Canada)
Mon 03:29 (GMT-08:00) Pacific Time (US & Canada)
Mon 03:29 (GMT-08:00) Tijuana, Baja California
Mon 02:29 (GMT-09:00) Alaska
Mon 01:29 (GMT-10:00) Hawaii
Mon 12:29 (GMT-11:00) Midway Island, Samoa
Mon 11:29 (GMT-12:00) International Date Line West

Back to Contents.