set /etc/localtime link when change the timezone too
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 20 Aug 2007 10:17:35 +0000 (10:17 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 20 Aug 2007 10:17:35 +0000 (10:17 +0000)
lib/python/Components/Timezones.py

index 6e43aa2..d9edfec 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,12 @@ 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
+               symlink("/usr/share/zoneinfo/%s" %(self.timezones[index][1]), "/etc/localtime")
                try:
                        time.tzset()
                except:
                try:
                        time.tzset()
                except: