[newui] Add code for getting timezones for country

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These functions should be used later in the timezone spoke
---
 pyanaconda/localization.py |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/pyanaconda/localization.py b/pyanaconda/localization.py
index f561557..75b2864 100644
--- a/pyanaconda/localization.py
+++ b/pyanaconda/localization.py
@@ -26,6 +26,7 @@ import os
 import re
 
 import babel
+import pytz
 
 
 LOCALE_PREFERENCES = {}
@@ -272,3 +273,24 @@ class Language(object):
 
         # XXX DEBUG
         print 'set system lang to "%s"' % self.system_lang
+
+
+def get_all_timezones(territory):
+    if isinstance(territory, LocaleInfo):
+        territory = territory.territory
+
+    try:
+        timezones = pytz.country_timezones(territory)
+    except KeyError:
+        timezones = list()
+
+    return timezones
+
+
+def get_preferred_timezone(territory):
+    try:
+        timezone = get_all_timezones(territory)[0]
+    except IndexError:
+        timezone = None
+
+    return timezone
-- 
1.7.5.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux