summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Hennion <nicolas@nicolargo.com>2020-03-10 21:17:31 +0100
committerGitHub <noreply@github.com>2020-03-10 21:17:31 +0100
commit054f8e35537920d6012e717e18c5bf49c9e9575b (patch)
tree52e362b488de9383871ba911bff4e4cfc19302b2
parent547062750b28a9f03700d956535eb38a55571281 (diff)
parenta7eb10598960ed15159d557b4f9d1c8d9ca2412c (diff)
Merge pull request #1621 from bartlomiejcieszkowski/timezone_too_long
Timezone too long
-rw-r--r--glances/plugins/glances_now.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/glances/plugins/glances_now.py b/glances/plugins/glances_now.py
index c549335a..254d71b8 100644
--- a/glances/plugins/glances_now.py
+++ b/glances/plugins/glances_now.py
@@ -19,8 +19,7 @@
"""Now (current date) plugin."""
-from time import tzname, localtime
-from datetime import datetime
+from time import tzname, localtime, strftime
from glances.globals import WINDOWS
from glances.plugins.glances_plugin import GlancesPlugin
@@ -49,13 +48,11 @@ 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 / #1337 / #1598)
- if not WINDOWS:
- 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