3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-08 00:05:01 +00:00

feat: fix leap year rules, add year and month to the delay string

This commit is contained in:
Ruby 2025-01-03 15:12:43 +01:00
parent 504ffd729d
commit 5c0602715d
No known key found for this signature in database
GPG key ID: E0BDFAF7AE9E0531
28 changed files with 64 additions and 55 deletions

View file

@ -29,7 +29,7 @@ import {
import emojiRegex from "emoji-regex";
import fs from "fs";
import https from "https";
import humanizeDuration from "humanize-duration";
import { humanizeDuration, delayStringMultipliers } from "./humanizeDuration.js";
import isEqual from "lodash/isEqual.js";
import { performance } from "perf_hooks";
import tlds from "tlds" assert { type: "json" };
@ -45,21 +45,14 @@ import { waitForButtonConfirm } from "./utils/waitForInteraction.js";
const fsp = fs.promises;
const delayStringMultipliers = {
w: 1000 * 60 * 60 * 24 * 7,
d: 1000 * 60 * 60 * 24,
h: 1000 * 60 * 60,
m: 1000 * 60,
s: 1000,
x: 1,
};
export const MS = 1;
export const SECONDS = 1000 * MS;
export const MINUTES = 60 * SECONDS;
export const HOURS = 60 * MINUTES;
export const DAYS = 24 * HOURS;
export const WEEKS = 7 * 24 * HOURS;
export const WEEKS = 7 * DAYS;
export const YEARS = (365 + 1/4 - 1/100 + 1/400) * DAYS;
export const MONTHS = YEARS / 12
export const EMPTY_CHAR = "\u200b";
@ -408,7 +401,7 @@ const MAX_DELAY_STRING_AMOUNT = 100 * 365 * DAYS;
* Turns a "delay string" such as "1h30m" to milliseconds
*/
export function convertDelayStringToMS(str, defaultUnit = "m"): number | null {
const regex = /^([0-9]+)\s*([wdhms])?[a-z]*\s*/;
const regex = /^([0-9]+)\s*((?:mo?)|[ywdhs])?[a-z]*\s*/;
let match;
let ms = 0;