Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Calendar: the hour grid keeps to the clock on the days it moves

Yashwanth Kamireddiac426a264963
diff --git a/.uiverify/calendar-dst-grid.mjs b/.uiverify/calendar-dst-grid.mjs
new file mode 100644
index 0000000..e244042
--- /dev/null
+++ b/.uiverify/calendar-dst-grid.mjs
@@ -0,0 +1,49 @@
+// Day view on the morning the clocks go forward: a meeting at nine is drawn on the 9 line, and
+// an event made by double-clicking at nine — or dragging from nine — is made at nine. Counted as
+// time since midnight, both were an hour off after the change.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const BASE = process.env.BASE ?? "http://localhost:4202";
+const HOUR_PX = 48;
+const b = await engine.launch();
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+
+// 8 March 2026, New York: 2 AM becomes 3 AM. Nine o'clock that morning is 13:00 UTC.
+const nine = Date.UTC(2026, 2, 8, 13) / 1000;
+const ctx = await b.newContext({ viewport: { width: 1300, height: 900 }, timezoneId: "America/New_York", locale: "en-US" });
+await ctx.addInitScript((e) => { window.__fixedEvents = e; }, [
+ { guid: "dst1", calendarGuid: "work", title: "Spring standup", location: null, startsAt: nine, endsAt: nine + 3600,
+ allDay: false, timezone: "America/New_York", url: null, notes: null, etag: null },
+]);
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, calendarFixture: true });
+const page = await ctx.newPage();
+await page.goto(BASE, { waitUntil: "networkidle" });
+await openScreen(page, "Calendar");
+await page.keyboard.press("Control+1");
+await page.keyboard.press("Shift+Control+T");
+await page.getByRole("dialog", { name: "Go to Date" }).getByLabel("Date").fill("2026-03-08");
+await page.keyboard.press("Enter");
+await page.waitForTimeout(600);
+
+const block = page.locator(".cx-block", { hasText: "Spring standup" });
+const top = await block.evaluate((el) => parseFloat(el.style.top)).catch(() => NaN);
+ok(top === 9 * HOUR_PX, `the nine o'clock meeting is drawn on the 9 line (top ${top}px, wanted ${9 * HOUR_PX}px)`);
+
+// A double-click at half past eleven, well clear of the meeting.
+const columns = page.locator(".cx-columns");
+await page.locator(".cx-scroll").evaluate((el) => { el.scrollTop = 8 * 48; });
+await page.waitForTimeout(100);
+const box = await columns.boundingBox();
+await page.mouse.dblclick(box.x + box.width / 2, box.y + 11.5 * HOUR_PX + 4);
+await page.waitForTimeout(300);
+const made = page.locator(".cx-block.is-draft .cx-block-time");
+const said = (await made.count()) ? (await made.first().innerText()).trim() : "(none)";
+ok(/^11:30\s?AM$/i.test(said), `a double-click at 11:30 makes an event at 11:30 (${said})`);
+const drawn = await page.locator(".cx-block.is-draft").first().evaluate((el) => parseFloat(el.style.top)).catch(() => NaN);
+ok(drawn === 11.5 * HOUR_PX, `and draws it where it was made (top ${drawn}px)`);
+await page.keyboard.press("Escape");
+await page.waitForTimeout(200);
+
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/calendar-dst.test.mjs b/.uiverify/calendar-dst.test.mjs
new file mode 100644
index 0000000..115d913
--- /dev/null
+++ b/.uiverify/calendar-dst.test.mjs
@@ -0,0 +1,34 @@
+// The hour grid on the two days a year the clock moves: an event is drawn by the clock it is
+// at, beside its hour's label — never by the time gone since midnight, which put everything
+// after the change an hour off. Run in a zone that moves, whatever this computer's is.
+process.env.TZ = "America/New_York";
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { placeDay } from "../src/screens/calendar/model.ts";
+
+const at = (y, m, d, h = 0, min = 0) => Math.floor(new Date(y, m, d, h, min).getTime() / 1000);
+const ev = (guid, startsAt, endsAt) =>
+ ({ guid, calendarGuid: "c", title: guid, location: null, startsAt, endsAt, allDay: false, timezone: null, url: null, notes: null, etag: null });
+
+test("the zone moves its clocks (the test means something)", () => {
+ // 8 March 2026 is 23 hours long in New York.
+ assert.equal(at(2026, 2, 9) - at(2026, 2, 8), 23 * 3600);
+});
+
+test("on the day the clocks go forward, nine o'clock is drawn at nine", () => {
+ const [p] = placeDay([ev("standup", at(2026, 2, 8, 9), at(2026, 2, 8, 10))], new Date(2026, 2, 8));
+ assert.deepEqual([p.top, p.length], [9 * 60, 60]);
+});
+
+test("on the day the clocks go back, nine o'clock is drawn at nine", () => {
+ const [p] = placeDay([ev("standup", at(2026, 10, 1, 9), at(2026, 10, 1, 10))], new Date(2026, 10, 1));
+ assert.deepEqual([p.top, p.length], [9 * 60, 60]);
+});
+
+test("an evening run across the change ends at its own hour, and past midnight at the day's end", () => {
+ const [a] = placeDay([ev("night", at(2026, 2, 8, 1), at(2026, 2, 8, 4))], new Date(2026, 2, 8));
+ // 1 AM to 4 AM on the clock: from the 1 AM line to the 4 AM line.
+ assert.deepEqual([a.top, a.length], [60, 180]);
+ const [b] = placeDay([ev("late", at(2026, 2, 8, 22), at(2026, 2, 9, 1))], new Date(2026, 2, 8));
+ assert.deepEqual([b.top, b.length], [22 * 60, 120]);
+});
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index 02db99b..a7c0ca9 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -176,7 +176,9 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
{ guid: `quince:sub:${x.id}:m2:1`, calendarGuid: `quince:sub:${x.id}`, title: "Liverpool v Spurs", location: null,
startsAt: base + 2 * DAY + 8 * HOUR, endsAt: base + 2 * DAY + 10 * HOUR, allDay: false, timezone: "Europe/London", url: null, notes: null, etag: null },
]);
- if (!n) return [...events, ...subbed];
+ // A suite's own events at fixed moments (`window.__fixedEvents`), for a given day.
+ const fixed = window.__fixedEvents ?? [];
+ if (!n) return [...events, ...subbed, ...fixed];
const extra = (window.__extra ??= Array.from({ length: n }, (_, i) => ({
guid: `many${i}`, calendarGuid: i % 2 ? "work" : "home", title: `Event ${i}`, location: null,
startsAt: base + Math.floor((i - n / 2) / 8) * DAY + (8 + (i % 8)) * HOUR, endsAt: base + Math.floor((i - n / 2) / 8) * DAY + (9 + (i % 8)) * HOUR,
@@ -261,7 +263,10 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
if (window.__longReminder && calendarFixture && !dueReminders.some((r) => r.guid === "r9"))
dueReminders.push({ guid: "r9", listGuid: "l2", title: "Sort out everything for the trip to the coast before Friday, including the tickets and the bags",
notes: "Ask Alex Rivera about the car", dueAt: base + 4 * HOUR, completedAt: null, priority: 0, etag: null });
- return calendarFixture ? dueReminders : [];
+ // A suite's own (`window.__dueExtra`), chosen as the library chooses them: by the
+ // moment Apple stores, inside the range asked for.
+ if (!calendarFixture) return [];
+ return [...dueReminders, ...(window.__dueExtra ?? []).filter((r) => r.dueAt >= args.from && r.dueAt < args.to)];
case "reminder_create":
// Kept, as Apple keeps it, with what the view implied.
{
diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsx
index 08568cf..fddde0d 100644
--- a/src/screens/calendar/CalendarView.tsx
+++ b/src/screens/calendar/CalendarView.tsx
@@ -2355,8 +2355,7 @@ const TimeGrid = memo(function TimeGrid({
// A click on empty time does nothing, as in Calendar — only a drag or a double-click
// makes an event, so looking around the week never opens a form by accident.
if (done.to - done.from > 15) {
- const base = seconds(done.day);
- onCreate(base + done.from * 60, base + done.to * 60, false, besideColumn(done.column, clientY));
+ onCreate(onClockOf(done.day, done.from), onClockOf(done.day, done.to), false, besideColumn(done.column, clientY));
}
} else if (done.kind === "resize") {
if (done.dMinutes !== 0) {
@@ -2538,8 +2537,8 @@ const TimeGrid = memo(function TimeGrid({
const at = where(e.clientX, e.clientY);
if (!at) return;
const start = Math.min(snap(Math.floor(at.minutes / 30) * 30), 23 * 60);
- const base = seconds(days[at.column]);
- onCreate(base + start * 60, base + (start + 60) * 60, false, besideColumn(at.column, e.clientY));
+ const day = days[at.column];
+ onCreate(onClockOf(day, start), onClockOf(day, start + 60), false, besideColumn(at.column, e.clientY));
}}
>
{days.map((d, column) => (
@@ -2699,6 +2698,11 @@ export function stackReminders(list: Reminder[]): { reminder: Reminder; top: num
});
}
+/** The moment `minutes` on the clock into `day` — the grid's own measure. Added to midnight as
+ * seconds, an event made after the clock moved landed an hour off where it was drawn. */
+const onClockOf = (day: Date, minutes: number) =>
+ seconds(new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, minutes));
+
const pointOf = (el: Element): Anchor => {
const r = el.getBoundingClientRect();
return { x: r.right, y: r.top };
@@ -3122,7 +3126,9 @@ function EventPopover({
// is — not a form of greyed fields with a note saying they cannot be used.
if (!editable) {
const start = dateOf(draft.startsAt);
- const end = dateOf(Math.max(draft.startsAt, draft.endsAt - (draft.allDay ? 86_400 : 0)));
+ // An all-day event's last day is the one before its end midnight — a second before it, not a
+ // fixed 86,400 seconds, which across the clock's spring change named the day before.
+ const end = dateOf(Math.max(draft.startsAt, draft.endsAt - (draft.allDay ? 1 : 0)));
const day = (d: Date) => dateText(d, { weekday: "long", day: "numeric", month: "long", year: "numeric" });
const time = (d: Date) => timeText(d, { hour: "numeric", minute: "2-digit" });
const sameDay = start.toDateString() === end.toDateString();
@@ -3214,7 +3220,7 @@ function EventPopover({
set(
allDay
? { allDay, startsAt: seconds(day), endsAt: seconds(addDays(day, 1)) }
- : { allDay, startsAt: seconds(day) + 9 * 3600, endsAt: seconds(day) + 10 * 3600 }
+ : { allDay, startsAt: onClockOf(day, 9 * 60), endsAt: onClockOf(day, 10 * 60) }
);
}}
/>
diff --git a/src/screens/calendar/model.ts b/src/screens/calendar/model.ts
index 5464b7e..b10cb1b 100644
--- a/src/screens/calendar/model.ts
+++ b/src/screens/calendar/model.ts
@@ -247,6 +247,14 @@ export function placeDayWith(
): { events: Placed[]; marks: PlacedMark[] } {
const start = seconds(midnight(day));
const end = seconds(addDays(day, 1));
+ // Minutes on the clock, as the hour labels count them — the day's end its 24:00. Counted
+ // as time gone since midnight, every block after the clock moved sat an hour off its label
+ // on the two days a year it does.
+ const onClock = (s: number) => {
+ if (s >= end) return 24 * 60;
+ const d = dateOf(s);
+ return d.getHours() * 60 + d.getMinutes() + d.getSeconds() / 60;
+ };
type Item = { top: number; length: number; column: number; columns: number } & (
| { kind: "event"; event: CalendarEvent }
| { kind: "mark"; mark: Mark }
@@ -257,7 +265,8 @@ export function placeDayWith(
.map((event): Item => {
const from = Math.max(event.startsAt, start);
const to = Math.min(Math.max(event.endsAt, event.startsAt), end);
- return { kind: "event", event, top: (from - start) / 60, length: Math.max((to - from) / 60, minLength), column: 0, columns: 1 };
+ const top = onClock(from);
+ return { kind: "event", event, top, length: Math.max(onClock(to) - top, minLength), column: 0, columns: 1 };
}),
...marks.map((mark): Item => ({ kind: "mark", mark, top: mark.top, length: mark.length, column: 0, columns: 1 })),
].sort((a, b) => a.top - b.top || b.length - a.length);