From 79beb17aa3d7e6747f08a4e8024d4d797ab9caa2 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 1 Nov 2019 16:06:35 +0000 Subject: [PATCH] show GMT offset in !time output --- modules/user_time.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/user_time.py b/modules/user_time.py index cd51c9fb..043f2d3f 100644 --- a/modules/user_time.py +++ b/modules/user_time.py @@ -51,13 +51,19 @@ class Module(ModuleManager.BaseModule): if not timezone == None: dt = datetime.datetime.now(tz=pytz.timezone(timezone)) + gmt_offset = (dt.utcoffset().total_seconds()/60)/60 + tz = "GMT" + if not gmt_offset == 0.0: + if gmt_offset > 0: + tz += "+" + tz += "%g" % gmt_offset human = utils.datetime_human(dt) out = None if type == LocationType.USER: - out = "Time for %s: %s" % (name, human) + out = "Time for %s: %s %s" % (name, human, tz) else: - out = "It is %s in %s" % (human, name) + out = "It is %s in %s %s" % (human, name, tz) event["stdout"].write(out) else: out = None