Because x1 and x2 have different time zones.
The tzinfo field in x2 is equal to TZ and has a UTC offset of 1 hour.
The tzinfo field in x1 contains the DST version of that timezone,
with a UTC offset of 2 hours, because Skopje is currently on DST.
I think you want:
x2 = TZ.localize(datetime(x1.year, x1.month, x1.day))
That produces a datetime with the year, month and day set as indicated
and tzinfo set to the correct UTC offset for that date, at 00:00 hours.
Or maybe you need:
x2 = TZ.localize(datetime(x1.year, x1.month, x1.day, 12))
x2 = x2.replace(hour=0)
That determines whether DST should be on at noon, and then resets the
hour field to zero. This produces the same outcome as the one liner,
except on days when DST is switched on or off.
Thanks, I think this will help me.
Although these issues seem very much underdocumented in the datetime
documentation. Are there any good references of using good times in Python?
--
damjan
--
http://mail.python.org/mailman/listinfo/python-list