mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
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 `<map name> <capitalized three letter english month>D HH-mm.<ext>` Now filenames follow more closely ISO 8601 and are named by default `<map name> YYYY-MM-DD-HH-mm.<ext>`. The function also became much smaller and easier to read.
This commit is contained in:
parent
a9b16d6ee5
commit
460ccfeab7
1 changed files with 3 additions and 7 deletions
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue