Fix: Enforce UTC calculations in scheduler prompt

This commit is contained in:
2025-11-18 09:49:13 -08:00
parent afcfd09537
commit b5080d18a0

View File

@@ -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)}`) },