Skip to content

Commit

Permalink
Allow posixtzinfo to use the TZ environmental variable.
Browse files Browse the repository at this point in the history
This adds a check for the TZ environmental variable, and uses that to
define the local timezone if available, rather than always using
/etc/localtime. This resolves an issue on Debian-based systems that
always use the TZ variable, rather than defining the localtime file.
  • Loading branch information
wagnerrp committed Dec 30, 2012
1 parent 4dd0bf8 commit 0bffe06
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mythtv/bindings/python/MythTV/utility/dt.py
Expand Up @@ -11,6 +11,7 @@
tzinfo as _pytzinfo, \
timedelta
from collections import namedtuple
import os
import re
import time
import singleton
Expand Down Expand Up @@ -177,10 +178,12 @@ def _process(self, fd, version=1, skip=False):


def __init__(self, name=None):
if name is None:
fd = open('/etc/localtime')
else:
if name:
fd = open('/usr/share/zoneinfo/' + name)
elif os.getenv('TZ'):
fd = open('/usr/share/zoneinfo/' + os.getenv('TZ'))
else:
fd = open('/etc/localtime')

version = self._get_version(fd)
if version == 2:
Expand Down

0 comments on commit 0bffe06

Please sign in to comment.