Skip to content

Commit

Permalink
Fix tzinfo handling in custom Python datetime class
Browse files Browse the repository at this point in the history
Rename timezone class to _tzinfo to prevent conflicts with proper
timezone handling.  Correct regular expression to parse timezone offsets
from ISO8601 format properly.

Fixes #9937
  • Loading branch information
wagnerrp committed Jul 24, 2011
1 parent cb38a52 commit a606e97
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mythtv/bindings/python/MythTV/utility.py
Expand Up @@ -473,12 +473,12 @@ class datetime( _pydatetime ):
'(:(?P<sec>[0-9]{2}))?'
'(?P<tz>Z|'
'(?P<tzdirec>[-+])'
'(?P<tzhour>[0-9]{1,2}?)'
'(?P<tzhour>[0-9]{1,2})'
'(:)?'
'(?P<tzmin>[0-9]{2})?'
')?')

class tzinfo( _pytzinfo):
class _tzinfo( _pytzinfo):
def __init__(self, direc='+', hr=0, min=0):
if direc == '-':
hr = -1*int(hr)
Expand Down Expand Up @@ -509,11 +509,11 @@ def fromIso(cls, isotime, sep='T'):
dt.append(0)
if match.group('tz'):
if match.group('tz') == 'Z':
tz = cls.tzinfo()
tz = cls._tzinfo()
elif match.group('tzmin'):
tz = cls.tzinfo(*match.group('tzdirec','tzhour','tzmin'))
tz = cls._tzinfo(*match.group('tzdirec','tzhour','tzmin'))
else:
tz = cls.tzinfo(*match.group('tzdirec','tzhour'))
tz = cls._tzinfo(*match.group('tzdirec','tzhour'))
dt.append(0)
dt.append(tz)
return cls(*dt)
Expand Down

0 comments on commit a606e97

Please sign in to comment.