summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormeganomic <>2021-01-03 21:11:19 +0100
committermeganomic <>2021-01-03 21:11:19 +0100
commit54e8e7b8dcb8c9ebda1f6840f6a86f1486fda52f (patch)
treea8b9409f6c8c285ec901a65b3ab885f7aae98267
parent627ef431f92aab60e66669f7e63200cb516c4b91 (diff)
Add strftime config option
-rw-r--r--glances/config.py7
-rw-r--r--glances/plugins/glances_now.py14
2 files changed, 17 insertions, 4 deletions
diff --git a/glances/config.py b/glances/config.py
index 811dd5b3..1b08d995 100644
--- a/glances/config.py
+++ b/glances/config.py
@@ -107,7 +107,7 @@ class Config(object):
# Re patern for optimize research of `foo`
self.re_pattern = re.compile(r'(\`.+?\`)')
- self.parser = ConfigParser()
+ self.parser = ConfigParser(interpolation=None)
self.read()
def config_file_paths(self):
@@ -224,6 +224,11 @@ class Config(object):
self.set_default_cwc('processlist', 'cpu')
self.set_default_cwc('processlist', 'mem')
+ # Now
+ if not self.parser.has_section('strftime'):
+ self.parser.add_section('strftime')
+ self.set_default('strftime', 'format', '')
+
@property
def loaded_config_file(self):
"""Return the loaded configuration file."""
diff --git a/glances/plugins/glances_now.py b/glances/plugins/glances_now.py
index 254d71b8..77c05d21 100644
--- a/glances/plugins/glances_now.py
+++ b/glances/plugins/glances_now.py
@@ -41,6 +41,10 @@ class Plugin(GlancesPlugin):
# Set the message position
self.align = 'bottom'
+ if config is not None:
+ if 'strftime' in config.as_dict():
+ self.strftime = config.as_dict()['strftime']['format']
+
def reset(self):
"""Reset/init the stats."""
self.stats = ''
@@ -49,10 +53,14 @@ class Plugin(GlancesPlugin):
"""Update current date/time."""
# Had to convert it to string because datetime is not JSON serializable
# Add the time zone (issue #1249 / #1337 / #1598)
- if (len(tzname[1]) > 6):
- self.stats = strftime('%Y-%m-%d %H:%M:%S %z')
+
+ if self.strftime:
+ self.stats = strftime(self.strftime)
else:
- self.stats = strftime('%Y-%m-%d %H:%M:%S %Z')
+ 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