You ported Larkspur Physio’s reminder report from Python to JavaScript. The report reads the clinic’s export, keeps the coming week’s appointments, orders them, and prints each patient’s appointment and reminder in their own zone. The clinician totals are the next exercise’s task.
- Keep the clinic zone as a region name, the week as a seven-day duration, and the reminder lead as one calendar day. The formatting options replace Python’s format pattern.
- Parse the export once.
clinicTime()reads each UTC timestamp as an Instant and converts it to the clinic’s London zone. Mapping copies the other appointment fields. - Use the static
Temporal.ZonedDateTime.compare()method for both ends of the week and for sorting the start fields. The opening boundary is inclusive; the ending boundary is exclusive. - Change to the patient’s zone for the printed label and reminder. Check the closed day against the appointment’s London date with
.equals(). A closed booking skips both its reminder and its booked-time contribution. subtract({ days: 1 })preserves the intended local reminder time across the New York clock change. The locale chooses the wording; the zoned value supplies the time zone.- The header formats the supplied run clock. The fixed Thursday check shows 08:00 in both London and UTC.
- The map accumulates each clinician’s booked minutes. The daily entry point calls
Temporal.Now.zonedDateTimeISO("UTC")to read the current moment in UTC, matching Python’s run clock. The separate check supplies a fixed Thursday morning instead.
Save this port as reminders.js in your existing ~/reminders folder. Its package.json
contains { "type": "module" }. The complete port so far is below.
The complete reminders.js so far
Here is the complete file so far:
reminders.js
/**
* Print the clinic's weekly appointment reminders.
*/
const CLINIC_ZONE = "Europe/London";
const WEEK = Temporal.Duration.from({ days: 7 });
const REMINDER_LEAD = { days: 1 };
const TIME_FORMAT = {
weekday: "long",
day: "2-digit",
month: "long",
hour: "2-digit",
minute: "2-digit",
};
const ZONES = {
"Fiona Mackay": "Europe/London",
"Dana Whitfield": "America/New_York",
"Jonas Becker": "Europe/Berlin",
"Isla Grant": "Europe/London",
"Callum Reid": "America/New_York",
};
const EXPORT_TEXT = `{
"closed": "2026-11-03",
"appointments": [
{
"patient": "Dana Whitfield",
"clinician": "Callum Reid",
"start": "2026-11-01T15:00:00Z",
"minutes": 50
},
{
"patient": "Fiona Mackay",
"clinician": "Isla Grant",
"start": "2026-10-30T09:30:00Z",
"minutes": 50
},
{
"patient": "Jonas Becker",
"clinician": "Isla Grant",
"start": "2026-11-02T16:00:00Z",
"minutes": 50
},
{
"patient": "Fiona Mackay",
"clinician": "Isla Grant",
"start": "2026-11-03T11:00:00Z",
"minutes": 50
},
{
"patient": "Dana Whitfield",
"clinician": "Callum Reid",
"start": "2026-10-30T17:00:00Z",
"minutes": 30
},
{
"patient": "Jonas Becker",
"clinician": "Isla Grant",
"start": "2026-11-05T09:00:00Z",
"minutes": 50
}
]
}`;
function clinicTime(text) {
return Temporal.Instant.from(text)
.toZonedDateTimeISO(CLINIC_ZONE);
}
export function main(now) {
const data = JSON.parse(EXPORT_TEXT);
const closed = Temporal.PlainDate.from(data.closed);
const weekEnd = now.add(WEEK);
const week = data.appointments
.map(appt => ({
...appt,
start: clinicTime(appt.start),
}))
.filter(appt =>
Temporal.ZonedDateTime.compare(now, appt.start) <= 0
&& Temporal.ZonedDateTime.compare(
appt.start, weekEnd,
) < 0
)
.toSorted((a, b) =>
Temporal.ZonedDateTime.compare(a.start, b.start)
);
const heading = now.toLocaleString("en-GB", TIME_FORMAT);
console.log(`Reminders for the week from ${heading}`);
const booked = new Map();
for (const appt of week) {
const start = appt.start.withTimeZone(ZONES[appt.patient]);
const when = start.toLocaleString("en-GB", TIME_FORMAT);
const label = `${appt.patient}: ${when}`;
if (appt.start.toPlainDate().equals(closed)) {
console.log(`${label}, clinic closed: rebook`);
continue;
}
const reminder = start.subtract(REMINDER_LEAD);
const due = reminder.toLocaleString("en-GB", TIME_FORMAT);
console.log(`${label}, reminder ${due}`);
const clinician = appt.clinician;
const total = booked.get(clinician) ?? new Temporal.Duration();
booked.set(clinician, total.add({ minutes: appt.minutes }));
}
// Add the booked-time lines in the exercise.
}
if (import.meta.main) {
main(Temporal.Now.zonedDateTimeISO("UTC"));
}
This brings the reminder report together in one file.
To check the same Thursday-morning run as Python, save this separate caller as
check-reminders.js in the same folder. Importing the script doesn’t run its daily entry point: