Skip to content

Instantly share code, notes, and snippets.

@unutbu
Created August 18, 2014 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unutbu/007796e17134b6736571 to your computer and use it in GitHub Desktop.
Save unutbu/007796e17134b6736571 to your computer and use it in GitHub Desktop.
import calendar
import time
import pytz
import datetime as DT
utc = pytz.timezone('UTC')
for tzname in [name for name in pytz.all_timezones if 'Brazil' in name]:
tz1 = pytz.timezone(tzname)
date = utc.localize(DT.datetime(2013, 1, 1))
print(tzname)
while date.year == 2013:
now_tz = date.astimezone(tz1)
now_epoch = calendar.timegm(now_tz.utctimetuple())
begin_day = now_tz.replace(hour=0, minute=0, second=0)
try:
assert now_tz.utcoffset() == begin_day.utcoffset()
except AssertionError:
print(date)
print(repr(now_tz))
print(repr(begin_day))
print(now_tz.utcoffset(), begin_day.utcoffset())
print('-'*80)
date = date + DT.timedelta(hours=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment