/
githubmirror
/
novu
Обзор
Документация
Войти
/
githubmirror
/
novu
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
next
libs/application-generic/src/utils/duration-utils.ts
29 строк
793 B
Dima Grossman
feat(api, worker, dashboard): dynamic delay fixes NV-6713 (#9329)
21 окт 2025, 20:21
Не верифицирован
21 окт 2025, 20:21
b1c7992
Код
Авторство
О чём код?
export class DurationUtils { static isISO8601(value: string): boolean { const iso8601Regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z?$/; if (!iso8601Regex.test(value)) { return false; } const date = new Date(value); return !Number.isNaN(date.getTime()); } static convertToMilliseconds(amount: number, unit: string): number { const unitMap: Record<string, number> = { seconds: 1000, minutes: 60 * 1000, hours: 60 * 60 * 1000, days: 24 * 60 * 60 * 1000, weeks: 7 * 24 * 60 * 60 * 1000, months: 30 * 24 * 60 * 60 * 1000, }; if (!unitMap[unit]) { throw new Error(`Invalid time unit '${unit}'. Supported units: ${Object.keys(unitMap).join(', ')}`); } return amount * unitMap[unit]; } }