Opened 13 years ago

Closed 12 years ago

#10847 closed Bug Report - General (fixed)

Time conversion error

Reported by: Andreas Reibring <andreas@…> Owned by: Raymond Wagner
Priority: minor Milestone: 0.27
Component: Bindings - Python Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

After upgrading to 0.25 my old scripts using MythTV.MythXML.getProgramDetails() stopped working, giving either urllib2.HTTPError or httplib.BadStatusLine errors. (Traceback from the Python interpreter attached.) The reason seems to be that getProgramDetails() now expects the starttime argument in UTC. However, when passed a UTC starttime argument, the method returns a Program object with an incorrect starttime attribute that is neither UTC nor local time.

Example: The news program 'Rapport' starts at 19:30 local Swedish time (17:30 UTC).

>>> prog = MythTV.MythXML().getProgramDetails(u'6011', u'2012-06-20 17:30:00')
>>> print prog.title, prog.starttime
Rapport 2012-06-20 18:30:00

I believe that the problem is the time representation conversion in MythTV.utility.datetime.timestamp(). This method is calling time.mktime(), which expects a struct_time in local time as argument, with a struct_time in UTC. The problem can be resolved by calling calendar.timegm() instead. (See table on http://docs.python.org/library/time.html) Patch is attached.

Attachments (2)

traceback (3.0 KB ) - added by Andreas Reibring <andreas@…> 13 years ago.
utility.py_timeconversion.patch (636 bytes ) - added by Andreas Reibring <andreas@…> 13 years ago.

Download all attachments as: .zip

Change History (6)

by Andreas Reibring <andreas@…>, 13 years ago

Attachment: traceback added

by Andreas Reibring <andreas@…>, 13 years ago

comment:1 by Raymond Wagner, 13 years ago

Milestone: unknown0.26
Status: newaccepted

comment:2 by Raymond Wagner, 13 years ago

Milestone: 0.26unknown
Version: 0.25-fixesMaster Head

In b393cbc969f26c470e0ae38e48d9780b67dad604/mythtv:

Error: Processor CommitTicketReference failed
GIT backend not available

comment:3 by Raymond Wagner, 12 years ago

Milestone: unknown0.27

comment:4 by Raymond Wagner <rwagner@…>, 12 years ago

Resolution: fixed
Status: acceptedclosed

In 6b01d7ba4c2a77fbeed59ba9f2671e8038432611/mythtv:

Error: Processor CommitTicketReference failed
GIT backend not available
Note: See TracTickets for help on using tickets.