Created
November 1, 2014 20:01
-
-
Save ytjohn/c0fa4cea572eaf2b0ba4 to your computer and use it in GitHub Desktop.
show multiple timezone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from datetime import datetime | |
from dateutil import tz | |
import collections | |
import time | |
utczone = tz.gettz('UTC') | |
utc = datetime.utcnow() | |
utc = utc.replace(tzinfo=utczone) | |
zones = ['America/New_York', | |
'Europe/Stockholm', | |
'Europe/Moscow', | |
'America/Los_Angeles', | |
'Europe/London', | |
'America/Tijuana', | |
'Asia/Tokyo' | |
] | |
# print "{0}, {1}".format(utc, 'UTC') | |
utcs = "{0}U".format(str(utc)) | |
list = {utcs: '** UTC **'} | |
for zone in zones: | |
ts = utc.astimezone(tz.gettz(zone)) | |
# print str(ts) | |
list[str(ts)] = zone | |
# print "{0}, {1}".format(ts, zone) | |
od = collections.OrderedDict(sorted(list.items())) | |
for k, v in od.iteritems(): | |
print "{0}, {1}".format(k,v) |
Author
ytjohn
commented
Nov 1, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment