Index: binaries/data/mods/public/gui/common/datetime.js =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/common/datetime.js @@ -0,0 +1,20 @@ +function timeOfDayToString(time, showSeconds = false) +{ + return showSeconds ? + // Translation: Format of the local time as shown for example in the realtime overlay, + // chat in the lobby, game setup, and session, and the lobby game start time. + // For a list of symbols that you can use, see: + // http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Field-Symbol-Table + Engine.FormatMillisecondsIntoDateStringLocal(time, translateWithContext("time of day, with seconds", "HH:mm:ss")) : + // Translation: Format of the local time as shown for example in the realtime overlay, + // chat in the lobby, game setup, and session, and the lobby game start time. + // For a list of symbols that you can use, see: + // http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Field-Symbol-Table + Engine.FormatMillisecondsIntoDateStringLocal(time, translateWithContext("time of day, without seconds", "HH:mm")); +} + +function chatTimestampToString(time) +{ + // Translation: Time prefix as shown for example in the chat in the lobby, game setup, and session. + return sprintf(escapeText(translate("[%(time)s]")), { "time": timeOfDayToString(time) }); +} Index: binaries/data/mods/public/gui/common/functions_global_object.js =================================================================== --- binaries/data/mods/public/gui/common/functions_global_object.js +++ binaries/data/mods/public/gui/common/functions_global_object.js @@ -70,7 +70,7 @@ counters.push(sprintf(translate("FPS: %(fps)4s"), { "fps": Engine.GetFPS() })); if (Engine.ConfigDB_GetValue("user", "overlay.realtime") === "true") - counters.push((new Date()).toLocaleTimeString()); + counters.push(timeOfDayToString(Date.now(), true)); // If game has been started if (typeof appendSessionCounters != "undefined") Index: binaries/data/mods/public/gui/gamesetup/gamesetup.js =================================================================== --- binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -2268,9 +2268,7 @@ if (Engine.ConfigDB_GetValue("user", "chat.timestamp") == "true") text = sprintf(translate("%(time)s %(message)s"), { - "time": sprintf(translate("\\[%(time)s]"), { - "time": Engine.FormatMillisecondsIntoDateStringLocal(Date.now(), translate("HH:mm")) - }), + "time": chatTimestampToString(Date.now()), "message": text }); Index: binaries/data/mods/public/gui/lobby/lobby.js =================================================================== --- binaries/data/mods/public/gui/lobby/lobby.js +++ binaries/data/mods/public/gui/lobby/lobby.js @@ -1036,9 +1036,8 @@ sgGameStartTime.hidden = !game.startTime; if (game.startTime) sgGameStartTime.caption = sprintf( - // Translation: %(time)s is the hour and minute here. translate("Game started at %(time)s"), { - "time": Engine.FormatMillisecondsIntoDateStringLocal(+game.startTime * 1000, translate("HH:mm")) + "time": timeOfDayToString(+game.startTime * 1000) }); sgNbPlayers.caption = sprintf( @@ -1397,19 +1396,9 @@ if (Engine.ConfigDB_GetValue("user", "chat.timestamp") != "true") return formattedMessage; - // 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 - let timeString = Engine.FormatMillisecondsIntoDateStringLocal(msg.time ? msg.time * 1000 : Date.now(), translate("HH:mm")); - - // Translation: Time prefix as shown in the multiplayer lobby (when you enable it in the options page). - let timePrefixString = sprintf(translate("\\[%(time)s]"), { - "time": timeString - }); - // Translation: IRC message format when there is a time prefix. return sprintf(translate("%(time)s %(message)s"), { - "time": senderFont(timePrefixString), + "time": senderFont(chatTimestampToString(msg.time ? msg.time * 1000 : Date.now())), "message": formattedMessage }); } Index: binaries/data/mods/public/gui/session/messages.js =================================================================== --- binaries/data/mods/public/gui/session/messages.js +++ binaries/data/mods/public/gui/session/messages.js @@ -901,9 +901,7 @@ // Save to chat history let historical = { "txt": formatted, - "timePrefix": sprintf(translate("\\[%(time)s]"), { - "time": Engine.FormatMillisecondsIntoDateStringLocal(Date.now(), translate("HH:mm")) - }), + "timePrefix": chatTimestampToString(Date.now()), "filter": {} };