3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-14 22:05:01 +00:00
zeppelin/backend/src/plugins/TimeAndDate/functions/inGuildTz.ts
2024-04-09 20:57:18 +03:00

17 lines
562 B
TypeScript

import { GuildPluginData } from "knub";
import moment from "moment-timezone";
import { TimeAndDatePluginType } from "../types.js";
import { getGuildTz } from "./getGuildTz.js";
export function inGuildTz(pluginData: GuildPluginData<TimeAndDatePluginType>, input?: moment.Moment | number) {
let momentObj: moment.Moment;
if (typeof input === "number") {
momentObj = moment.utc(input, "x");
} else if (moment.isMoment(input)) {
momentObj = input.clone();
} else {
momentObj = moment.utc();
}
return momentObj.tz(getGuildTz(pluginData));
}