X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/9925392e576717cc0df070ace822a6f392808bb7..d0ca21133e420f63c90d44e6b8bd23273e2ffd58:/lib/python/Components/Timezones.py diff --git a/lib/python/Components/Timezones.py b/lib/python/Components/Timezones.py index 90b227f7..0b6eb79b 100644 --- a/lib/python/Components/Timezones.py +++ b/lib/python/Components/Timezones.py @@ -1,6 +1,11 @@ from xml.sax import make_parser from xml.sax.handler import ContentHandler +import os +import time + +from enigma import * + class Timezones: class parseTimezones(ContentHandler): def __init__(self, timezones): @@ -8,18 +13,11 @@ class Timezones: self.timezones = timezones def startElement(self, name, attrs): - print "Name: " + str(name) if (name == "zone"): - self.timezones[attrs.get('name',"")] = attrs.get('zone',"") - #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',"")) - #tpos = attrs.get('position',"") - #tname = attrs.get('name',"") - #self.satellites[tpos] = tname - #self.satList.append( (tname, tpos) ) - #self.parsedSat = int(tpos) + self.timezones.append((attrs.get('name',""), attrs.get('zone',""))) def __init__(self): - self.timezones = {} + self.timezones = [] self.readTimezonesFromFile() @@ -29,5 +27,21 @@ class Timezones: parser.setContentHandler(timezonesHandler) parser.parse('/etc/timezone.xml') + def activateTimezone(self, index): + os.environ['TZ'] = self.timezones[index][1] + try: + time.tzset() + except: + etimezone() + + def getTimezoneList(self): + list = [] + for x in self.timezones: + list.append(str(x[0])) + return list + + def getDefaultTimezone(self): + # TODO return something more useful - depending on country-settings? + return 27 timezones = Timezones()