python deal with datetime with timezone
reference: http://www.saltycrane.com/blog/2009/05/converting-time-zones-datetime-objects-python/
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
from datetime import datetime
from pytz import timezone
# set the time format
fmt = '%Y-%m-%d %H:%M:%S %Z%z'
# get current time in UTC
now_utc = datetime.now(timezone('UTC'))
# format the time display
now_utc.strftime(fmt)
## convert to local timezone with consideration of daylight time savings
now_utc.astimezone(timezone('US/Pacific')).strftime(fmt)
now_utc.astimezone(timezone('Europe/Berlin')).strftime(fmt)
## list all supported timezones (timezone ids)
from pytz import all_timezones
print len(all_timezones)
for zone in all_timezones:
if 'US' in zone:
print zone