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:
parent
504ffd729d
commit
5c0602715d
28 changed files with 64 additions and 55 deletions
backend/src
34
backend/src/humanizeDuration.ts
Normal file
34
backend/src/humanizeDuration.ts
Normal 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
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue