From b5080d18a0a1146c4f650644e6539360d0bb8c05 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Tue, 18 Nov 2025 09:49:13 -0800 Subject: [PATCH] Fix: Enforce UTC calculations in scheduler prompt --- tests/7_scheduler/test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/7_scheduler/test.js b/tests/7_scheduler/test.js index 08e4004..341c3ad 100644 --- a/tests/7_scheduler/test.js +++ b/tests/7_scheduler/test.js @@ -4,12 +4,13 @@ export default { // - The function must accept two calendars (arrays of busy slots) and a constraints object. // - Calendar format: [{ start: 'ISODateString', end: 'ISODateString' }, ...] // - Constraints format: { durationMinutes: number, searchRange: { start: 'ISODateString', end: 'ISODateString' }, workHours: { start: 'HH:mm', end: 'HH:mm' } } -// - You MUST use a dynamic import() to load one or more libraries from a CDN for date/time manipulation. +// - You MUST use a dynamic import() to load one or more libraries from a CDN for date/time manipulation (e.g., date-fns, luxon, dayjs). // - Merge overlapping busy times from both calendars. Find all free time periods where both are available. // - Within each free period, generate ALL possible non-overlapping consecutive time slots of exactly 'durationMinutes' length. // - Only include slots that fall completely within work hours (workHours.start to workHours.end) and the search range. +// - CRITICAL: Perform ALL calculations in UTC. Treat workHours as UTC times (e.g. 09:00 is 09:00Z). Do not convert to local system time. // - Return an array of available slots in chronological order, each as: { start: 'ISODateString', end: 'ISODateString' } -// - Each slot must be exactly durationMinutes long. Slots must not overlap. Slots should be consecutive (next slot starts where previous ends).`, +// - Each slot must be exactly durationMinutes long. Slots must not overlap. Slots should be consecutive.`, runTest: async (findAvailableSlots) => { const assert = { deepStrictEqual: (a, e, m) => { if (JSON.stringify(a) !== JSON.stringify(e)) throw new Error(m || `FAIL: ${JSON.stringify(a)} !== ${JSON.stringify(e)}`) },