3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-08 11:37:20 +00:00

Add time_and_date plugin. Use it for timezones and date formats around the bot.

This commit is contained in:
Dragory 2020-08-19 00:19:12 +03:00
parent cffb0dbd6b
commit 4ae8cf85a3
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
67 changed files with 543 additions and 177 deletions

View file

@ -1,11 +1,11 @@
import moment, { Moment } from "moment-timezone";
import { convertDelayStringToMS } from "src/utils";
import { PluginData } from "knub";
import { getGuildTz } from "../../../utils/timezones";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
// TODO: Extract out of the Post plugin, use everywhere with a date input
export function parseScheduleTime(pluginData: PluginData<any>, str: string): Moment {
const tz = getGuildTz(pluginData);
export async function parseScheduleTime(pluginData: PluginData<any>, memberId: string, str: string): Promise<Moment> {
const tz = await pluginData.getPlugin(TimeAndDatePlugin).getMemberTz(memberId);
const dt1 = moment.tz(str, "YYYY-MM-DD HH:mm:ss", tz);
if (dt1 && dt1.isValid()) return dt1;