Skip to content

Commit

Permalink
Closes #7308. Adds timezone check functionality to the Python Binding…
Browse files Browse the repository at this point in the history
…s (matches Perl bindings). Useful for Live CD purposes to query the MBE for Timezone/Time.

git-svn-id: http://svn.mythtv.org/svn/trunk@22395 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
Robert McNamara committed Oct 12, 2009
1 parent 04ed9ac commit 080770f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion mythtv/bindings/python/MythTV/MythTV.py
Expand Up @@ -14,7 +14,7 @@
import socket
import code
import re
from datetime import datetime
from datetime import datetime, tzinfo, timedelta
from time import mktime

from MythDB import *
Expand Down Expand Up @@ -483,6 +483,24 @@ def getLastGuideData(self):
"""
return self.backendCommand('QUERY_GUIDEDATATHROUGH')

def getTimeZone(self):
"""
Returns a tuple containing Zone ID, UTC offset, and ISO format date
"""
return tuple(self.backendCommand('QUERY_TIME_ZONE').split(BACKEND_SEP))

def getTime(self):
"""
Returns an "aware" datetime object of the backend's current time
"""
class tz(tzinfo):
def __init__(self,offs): self.offset = int(offs)
def tzname(self): return "GMT%d" % (self.offset/3600)
def dst(self,dt): return timedelta(0)
def utcoffset(self,dt): return timedelta(seconds=self.offset)
tup = self.getTimeZone()
return datetime.strptime(tup[2],"%Y-%m-%dT%H:%M:%S").replace(tzinfo=tz(tup[1]))

def joinInt(self,high,low):
"""
Returns a single long from a pair of signed integers
Expand Down

0 comments on commit 080770f

Please sign in to comment.