Created
April 15, 2015 06:13
-
-
Save fschulze/aca6e098b714951d7f43 to your computer and use it in GitHub Desktop.
This file contains 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
import datetime | |
import pytz | |
def testcase(tzinfo, dt, delta): | |
dt = dt.replace(tzinfo=tzinfo) | |
earlier = dt - delta | |
later = earlier + delta | |
assert dt == later | |
print "tzinfo ", tzinfo | |
print "dt ", dt | |
print "dst dt ", tzinfo.dst(dt) | |
print "delta ", delta | |
print "earlier ", earlier | |
print "dst earlier ", tzinfo.dst(earlier) | |
print "later ", later | |
print "dst later ", tzinfo.dst(later) | |
testcase( | |
tzinfo=pytz.timezone('US/Eastern'), | |
dt=datetime.datetime(2002, 10, 27, 1, 0), | |
delta=datetime.timedelta(hours=1)) | |
testcase( | |
tzinfo=pytz.timezone('US/Eastern'), | |
dt=datetime.datetime(2002, 10, 27, 1, 0), | |
delta=-datetime.timedelta(hours=1)) | |
testcase( | |
tzinfo=pytz.timezone('US/Eastern'), | |
dt=datetime.datetime(2002, 10, 27, 1, 0), | |
delta=datetime.timedelta(days=1)) | |
testcase( | |
tzinfo=pytz.timezone('US/Eastern'), | |
dt=datetime.datetime(2002, 10, 27, 1, 0), | |
delta=-datetime.timedelta(days=1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment