mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-23 23:11:13 -04:00
WIP
This commit is contained in:
parent
539683f8e9
commit
c1ccaa7a9f
8 changed files with 93 additions and 45 deletions
|
@ -648,8 +648,14 @@ module.exports.send403 = (res, msg = "") => {
|
|||
};
|
||||
|
||||
function timeObjectConvertTimezone(obj, timezone, timeObjectToUTC = true) {
|
||||
// e.g. +08:00
|
||||
let offsetString = dayjs().tz(timezone).format("Z");
|
||||
let offsetString;
|
||||
|
||||
if (timezone) {
|
||||
offsetString = dayjs().tz(timezone).format("Z");
|
||||
} else {
|
||||
offsetString = dayjs().format("Z");
|
||||
}
|
||||
|
||||
let hours = parseInt(offsetString.substring(1, 3));
|
||||
let minutes = parseInt(offsetString.substring(4, 6));
|
||||
|
||||
|
@ -680,10 +686,22 @@ function timeObjectConvertTimezone(obj, timezone, timeObjectToUTC = true) {
|
|||
return obj;
|
||||
}
|
||||
|
||||
module.exports.timeObjectToUTC = (obj, timezone) => {
|
||||
/**
|
||||
*
|
||||
* @param {object} obj
|
||||
* @param {string} timezone
|
||||
* @returns {object}
|
||||
*/
|
||||
module.exports.timeObjectToUTC = (obj, timezone = undefined) => {
|
||||
return timeObjectConvertTimezone(obj, timezone, true);
|
||||
};
|
||||
|
||||
module.exports.timeObjectToLocal = (obj, timezone) => {
|
||||
/**
|
||||
*
|
||||
* @param {object} obj
|
||||
* @param {string} timezone
|
||||
* @returns {object}
|
||||
*/
|
||||
module.exports.timeObjectToLocal = (obj, timezone = undefined) => {
|
||||
return timeObjectConvertTimezone(obj, timezone, false);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue