#!/usr/bin/env python3
#=====================================================================================
# Python Timezone(s) 
#=====================================================================================
print("Content-Type: text/html \n")     #http header with newline char (required for the web)
print('<pre>')                          #to produce better display on the web 

from datetime import datetime
import time, pytz

timezone = time.tzname
print ('Timezone Name: ', timezone)

delta   = datetime.now() - datetime.utcnow()
num_sec = delta.total_seconds()
num_hrs = round(num_sec/(60*60))  
print('Offset to GMT:', num_hrs)

offset = time.strftime('%z')
print('Offset to GMT:', offset)

tz_utc     = pytz.utc
tz_london  = pytz.timezone('Europe/London')
tz_ny      = pytz.timezone('America/New_York')
tz_bangkok = pytz.timezone('Asia/Bangkok')

time_utc     = datetime.now(tz_utc)
time_london  = datetime.now(tz_london) 
time_ny      = datetime.now(tz_ny)
time_bangkok = datetime.now(tz_bangkok)

print('Time at UTC.....: ', time_utc)
print('Time in London..: ', time_london)
print('Time in New York: ', time_ny)
print('Time in Bangkok.: ', time_bangkok)

print()
print (pytz.all_timezones)
print (pytz.common_timezones)

for key, val in pytz.country_names.items():
    print(key, '=', val)

print()

for key, val in pytz.country_timezones.items():
    print(key, '=', val)