From: Stefan Pluecken Date: Thu, 17 Nov 2005 16:12:16 +0000 (+0000) Subject: timezone selection works now. tzset doesn't exist, so we cannot activate the timezone... X-Git-Tag: 2.6.0~5112 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/350ca9a9900a43be5873efdaf8e31f58dc4c3f9c?ds=sidebyside timezone selection works now. tzset doesn't exist, so we cannot activate the timezone atm. --- diff --git a/lib/python/Components/SetupDevices.py b/lib/python/Components/SetupDevices.py index 003bba54..612bb8c8 100644 --- a/lib/python/Components/SetupDevices.py +++ b/lib/python/Components/SetupDevices.py @@ -8,8 +8,13 @@ from config import configText from Components.Timezones import timezones def InitSetupDevices(): + + def timezoneNotifier(configElement): + timezones.activateTimezone(configElement.value) + config.timezone = ConfigSubsection(); - config.timezone.val = configElement("config.timezone.val", configSelection, 1, ("GMT", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5", "GMT+6", "GMT+7", "GMT+8", "GMT+9") ); + config.timezone.val = configElement("config.timezone.val", configSelection, timezones.getDefaultTimezone(), timezones.getTimezoneList()); + config.timezone.val.addNotifier(timezoneNotifier) config.rc = ConfigSubsection(); config.rc.map = configElement("config.rc.map", configSelection, 0, ("Default", "Classic") ); diff --git a/lib/python/Components/Timezones.py b/lib/python/Components/Timezones.py index 90b227f7..2eec17a6 100644 --- a/lib/python/Components/Timezones.py +++ b/lib/python/Components/Timezones.py @@ -1,6 +1,9 @@ from xml.sax import make_parser from xml.sax.handler import ContentHandler +import os +import time + class Timezones: class parseTimezones(ContentHandler): def __init__(self, timezones): @@ -8,18 +11,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 +25,19 @@ class Timezones: parser.setContentHandler(timezonesHandler) parser.parse('/etc/timezone.xml') + def activateTimezone(self, index): + os.environ['TZ'] = self.timezones[index][1] + # FIXME we need a tzset + #time.tzset() + + 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()