chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:32:57 +08:00
commit cd420f9332
4811 changed files with 884702 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
import { parseNaturalLanguageDuration } from "@trigger.dev/core/v3/isomorphic";
export const calculateDurationInMs = (options: {
seconds?: number;
minutes?: number;
hours?: number;
days?: number;
}) => {
return (
(options?.seconds ?? 0) * 1000 +
(options?.minutes ?? 0) * 60 * 1000 +
(options?.hours ?? 0) * 60 * 60 * 1000 +
(options?.days ?? 0) * 24 * 60 * 60 * 1000
);
};
export async function parseDelay(value?: string | Date): Promise<Date | undefined> {
if (!value) {
return;
}
if (value instanceof Date) {
return value;
}
try {
const date = new Date(value);
// Check if the date is valid
if (isNaN(date.getTime())) {
return parseNaturalLanguageDuration(value);
}
if (date.getTime() <= Date.now()) {
return;
}
return date;
} catch (_error) {
return parseNaturalLanguageDuration(value);
}
}