From b620157a393a86ce2b10c823e569ea1ef069165c Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Mon, 25 Mar 2013 10:43:17 +0100 Subject: fix time transformation thx to Lujeni --- py3status/__init__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'py3status') diff --git a/py3status/__init__.py b/py3status/__init__.py index 5324385..9410ed5 100755 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -206,11 +206,15 @@ def transform(j, **kwargs): - update the 'time' object so that it's updated at INTERVAL seconds - update the 'run_watch' objects so that we rely on the color instead of useless 'yes' or 'no' status """ - for item in j: - # time modification - if item['name'] == 'time': - date = datetime.strptime(item['full_text'], I3STATUS_CONFIG['time_format']) + timedelta(seconds=kwargs['delta']) - item['full_text'] = date.strftime(I3STATUS_CONFIG['time_format']) + try: + for item in j: + # time modification + if item['name'] in [ 'time', 'tztime' ]: + date = datetime.strptime(item['full_text'], I3STATUS_CONFIG['time_format']) + timedelta(seconds=kwargs['delta']) + item['full_text'] = date.strftime(I3STATUS_CONFIG['time_format']) + except Exception: + err = sys.exc_info()[1] + syslog(LOG_ERR, "transformation failed (%s)" % (str(err))) return j def load_from_file(filepath): -- cgit v1.3