1 from xml.sax import make_parser
2 from xml.sax.handler import ContentHandler
8 class parseTimezones(ContentHandler):
9 def __init__(self, timezones):
10 self.isPointsElement, self.isReboundsElement = 0, 0
11 self.timezones = timezones
13 def startElement(self, name, attrs):
15 self.timezones.append((attrs.get('name',""), attrs.get('zone',"")))
20 self.readTimezonesFromFile()
22 def readTimezonesFromFile(self):
23 parser = make_parser()
26 timezonesHandler = self.parseTimezones(self.timezones)
27 parser.setContentHandler(timezonesHandler)
28 parser.parse('/etc/timezone.xml')
32 if len(self.timezones) == 0:
33 self.timezones = [("UTC", "UTC")]
35 def activateTimezone(self, index):
36 if len(self.timezones) <= index:
39 os.environ['TZ'] = self.timezones[index][1]
43 from enigma import e_tzset
46 def getTimezoneList(self):
48 for x in self.timezones:
49 list.append(str(x[0]))
52 def getDefaultTimezone(self):
53 # TODO return something more useful - depending on country-settings?
54 return "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Vienna"
56 timezones = Timezones()