Should not have negative DST offsets

Bug #427444 reported by mm
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pytz
Fix Released
Medium
Stuart Bishop

Bug Description

In very few timezones pytz reports negative dst. This happens if a change to daylight saving time falls together with a reduction in GMT offset such that the last STD time gmt offset is higher than the DST gmt offset.
This happens for 'Europe/Kiev' and other TZ in that region and for 'Antarctica/Palmer' and 'America/Iqaluit'

I am suggesting the following fix tzfile.py

@@ -83,6 +83,14 @@
                     if not prev_inf[1]:
                         break
                 dst = inf[0] - prev_inf[0] # dst offset
+
+ if dst < 0: # negative dst? : try beyond
+ for j in range(i+1, len(transitions)):
+ stdinf = ttinfo[lindexes[j]]
+ if not stdinf[1]:
+ break # found std time
+ dst = inf[0] - stdinf[0] # dst offset
+
             tzname = inf[2]

             # Round utcoffset and dst to the nearest minute or the

Related branches

Revision history for this message
mm (mm-softwareag) wrote :
Revision history for this message
Stuart Bishop (stub) wrote :

This seems correct. The test suite passes with the patch, and I've added a test to test_tzinfo.py that fails without this fix and passes with it (VilniusCESTStartTestCase)

Changed in pytz:
importance: Undecided → Medium
status: New → Fix Committed
assignee: nobody → Stuart Bishop (stub)
Stuart Bishop (stub)
Changed in pytz:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.