From 0a99a0bb413d06820247e4fc4a52c1eba07c4c60 Mon Sep 17 00:00:00 2001 From: YellowRoseCx <80486540+YellowRoseCx@users.noreply.github.com> Date: Sun, 16 Jul 2023 00:09:43 -0500 Subject: [PATCH] Add timezone replacement tags Allows setting of various timezones for the {{time}} tag by including the UTC offset with it like {{time_UTC-4}} or {{time_UTC+3}} --- public/script.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index 1ef40b8ba..a922c8ca0 100644 --- a/public/script.js +++ b/public/script.js @@ -1524,7 +1524,7 @@ function substituteParams(content, _name1, _name2, _original) { _name1 = _name1 ?? name1; _name2 = _name2 ?? name2; if (!content) { - return '' + return ''; } // Replace {{original}} with the original message @@ -1542,6 +1542,11 @@ function substituteParams(content, _name1, _name2, _original) { content = content.replace(/{{time}}/gi, moment().format('LT')); content = content.replace(/{{date}}/gi, moment().format('LL')); content = content.replace(/{{idle_duration}}/gi, () => getTimeSinceLastMessage()); + content = content.replace(/{{time_UTC([-+]\d+)}}/gi, (_, offset) => { + const utcOffset = parseInt(offset, 10); + const utcTime = moment().utc().utcOffset(utcOffset).format('LT'); + return utcTime; + }); content = randomReplace(content); return content; }