From 0cceb31288f9e6c3c8bb638c07cf0152c5e7f66a Mon Sep 17 00:00:00 2001 From: Phuntsok Drak-pa Date: Sat, 8 Aug 2020 20:50:26 +0200 Subject: [PATCH] =?UTF-8?q?Saved=20files=E2=80=99=20filename=20now=20holds?= =?UTF-8?q?=20local=20time=20(#505)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correcting PR #504, which made saved files’ filenames follow the UTC. This commit modifies the way the filename is generated and makes it follow the user’s local time. --- modules/ui/editors.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/ui/editors.js b/modules/ui/editors.js index 28c8a83f4..58e493701 100644 --- a/modules/ui/editors.js +++ b/modules/ui/editors.js @@ -544,9 +544,18 @@ function unfog(id) { } function getFileName(dataType) { + const formatTime = (time) => { + return (time < 10) ? "0" + time : time; + }; const name = mapName.value; const type = dataType ? dataType + " " : ""; - const dateString = new Date().toISOString().replace(/:[0-9]+\..*/, "").replace(/[T:]/g, "-"); + const date = new Date(); + const year = date.getFullYear(); + const month = formatTime(date.getMonth()); + const day = formatTime(date.getDay()); + const hour = formatTime(date.getHours()); + const minutes = formatTime(date.getMinutes()); + const dateString = [year, month, day, hour, minutes].join('-'); return name + " " + type + dateString; }