Opened 7 years ago

Closed 6 years ago

#11447 closed Bug Report - General (fixed)

Daylight Savings Time transition broken

Reported by: Tom Grigg <tomegrigg@…> Owned by: Raymond Wagner
Priority: minor Milestone: 0.27
Component: Bindings - Python Version: 0.26-fixes
Severity: medium Keywords:
Cc: Ticket locked: no

Description

The POSIX timezone implementation in the MythTV python bindings does not properly handle the transition to summer (daylight savings) time, which occurs here in the USA this coming weekend.

This is caused by scanning the transition table using the local time entry, which for the transition to DST is actually one hour ahead of the time for which the transition is being looked up.

A symptom of this issue is that attempting to convert a datetime instance from UTC to local time during the transition and the hour following will result in an incorrect result. For example:

     starttime = datetime.duck('2013-03-10T10:30:00Z')  
     print starttime.astimezone(datetime.localTZ())

will print

     2013-03-10 02:30:00-08:00

instead of

     2013-03-10 03:30:00-07:00

Attached is a testcase and a quick and dirty patch which fixes the issue. It may be more elegant to implement a fix as the zoneinfo tables are read rather than during transition search.

Attachments (2)

dst-test.py (2.2 KB) - added by Tom Grigg <tomegrigg@…> 7 years ago.
test case
python-bindings-dst-fix.patch (768 bytes) - added by Tom Grigg <tomegrigg@…> 7 years ago.
patch

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by Tom Grigg <tomegrigg@…>

Attachment: dst-test.py added

test case

Changed 7 years ago by Tom Grigg <tomegrigg@…>

patch

comment:1 Changed 6 years ago by Raymond Wagner

Milestone: unknown0.27
Status: newaccepted

comment:2 Changed 6 years ago by Raymond Wagner <rwagner@…>

Resolution: fixed
Status: acceptedclosed

In 6b01d7ba4c2a77fbeed59ba9f2671e8038432611/mythtv:

Improve time zone behavior in Python bindings at transition points.

This adds pre-computed ranges during which time zone definitions are in
effect, allowing the search to function more correctly in the hour
immediately before and after a transition.

Fixes #11447
Closes #10847

Note: See TracTickets for help on using tickets.