From ca8185b50aa29d452a52c00dd2d12535ee6074ed Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Thu, 12 Mar 2015 18:38:15 +0100 Subject: catch daylight savings time change, fix issue #75 thx to @Gamonics --- py3status/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/py3status/__init__.py b/py3status/__init__.py index d98b83d..226448b 100755 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -8,7 +8,7 @@ import sys from collections import OrderedDict from contextlib import contextmanager from copy import deepcopy -from datetime import datetime, timedelta +from datetime import datetime from json import dumps, loads from signal import signal from signal import SIGTERM, SIGUSR1 @@ -346,9 +346,6 @@ class I3status(Thread): # get a datetime from the parsed string date date = datetime.strptime(i3s_time, time_fmt) - - # i3status output delay adjustment - date += timedelta(seconds=1) except Exception: err = sys.exc_info()[1] syslog( @@ -373,6 +370,10 @@ class I3status(Thread): with respect to their parsed and timezone offset detected on start. """ utcnow = datetime.utcnow() + # every whole minute, resync our time from i3status' + # this ensures we will catch any daylight savings time change + if utcnow.second == 0: + self.set_time_modules() # for index, item in enumerate(json_list): if item.get('name') in ['time', 'tztime']: -- cgit v1.3