From 0ecfd78e47ee3f14a04a47a9281057a24055b9e6 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Fri, 12 Dec 2025 01:16:13 +0530 Subject: [PATCH] fix: Update timeZoneSchema to handle +00:00 timezone case and maintain IANA compliance (#25776) * fix: Update timeZoneSchema to handle +00:00 timezone case and maintain IANA compliance * fix: Use superRefine to properly handle +00:00 timezone and transform to UTC Co-Authored-By: hariom@cal.com * feat: Add logging for non-IANA timezone cases Co-Authored-By: hariom@cal.com * refactor: Simplify timeZoneSchema to use .refine() instead of superRefine Co-Authored-By: hariom@cal.com * chore: Remove warn log for +00:00 timezone to avoid spam Co-Authored-By: hariom@cal.com * chore: Remove logger from timeZone schema Co-Authored-By: hariom@cal.com --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- packages/lib/dayjs/timeZone.schema.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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));