commit 7a63882b900ebae1a2037d74c922063c89371f44 parent fddca73db6e2e4068330b1adfc94e5ca4d58efbd Author: Agastya Chandrakant <acagastya@outlook.com> Date: Fri, 5 Jun 2020 23:43:56 +0530 different approach Diffstat:
M | utils.js | | | 9 | +++------ |
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/utils.js b/utils.js @@ -48,12 +48,9 @@ function sayTime(msg, client, channel) { while (arr[1] != '!time') arr.shift(); const user = arr[2]; const timezone = timezones.get(user) || user; - let time; - try { - time = moment().tz(timezone).format('HH:mm MMM DD'); - } catch (error) { - time = `${moment().tz('UTC').format('HH:mm MMM DD')} UTC`; - } + const TZ = moment.tz.names().includes(timezone) ? timezone : 'UTC'; + let time = moment().tz(timezone).format('HH:mm MMM DD'); + if (TZ == 'UTC') time += ' UTC'; client.say(channel, time); }