Made getTimezone into an exported lambda.

This commit is contained in:
Alexander Andreev 2021-02-17 03:28:23 +04:00
parent 1c632dcf80
commit efbb18cdea
Signed by: Arav
GPG Key ID: 610DF2574456329F

10
util.js
View File

@ -5,11 +5,6 @@ const formats = Object.freeze({
file_date: "YYYY-MM-DD HH:mm:ss z",
id_date: "YYYYMMDD-HHmm" });
function getTimezone(ctx) {
if (ctx.header['x-client-timezone'] !== undefined)
return ctx.header['x-client-timezone'];
}
function datetime(date, format=formats.post_date, timezone="UTC") {
return moment.utc(date).tz(timezone).format(format);
}
@ -35,7 +30,10 @@ exports.getServiceByHost = (host, service="") => {
}
}
exports.getTimezone = getTimezone;
exports.getTimezone = ctx => {
if (ctx.header['x-client-timezone'] !== undefined)
return ctx.header['x-client-timezone'];
};
exports.formats = formats;
exports.datetime = datetime;