Hi. I am creating a couple of small methods to help me manage time from UTC as standard but I am getting strange results.
If I start with a datetime of 2005-12-12 14:30:00 in timezone 'America/Halifax' and I want to turn this into a UTC representation. from datetime import datetime from pytz.reference import UTC import pytz fmt = '%Y-%m-%d %H:%M:%S %Z%z' tz = pytz.timezone('America/Halifax') dt = datetime(year=2005, month=12, day=11, hour=14, minute=30, second=0, microsecond=0, tzinfo=tz) print dt.strftime(fmt) This is giving me a strange offset of -0414 and LMT timezone. ie. 2005-12-12 14:30:00 LMT-0414 I am not sure where this is coming from To get the utc equivalent using dt = dt.astimezone(UTC) I get this strange result which is obviously also not correct: # '2005-12-12 18:44:00 UTC+0000' If I do datetime.now instead with the same timezone I get the correct timezone and correct offset. ie. dt = datetime.now(tz=tz) # '2005-12-12 21:37:17 AST-0400' If I get now time from this as utc it is correct dt = dt.astimezone(UTC) # '2005-12-12 01:37:17 UTC+0000' If I do a different timezone of 'America/Vancouver' I get something appropriate for the 2:30 case tz = pytz.timezone('America/Vancouver') dt = datetime(year=2005, month=12, day=12, hour=14, minute=30, second=0, microsecond=0, tzinfo=tz) print dt.strftime(fmt) # 2005-12-12 20:30:00 PST-0800 I am not sure why I am getting -0414 and LMT for 'America/Halifax' timezone? Is this a bug in the pytz package? Many thanks. Regards, David -- http://mail.python.org/mailman/listinfo/python-list