| | 164 | |
| | 165 | def _handleTimeZoneReport( self, report ): |
| | 166 | # this can be improved - AA |
| | 167 | # if we know the country, the offset and if this zone supports daylight savings |
| | 168 | # the proper timezone can be derived. |
| | 169 | # so opreferencesd needs to have a <this zone uses daylight savings> flag |
| | 170 | # and we need a /usr/share/zoneinfo parser |
| | 171 | |
| | 172 | # CTZV is offset * 4 |
| | 173 | offset = report / 4 |
| | 174 | # offset need to be inverted to get the correct TZ |
| | 175 | zone = "Etc/GMT" |
| | 176 | if offset <= 0 : |
| | 177 | zone += "+" + str( offset * -1 ) |
| | 178 | else : |
| | 179 | zone += "-" + str( offset ) |
| | 180 | logger.debug( "TimeZoneReport :" + str( report ) + " offset " + str( offset ) + " zone " + zone ) |
| | 181 | if zone != self.zone : |
| | 182 | try: |
| | 183 | shutil.copyfile( "/usr/share/zoneinfo/"+zone, "/etc/localtime" ) |
| | 184 | self.zone = zone |
| | 185 | except: |
| | 186 | logger.warning( "failed to install time zone file " + zone + " to /etc/localtime" ) |