follow core event changes
[enigma2.git] / lib / python / Components / Timezones.py
index 2eec17a67e9ed0202b2dedc904b16d76a37e9f9e..15837450e1074a70966a57a627740c74b0ed807e 100644 (file)
@@ -4,6 +4,8 @@ from xml.sax.handler import ContentHandler
 import os
 import time
 
+from enigma import *
+
 class Timezones:
        class parseTimezones(ContentHandler):
                def __init__(self, timezones):
@@ -21,14 +23,26 @@ class Timezones:
 
        def readTimezonesFromFile(self):
                parser = make_parser()
-               timezonesHandler = self.parseTimezones(self.timezones)
-               parser.setContentHandler(timezonesHandler)
-               parser.parse('/etc/timezone.xml')
+               
+               try:
+                       timezonesHandler = self.parseTimezones(self.timezones)
+                       parser.setContentHandler(timezonesHandler)
+                       parser.parse('/etc/timezone.xml')
+               except:
+                       pass
+               
+               if len(self.timezones) == 0:
+                       self.timezones = [("UTC", "UTC")]
                
        def activateTimezone(self, index):
+               if len(self.timezones) <= index:
+                       return
+               
                os.environ['TZ'] = self.timezones[index][1]
-               # FIXME we need a tzset
-               #time.tzset()
+               try:
+                       time.tzset()
+               except:
+                       etimezone()
                
        def getTimezoneList(self):
                list = []