accessing tzinfo for timezones defined via tzwin which don't observe Daylight Saving Time throws ValueError because _dstmonth is 0
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dateutil |
Confirmed
|
Medium
|
Tomi Hukkalainen |
Bug Description
on windows:
from dateutil.tz import gettz
from datetime import datetime
tzinfo = gettz('UTC')
f = datetime.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\
if self._isdst(dt):
File "C:\Python27\
self.
File "C:\Python27\
first = datetime.
ValueError: month must be in 1..12
Patch:
--- tzwin.py~ 2012-06-05 09:08:36.212393800 -0400
+++ tzwin.py 2012-06-07 10:24:33.878270600 -0400
@@ -62,6 +62,8 @@
return self._display
def _isdst(self, dt):
+ if self._dstmonth == 0:
+ return False
dston = picknthweekday(
Related branches
- Dateutil Maintainers: Pending requested
-
Diff: 60 lines (+17/-1)2 files modifieddateutil/tzwin.py (+6/-1)
test.py (+11/-0)
Changed in dateutil: | |
importance: | Undecided → Medium |
status: | New → Confirmed |
assignee: | nobody → Tomi Pieviläinen (tpievila) |
Update 2014
This defect is still present in python-dateutil 2.2 and in lp:dateutil 135
It will manifest when testing under py 3.X , will not show up in py 2.X due to another bug (will report as separate issue)
The rationale for the fix is solid: as seen in the docs of win32 API for TIME_ZONE_ INFORMATION structure [1], dstmonth == 0 is a flag for 'this timezone don't have Daylight Saving Time'
We ( https:/ /github. com/getnikola/ nikola ) are affected for this defect.
I will post a merge request, with test, if that helps to land the patch.
[1] http:// msdn.microsoft. com/en- us/library/ windows/ desktop/ ms725481( v=vs.85) .aspx