[pywin32-bugs] [ pywin32-Bugs-3523104 ] TimeZoneInfo does not convert timezones correctly
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2012-05-02 20:01:07
|
Bugs item #3523104, was opened at 2012-05-02 13:01 Message generated for change (Tracker Item Submitted) made by bmatthews27 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3523104&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: win32timezone Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Brian Matthews (bmatthews27) Assigned to: Jason R. Coombs (jaraco) Summary: TimeZoneInfo does not convert timezones correctly Initial Comment: in the following example two dates are converted from Hawaii time zone to Pacific time zone. In both cases the time difference should be 3 hours. The first is correct, the second is incorrect >>> from win32timezone import TimeZoneInfo >>> from datetime import datetime >>> tzi = TimeZoneInfo('Hawaiian Standard Time') >>> tzs = TimeZoneInfo('Pacific Standard Time') >>> dthaw = datetime(2011, 11, 5, 15, 59, 59, 0, tzinfo=tzi) >>> print dthaw.timetuple() time.struct_time(tm_year=2011, tm_mon=11, tm_mday=5, tm_hour=15, tm_min=59, tm_sec=59, tm_wday=5, tm_yday=309, tm_isdst=0) >>> dtpac = dthaw.astimezone(tzs) >>> print dtpac.timetuple() time.struct_time(tm_year=2011, tm_mon=11, tm_mday=5, tm_hour=18, tm_min=59, tm_sec=59, tm_wday=5, tm_yday=309, tm_isdst=1) >>> >>> dthaw = datetime(2011, 11, 5, 16, 0, 0, 0, tzinfo=tzi) >>> print dthaw.timetuple() time.struct_time(tm_year=2011, tm_mon=11, tm_mday=5, tm_hour=16, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=309, tm_isdst=0) >>> dtpac = dthaw.astimezone(tzs) >>> print dtpac.timetuple() time.struct_time(tm_year=2011, tm_mon=11, tm_mday=5, tm_hour=17, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=309, tm_isdst=1) >>> ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3523104&group_id=78018 |