Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import datetime as dt
- from pytz import timezone as tz # pip install pytz
- britian = ['GB']
- american = [
- 'America/Vancouver',
- 'America/Toronto',
- 'America/Los_Angeles',
- 'America/New_York'
- ]
- states = [
- 'US/Pacific',
- 'US/Mountain',
- 'US/Central',
- 'US/Eastern',
- ]
- world = [
- 'Asia/Seoul',
- 'Hongkong',
- 'Asia/Singapore'
- ]
- def get_times(zones):
- time_list = list()
- time_tuple = tuple()
- for zn in zones:
- time_now = dt.now(tz=tz(zn)).replace(tzinfo=None)
- time_string = time_now.isoformat(sep=' ', timespec='minutes')
- zone = zn.rsplit('/', 1)
- time_tuple = time_string, zone[-1:][0]
- time_list.append(time_tuple)
- return time_list
- print('Britain:')
- for x in get_times(britian):
- print(x[0], ' - ', x[1])
- print()
- print('America:')
- for x in get_times(american):
- print(x[0], ' - ', x[1])
- print()
- print('Major USA Time Zones:')
- for x in get_times(states):
- print(x[0], ' - ', x[1])
- print()
- print('Global:')
- for x in get_times(world):
- print(x[0], ' - ', x[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement