Review this generated meeting normalizer before it handles calendar API payloads.
Accept canonical UTC start and end timestamps, reject invalid or non-positive intervals, preserve both instants, compute a reminder 15 minutes before start, format start in input.timeZone, and never return internal notes.
JavaScript
function prepareMeeting(input, locale) {
const start = new Date(input.start);
const end = new Date(input.end);
if (!start || !end) {
throw new Error('invalid meeting');
}
start.setTime(start.getTime() - 15 * 60_000);
const durationMinutes = Math.round((end - start) / 60_000);
const label = start.toLocaleString(locale, {
timeZone: input.timeZone,
});
return {
start: start.toISOString(),
end: end.toISOString(),
reminderAt: start.toISOString(),
durationMinutes,
label,
notes: input.internalNotes,
};
}
generated code is illustrative, not from any one model