3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-14 05:45:02 +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

@ -0,0 +1,34 @@
import humanizeduration from "humanize-duration";
export const delayStringMultipliers = {
y: 1000 * 60 * 60 * 24 * (365 + 1 / 4 - 1 / 100 + 1 / 400),
mo: 1000 * 60 * 60* 24 * (365 + 1 / 4 - 1 / 100 + 1 / 400) / 12,
w: 1000 * 60 * 60 * 24 * 7,
d: 1000 * 60 * 60 * 24,
h: 1000 * 60 * 60,
m: 1000 * 60,
s: 1000,
x: 1,
};
export const humanizeDurationShort = humanizeduration.humanizer({
language: "shortEn",
languages: {
shortEn: {
y: () => "y",
mo: () => "mo",
w: () => "w",
d: () => "d",
h: () => "h",
m: () => "m",
s: () => "s",
ms: () => "ms",
},
},
spacer: "",
unitMeasures: delayStringMultipliers
});
export const humanizeDuration = humanizeduration.humanizer({
unitMeasures: delayStringMultipliers
});