In python3.4, if I create a timezone aware datetime objet, how do I determine whether the given date is summer (dst) or winter time?
Example:
local_time = pytz.timezone('Europe/Berlin')
time_winter = datetime.datetime(2014, 11, 26, 10, tzinfo=local_time)
time_summer = datetime.datetime(2014, 7, 26, 10, tzinfo=local_time)
In both cases .dst() returns off:
>>> datetime.timedelta(0)
Also .tzname() and .tzinfo() are always the same.
In principle, the object is aware of the timezone and dst, but only sometimes:
cet_winter = pytz.timezone('CET') # CET is without dst
datetime.datetime(2014,7 , 26, 10, tzinfo=local_time).astimezone(cet_winter)
>>> datetime.datetime(2014, 7, 26, 11, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>)
datetime.datetime(2014,11, 26, 10, tzinfo=local_time).astimezone(cet_winter)
>>> datetime.datetime(2014, 11, 26, 10, 0, tzinfo=<DstTzInfo 'CET' CET+1:00:00 STD>)
Here it shows a difference between summer and winter time... Doing the same to UTC, it won't work...
datetime.datetime(2014,11, 26, 10, tzinfo=local_time).astimezone(pytz.timezone('UTC'))
>>> datetime.datetime(2014, 11, 26, 9, 0, tzinfo=<UTC>)
datetime.datetime(2014,11, 26, 10, tzinfo=local_time).astimezone(pytz.timezone('UTC'))
>>> datetime.datetime(2014, 11, 26, 9, 0, tzinfo=<UTC>)
Do I miss something fundamentally or do I need to make the timezone object time dependent?