[clocks] Make Clocks respect the 12-h 24-h settings by GNOME
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clocks] Make Clocks respect the 12-h 24-h settings by GNOME
- Date: Wed, 13 Jun 2012 13:40:07 +0000 (UTC)
commit 93fa24c5c30de9a9ef57a1c5a5fb4b5aebe945a2
Author: Eslam Mostafa <eslam Pandora localdomain>
Date: Wed Jun 13 01:10:26 2012 +0200
Make Clocks respect the 12-h 24-h settings by GNOME
Signed-off-by: Seif Lotfy <seif lotfy collabora co uk>
widgets.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/widgets.py b/widgets.py
index 4d2f66a..d7731ff 100644
--- a/widgets.py
+++ b/widgets.py
@@ -114,6 +114,11 @@ class DigitalClock ():
text = text[1:]
return text
+ def get_system_clock_format(self):
+ settings = Gio.Settings.new('org.gnome.desktop.interface')
+ systemClockFormat = settings.get_string('clock-format')
+ return systemClockFormat
+
def get_image(self):
local_time = self.get_local_time ()
if local_time.tm_hour > 7 and local_time.tm_hour < 19:
@@ -131,6 +136,19 @@ class DigitalClock ():
def update(self):
t = self.get_local_time_text ()
if not t == self._last_time:
+ systemClockFormat = self.get_system_clock_format ()
+ if systemClockFormat == '12h':
+ pass
+ else:
+ #Convert to 24h
+ hours = t[0:2]
+ hours = int(hours)+12
+ if hours == 24:
+ hours = '00'
+ else:
+ hours = str(hours)
+ minutes = t[3:5]
+ t = '%s:%s' % (hours, minutes)
img = self.get_image ()
self.drawing.render(t, img, self.get_is_day ())
if self.view_iter and self.list_store:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]