Saved files’ filename now holds local time (#505)

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.
This commit is contained in:
Phuntsok Drak-pa 2020-08-08 20:50:26 +02:00 committed by GitHub
parent 04a50992c9
commit 0cceb31288
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -544,9 +544,18 @@ function unfog(id) {
} }
function getFileName(dataType) { function getFileName(dataType) {
const formatTime = (time) => {
return (time < 10) ? "0" + time : time;
};
const name = mapName.value; const name = mapName.value;
const type = dataType ? dataType + " " : ""; 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; return name + " " + type + dateString;
} }