From 9c5baeede1abafb3c4f1bef486898d0f83d11a3c Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Fri, 7 Aug 2020 11:21:26 +0200 Subject: [PATCH] Change filename format of saved files The following commit changes the default name of files saved by the user. Originally, any saved file was named ` D HH-mm.` Now filenames follow more closely ISO 8601 and are named by default ` YYYY-MM-DD-HH-mm.`. The function also became much smaller and easier to read. --- modules/ui/editors.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/ui/editors.js b/modules/ui/editors.js index 6129dd59..1b8b83c1 100644 --- a/modules/ui/editors.js +++ b/modules/ui/editors.js @@ -546,12 +546,8 @@ function unfog(id) { function getFileName(dataType) { const name = mapName.value; const type = dataType ? dataType + " " : ""; - const date = new Date(); - const datFormatter = new Intl.DateTimeFormat("en", {month: "short", day: "numeric"}); - const timeFormatter = new Intl.DateTimeFormat("ru", {hour: "numeric", minute: "numeric"}); - const day = datFormatter.format(date).replace(" ", ""); - const time = timeFormatter.format(date).replace(":", "-"); - return name + " " + type + day + " " + time; + const dateString = new Date().toISOString().replace(/:[0-9]+\..*/, "").replaceAll(/[T:]/g, "-"); + return name + " " + type + dateString; } function downloadFile(data, name, type = "text/plain") { @@ -643,4 +639,4 @@ function refreshAllEditors() { if (document.getElementById('statesEditorRefresh').offsetParent) statesEditorRefresh.click(); if (document.getElementById('zonesEditorRefresh').offsetParent) zonesEditorRefresh.click(); console.timeEnd('refreshAllEditors'); -} \ No newline at end of file +}