It makes sense to set timezone to UTC or GMT-XX. Please mind that "Etc" category doesn't come from my mind, that's how these timezones are defined in the /usr/share/zoneinfo tree.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com --- pyanaconda/timezone.py | 14 +++++++++++- pyanaconda/ui/gui/spokes/datetime_spoke.py | 35 ++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/pyanaconda/timezone.py b/pyanaconda/timezone.py index 61f7e75..f08f0c4 100644 --- a/pyanaconda/timezone.py +++ b/pyanaconda/timezone.py @@ -34,6 +34,15 @@ from pyanaconda import iutil import logging log = logging.getLogger("anaconda")
+# The following zones are not in pytz.common_timezones and +# Etc category in pytz.all_timezones includes some more, +# however confusing ones (like UCT, GMT+0, GMT-0,...) +ETC_ZONES = ['GMT+1', 'GMT+2', 'GMT+3', 'GMT+4', 'GMT+5', 'GMT+6', 'GMT+7', + 'GMT+8', 'GMT+9', 'GMT+10', 'GMT+11', 'GMT+12', + 'GMT-1', 'GMT-2', 'GMT-3', 'GMT-4', 'GMT-5', 'GMT-6', 'GMT-7', + 'GMT-8', 'GMT-9', 'GMT-10', 'GMT-11', 'GMT-12', 'GMT-13', + 'GMT-14', 'UTC', 'GMT'] + class TimezoneConfigError(Exception): """Exception class for timezone configuration related problems""" pass @@ -163,6 +172,7 @@ def get_all_regions_and_timezones(): result[parts[0]] = set() result[parts[0]].add(parts[1])
+ result["Etc"] = set(ETC_ZONES) return result
def is_valid_timezone(timezone): @@ -174,5 +184,7 @@ def is_valid_timezone(timezone):
"""
- return timezone in pytz.common_timezones + etc_zones = ["Etc/" + zone for zone in ETC_ZONES] + + return timezone in pytz.common_timezones + etc_zones
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py index f3249bb..aae574c 100644 --- a/pyanaconda/ui/gui/spokes/datetime_spoke.py +++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py @@ -366,7 +366,16 @@ class DatetimeSpoke(NormalSpoke): GLib.source_remove(self._update_datetime_timer_id) self._update_datetime_timer_id = None
- self.data.timezone.timezone = self._tzmap.get_timezone() + new_tz = self._tzmap.get_timezone() + + # get_timezone() may return "" if Etc/XXXXX is selected + if not new_tz: + # get selected "Etc/XXXXXX" zone + region = self._get_active_region() + city = self._get_active_city() + new_tz = region + "/" + city + + self.data.timezone.timezone = new_tz
if self._ntpSwitch.get_active(): # turned ON @@ -719,7 +728,16 @@ class DatetimeSpoke(NormalSpoke): if city and region: timezone = region + "/" + city
- if timezone and (self._tzmap.get_timezone() != timezone): + if timezone is not None and region == "Etc": + # Etc timezones cannot be displayed on the map, so let's set the map + # to "" which sets it to "Europe/London" (UTC) without a city pin + self._tzmap.set_timezone("") + + # Change to Etc/XXXXX emits timezone-changed with "" as timezone, + # so let's help it a bit. + self._tzmap.emit("timezone-changed", timezone) + + elif timezone and (self._tzmap.get_timezone() != timezone): self._tzmap.set_timezone(timezone)
def on_month_changed(self, *args): @@ -736,13 +754,16 @@ class DatetimeSpoke(NormalSpoke): def on_timezone_changed(self, tz_map, timezone): fields = timezone.split("/", 1) if len(fields) == 1: - #initial "" + # timezone may be "" return - else: - region, city = fields
- self._set_combo_selection(self._regionCombo, region) - self._set_combo_selection(self._cityCombo, city) + region, city = fields + if region != "Etc": + # If region is "Etc", TimezoneMap returns "" from get_timezone + # and changing comboboxes here would create an endless loop. + self._set_combo_selection(self._regionCombo, region) + self._set_combo_selection(self._cityCombo, city) + os.environ["TZ"] = timezone self._update_datetime()