From 0928b4cd7f6f2a99e99302440dfff7f1dad5a00e Mon Sep 17 00:00:00 2001 From: vkpdeveloper Date: Fri, 6 Nov 2026 01:24:30 +0530 Subject: [PATCH 1/2] fix(provider-utils): read offset-less event times in their own time zone eventTimeToInstant parsed a dateTime without an offset with Date.parse, so it used the host's zone and ignored timeZone. The mock calendar then reported busy times hours off wherever the host zone differed from the event's. --- .changeset/local-event-times.md | 6 ++++++ packages/provider-utils/src/time/event-time.ts | 11 ++++++++--- packages/provider-utils/src/time/time.test.ts | 10 ++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .changeset/local-event-times.md diff --git a/.changeset/local-event-times.md b/.changeset/local-event-times.md new file mode 100644 index 0000000..07c72c2 --- /dev/null +++ b/.changeset/local-event-times.md @@ -0,0 +1,6 @@ +--- +'@cal-sdk/provider-utils': patch +'@cal-sdk/mock': patch +--- + +Event times without an offset, such as `{ dateTime: '2026-11-09T10:00:00', timeZone: 'Europe/Berlin' }`, are read in their own time zone instead of the machine's. This fixes busy times, listing windows and recurrence expansion in the mock calendar. diff --git a/packages/provider-utils/src/time/event-time.ts b/packages/provider-utils/src/time/event-time.ts index 644c21b..f44edcc 100644 --- a/packages/provider-utils/src/time/event-time.ts +++ b/packages/provider-utils/src/time/event-time.ts @@ -10,11 +10,16 @@ export function isAllDay(time: EventTimeV1): time is Extract { expect(eventTimeToInstant({ date: '2026-11-03' })).toBe(Date.parse('2026-11-03T00:00:00Z')); }); + it('reads a date-time without an offset in its own time zone, not the host zone', () => { + expect( + eventTimeToInstant({ dateTime: '2026-11-09T10:00:00', timeZone: 'Europe/Berlin' }), + ).toBe(Date.parse('2026-11-09T09:00:00Z')); + // Daylight saving time in New York. + expect( + eventTimeToInstant({ dateTime: '2026-07-01T09:30', timeZone: 'America/New_York' }), + ).toBe(Date.parse('2026-07-01T13:30:00Z')); + }); + it('adds days across month and year ends', () => { expect(addDaysToDate('2026-12-31', 1)).toBe('2027-01-01'); expect(addDaysToDate('2028-03-01', -1)).toBe('2028-02-29'); From 34020f6446e014eabd147b1fec05376de8638f18 Mon Sep 17 00:00:00 2001 From: vkpdeveloper Date: Fri, 6 Nov 2026 01:29:12 +0530 Subject: [PATCH 2/2] style: format the local time test --- packages/provider-utils/src/time/time.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/provider-utils/src/time/time.test.ts b/packages/provider-utils/src/time/time.test.ts index ffc45cc..784d467 100644 --- a/packages/provider-utils/src/time/time.test.ts +++ b/packages/provider-utils/src/time/time.test.ts @@ -116,13 +116,13 @@ describe('event time', () => { }); it('reads a date-time without an offset in its own time zone, not the host zone', () => { - expect( - eventTimeToInstant({ dateTime: '2026-11-09T10:00:00', timeZone: 'Europe/Berlin' }), - ).toBe(Date.parse('2026-11-09T09:00:00Z')); + expect(eventTimeToInstant({ dateTime: '2026-11-09T10:00:00', timeZone: 'Europe/Berlin' })).toBe( + Date.parse('2026-11-09T09:00:00Z'), + ); // Daylight saving time in New York. - expect( - eventTimeToInstant({ dateTime: '2026-07-01T09:30', timeZone: 'America/New_York' }), - ).toBe(Date.parse('2026-07-01T13:30:00Z')); + expect(eventTimeToInstant({ dateTime: '2026-07-01T09:30', timeZone: 'America/New_York' })).toBe( + Date.parse('2026-07-01T13:30:00Z'), + ); }); it('adds days across month and year ends', () => {