Is there an easy way to have an automatically constructed local time zone tzinfo object be used with datetime?
Following code shows the problem - the time module works fine mostly (%Z works, but %z does not, but that may be the way it is), uses # The following python code outputs: note the time() modules print EST and EDT (daylight savings), # but datetime does not. #----------- t = time.time() = 1172170000 # t tuple = (2007, 2, 22, 13, 46, 40, 3, 53, 0) %Z%z = EST+0000 # dt tuple = (2007, 2, 22, 13, 46, 40, 3, 53, -1) %Z%z = #----------- t = time.time() = 1177340000 # t tuple = (2007, 4, 23, 10, 53, 20, 0, 113, 1) %Z%z = EDT+0000 # dt tuple = (2007, 4, 23, 10, 53, 20, 0, 113, -1) %Z%z = ---- python code------------------------- import time from datetime import datetime t = 1172170000 # Feb 22 t_tuple = time.localtime(t) dt = datetime.fromtimestamp(t) dt_tuple = dt.timetuple() print "#-----------", "t = time.time() = ", t print "# t tuple = ", t_tuple, " %Z%z = ", time.strftime("%Z%z", t_tuple) print "# dt tuple = ", dt_tuple, " %Z%z = ", dt.strftime("%Z%z") t += 5170000 # Apr 23 t_tuple = time.localtime(t) dt = datetime.fromtimestamp(t) dt_tuple = dt.timetuple() print "#-----------", "t = time.time() = ", t print "# t tuple = ", t_tuple, " %Z%z = ", time.strftime("%Z%z", t_tuple) print "# dt tuple = ", dt_tuple, " %Z%z = ", dt.strftime("%Z%z") -- http://mail.python.org/mailman/listinfo/python-list