refs bug #429
[enigma2.git] / lib / python / Components / Timezones.py
index 6e43aa21120c9e6d3d3367d6ffbf148a050e8999..7f709159286b0065cc3e53fd9a1dd6f76e9b7c74 100644 (file)
@@ -1,7 +1,7 @@
 from xml.sax import make_parser
 from xml.sax.handler import ContentHandler
 
 from xml.sax import make_parser
 from xml.sax.handler import ContentHandler
 
-import os
+from os import environ, unlink, symlink
 import time
 
 class Timezones:
 import time
 
 class Timezones:
@@ -36,7 +36,15 @@ class Timezones:
                if len(self.timezones) <= index:
                        return
                
                if len(self.timezones) <= index:
                        return
                
-               os.environ['TZ'] = self.timezones[index][1]
+               environ['TZ'] = self.timezones[index][1]
+               try:
+                       unlink("/etc/localtime")
+               except OSError:
+                       pass
+               try:
+                       symlink("/usr/share/zoneinfo/%s" %(self.timezones[index][1]), "/etc/localtime")
+               except OSError:
+                       pass
                try:
                        time.tzset()
                except:
                try:
                        time.tzset()
                except:
@@ -44,11 +52,8 @@ class Timezones:
                        e_tzset()
                
        def getTimezoneList(self):
                        e_tzset()
                
        def getTimezoneList(self):
-               list = []
-               for x in self.timezones:
-                       list.append(str(x[0]))
-               return list
-       
+               return [ str(x[0]) for x in self.timezones ]
+
        def getDefaultTimezone(self):
                # TODO return something more useful - depending on country-settings?
                t = "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Vienna"
        def getDefaultTimezone(self):
                # TODO return something more useful - depending on country-settings?
                t = "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Vienna"