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 6e43aa21120c9e6d3d3367d6ffbf148a050e8999..d9edfec5fdffd553648486d16d0fb8fbeafc9863 100644 (file)
@@ -1,7 +1,7 @@
 from xml.sax import make_parser
 from xml.sax.handler import ContentHandler
 
-import os
+from os import environ, unlink, symlink
 import time
 
 class Timezones:
@@ -36,7 +36,12 @@ class Timezones:
                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: