pull/1621/head
Bartlomiej Cieszkowski 2020-02-17 07:49:00 +01:00
parent 3e5ec443ce
commit e4594829f3
1 changed files with 5 additions and 7 deletions

View File

@ -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