From e514aca59915b639688aa9465f553f3392a22dd7 Mon Sep 17 00:00:00 2001 From: elexis Date: Mon, 21 Mar 2016 13:53:22 +0000 Subject: [PATCH] Display chat-timestamps in the lobby in the correct timezone, refs #3350. This was SVN commit r17929. --- binaries/data/mods/public/gui/lobby/lobby.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/binaries/data/mods/public/gui/lobby/lobby.js b/binaries/data/mods/public/gui/lobby/lobby.js index 48269746d5..8f55b0ef85 100644 --- a/binaries/data/mods/public/gui/lobby/lobby.js +++ b/binaries/data/mods/public/gui/lobby/lobby.js @@ -891,23 +891,13 @@ function ircFormat(msg) if (!g_ShowTimestamp) return formattedMessage; - var time; - if (msg.datetime) - { - let dTime = msg.datetime.split("T"); - let parserDate = dTime[0].split("-"); - let parserTime = dTime[1].split(":"); - // See http://xmpp.org/extensions/xep-0082.html#sect-idp285136 for format of datetime - // Date takes Year, Month, Day, Hour, Minute, Second - time = new Date(Date.UTC(parserDate[0], parserDate[1], parserDate[2], parserTime[0], parserTime[1], parserTime[2].split("Z")[0])); - } - else - time = new Date(Date.now()); + // Convert from UTC to localtime + var time = msg.time - new Date().getTimezoneOffset() * 60; // Translation: Time as shown in the multiplayer lobby (when you enable it in the options page). // For a list of symbols that you can use, see: // https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table - var timeString = Engine.FormatMillisecondsIntoDateString(time.getTime(), translate("HH:mm")); + var timeString = Engine.FormatMillisecondsIntoDateString(time * 1000, translate("HH:mm")); // Translation: Time prefix as shown in the multiplayer lobby (when you enable it in the options page). var timePrefixString = '[font="' + g_SenderFont + '"]' + sprintf(translate("\\[%(time)s]"), { "time": timeString }) + '[/font]';