diff --git a/packages/lib/dayjs/timeZone.schema.ts b/packages/lib/dayjs/timeZone.schema.ts index 920ad9c225..1edea4f99f 100644 --- a/packages/lib/dayjs/timeZone.schema.ts +++ b/packages/lib/dayjs/timeZone.schema.ts @@ -3,6 +3,18 @@ import { z } from "zod"; import { isSupportedTimeZone } from "./index"; // Schema for validating IANA timezone strings compatible with Intl.DateTimeFormat -export const timeZoneSchema = z.string().refine((timeZone) => isSupportedTimeZone(timeZone), { - message: "Invalid timezone. Must be a valid IANA timezone string.", -}); +// Browserstack and some automations return +00:00 as the timezone which isn't a valid IANA timezone +// @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions#timezone +export const timeZoneSchema = z + .string() + .refine( + (timeZone) => { + // Allow +00:00 as a special case - it will be transformed to UTC + if (timeZone === "+00:00") { + return true; + } + return isSupportedTimeZone(timeZone); + }, + { message: "Invalid timezone. Must be a valid IANA timezone string." } + ) + .transform((timeZone) => (timeZone === "+00:00" ? "UTC" : timeZone));