diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2013-03-25 10:43:17 +0100 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2013-03-25 10:43:17 +0100 |
| commit | b620157a393a86ce2b10c823e569ea1ef069165c (patch) | |
| tree | e3048af3e5b1250d93d5b22a3ad624fc7d778359 | |
| parent | 1bb0856652043c1783dec083f2d255cffef0ce0a (diff) | |
fix time transformation thx to Lujeni
| -rwxr-xr-x | py3status/__init__.py | 14 |
1 files changed, 9 insertions, 5 deletions
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): |
