From e4594829f34e562efbe824d67e4a6e5b27dd8b33 Mon Sep 17 00:00:00 2001 From: Bartlomiej Cieszkowski Date: Mon, 17 Feb 2020 07:49:00 +0100 Subject: [PATCH] tz --- glances/plugins/glances_now.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/glances/plugins/glances_now.py b/glances/plugins/glances_now.py index 85f4ece1..497af195 100644 --- a/glances/plugins/glances_now.py +++ b/glances/plugins/glances_now.py @@ -19,7 +19,7 @@ """Now (current date) plugin.""" -from time import tzname, localtime +from time import tzname, localtime, strftime from datetime import datetime from glances.plugins.glances_plugin import GlancesPlugin @@ -48,12 +48,10 @@ class Plugin(GlancesPlugin): def update(self): """Update current date/time.""" # Had to convert it to string because datetime is not JSON serializable - self.stats = datetime.now().strftime('%Y-%m-%d %H:%M:%S') - # Add the time zone (issue #1249 and issue #1337) - if 'tmzone' in localtime(): - self.stats += ' {}'.format(localtime().tm_zone) - elif len(tzname) > 0: - self.stats += ' {}'.format(tzname[1]) + if (len(tzname[1]) > 6): + self.stats = strftime('%Y-%m-%d %H:%M:%S %z') + else: + self.stats = strftime('%Y-%m-%d %H:%M:%S %Z') return self.stats