Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -0,0 +1,30 @@
import { fromZonedTime } from "date-fns-tz";
// Wall-clock inputs ("2026-07-20T09:00") carry no offset; anything with an
// explicit offset or Z suffix is already an absolute instant.
const EXPLICIT_OFFSET = /(?:Z|[+-]\d{2}:?\d{2})$/i;
export function isValidTimeZone(timeZone: string): boolean {
try {
new Intl.DateTimeFormat("en-US", { timeZone });
return true;
} catch {
return false;
}
}
export type ParsedScheduledAt = { ok: true; date: Date | null } | { ok: false };
/**
* Resolves the campaign "scheduledAt" form value to a UTC instant.
* Wall-clock strings are interpreted in the campaign's IANA timezone —
* NOT in the server's local timezone (that was the pre-fix behavior and
* shifted scheduled sends by the server/tz offset difference).
*/
export function parseScheduledAt(value: string | null, timeZone: string): ParsedScheduledAt {
if (!value) return { ok: true, date: null };
if (!isValidTimeZone(timeZone)) return { ok: false };
const date = EXPLICIT_OFFSET.test(value) ? new Date(value) : fromZonedTime(value, timeZone);
if (Number.isNaN(date.getTime())) return { ok: false };
return { ok: true, date };
}