From efcf8c8610767ac021e2e493b561201a0d6a21c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Mand=C3=A1k?= Date: Sun, 18 Jan 2015 11:59:05 +0100 Subject: [PATCH] Updated 'clock' module to change locale only if necessary. --- i3pystatus/clock.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/i3pystatus/clock.py b/i3pystatus/clock.py index d0db703..67a8fa7 100644 --- a/i3pystatus/clock.py +++ b/i3pystatus/clock.py @@ -32,13 +32,12 @@ class Clock(IntervalModule): on_downscroll = ["scroll_format", -1] def init(self): - lang = os.environ.get('LANG', None) - if lang: - # affects function time.strftime() in whole program - locale.setlocale(locale.LC_TIME, lang) - + lang, enc = os.environ.get('LANG', None).split('.', 1) + if lang != locale.getlocale(locale.LC_TIME)[0]: + # affects datetime.time.strftime() in whole program + locale.setlocale(locale.LC_TIME, (lang, enc)) + if self.format is None: - lang = locale.getlocale()[0] if lang == 'en_US': # MDY format - United States of America self.format = ["%a %b %-d %X"]