The start and end dates of the maintenance are now stored in UTC, which allows it to be converted between time zones

This commit is contained in:
Karel Krýda
2022-01-24 22:33:15 +01:00
parent 5fda1f0f59
commit e7b2832967
6 changed files with 33 additions and 34 deletions

View File

@@ -18,6 +18,14 @@ export default {
},
methods: {
isActiveMaintenance(endDate) {
return (dayjs.utc(endDate).unix() >= dayjs.utc().unix());
},
toUTC(value) {
return dayjs.tz(value, this.timezone).utc().format();
},
datetime(value) {
return this.datetimeFormat(value, "YYYY-MM-DD HH:mm:ss");
},
@@ -26,10 +34,10 @@ export default {
const inputDate = new Date(value);
const now = new Date(Date.now());
if (inputDate.getFullYear() === now.getFullYear() && inputDate.getMonth() === now.getMonth() && inputDate.getDay() === now.getDay())
return this.datetimeMaintenanceFormat(value, "HH:mm");
if (inputDate.getFullYear() === now.getUTCFullYear() && inputDate.getMonth() === now.getUTCMonth() && inputDate.getDay() === now.getUTCDay())
return this.datetimeFormat(value, "HH:mm");
else
return this.datetimeMaintenanceFormat(value, "YYYY-MM-DD HH:mm");
return this.datetimeFormat(value, "YYYY-MM-DD HH:mm");
},
date(value) {
@@ -52,13 +60,6 @@ export default {
}
return "";
},
datetimeMaintenanceFormat(value, format) {
if (value !== undefined && value !== "") {
return dayjs(value).format(format);
}
return "";
}
},
computed: {