This commit is contained in:
2021-06-01 23:58:19 +00:00
parent 73d6c7c219
commit 2ddf8b9ddf
4 changed files with 80 additions and 7 deletions

View File

@@ -243,11 +243,47 @@ export default {
}
//instantiate a luxon date object from val which is assumed to be an iso string
let dt = window.$gz.DateTime.fromISO(val);
if (!dt.isValid) {
console.error("locale::addMinutes, input not valid:", {
val: val,
dt: dt
});
return val;
}
//add minutes
dt = dt.plus({ minutes: minutes });
return dt.toUTC().toString();
},
///////////////////////////////////////////////
// parse UTC ISO 8601 strings, diff, return hours
//
diffHoursFromUTC8601String(start, stop) {
if (!start || start == "" || !stop == null || stop == "") {
return 0;
}
//instantiate a luxon date object from val which is assumed to be an iso string
const startDate = window.$gz.DateTime.fromISO(start);
if (!startDate.isValid) {
console.error("locale::diffHours, start not valid:", {
start: start,
startDate: startDate
});
return 0;
}
const stopDate = window.$gz.DateTime.fromISO(stop);
if (!stopDate.isValid) {
console.error("locale::diffHours, start not valid:", {
stop: stop,
stopDate: stopDate
});
return 0;
}
return window.$gz.util.roundAccurately(
stopDate.diff(startDate, "hours").toObject().hours,
2
);
},
///////////////////////////////////////////////
// Local now timestamp converted to timeZoneName
// and output as ISO 8601
// (used to inform server of local client time)