Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Calendar: a reminder for a day is on its day, with no time
Yashwanth Kamireddif0adad255b20
diff --git a/.uiverify/calendar-allday-reminders.mjs b/.uiverify/calendar-allday-reminders.mjsnew file mode 100644index 0000000..1a475e1--- /dev/null+++ b/.uiverify/calendar-allday-reminders.mjs@@ -0,0 +1,73 @@+// A reminder for a day, not a time, in Calendar: on its own day wherever the viewer is, its card+// naming that day — not the one before, east of Greenwich — with no "12 AM" beside it in Month+// or the day's list, and found on the first day a view reads, west of Greenwich too.+//+// Apple keeps such a reminder's date as that day's midnight in UTC.+import { engine } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";+const BASE = process.env.BASE ?? "http://localhost:4202";+const b = await engine.launch();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };++/** A day's UTC midnight, as Apple stores an all-day date. */+const utcDay = (y, m, d) => Date.UTC(y, m, d) / 1000;+const allDay = (guid, title, dueAt) => ({ guid, listGuid: "l1", title, notes: null, dueAt, allDay: true, completedAt: null, priority: 0, etag: null });++async function open(timezoneId, due) {+ const ctx = await b.newContext({ viewport: { width: 1300, height: 900 }, timezoneId, locale: "en-GB" });+ await ctx.addInitScript((d) => { window.__dueExtra = d; }, due);+ await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, calendarFixture: true, remindersFixture: true });+ const page = await ctx.newPage();+ await page.goto(BASE, { waitUntil: "networkidle" });+ await openScreen(page, "Calendar");+ await page.waitForTimeout(400);+ return { ctx, page };+}++// East of Greenwich: the card names the reminder's own day.+{+ // Tomorrow, on the clock of a zone east of UTC, as Apple stores it.+ const now = new Date(new Date().toLocaleString("en-US", { timeZone: "Asia/Kolkata" }));+ const day = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);+ const { ctx, page } = await open("Asia/Kolkata", [allDay("ad1", "Renew the passport", utcDay(day.getFullYear(), day.getMonth(), day.getDate()))]);+ await page.keyboard.press("Control+3");+ await page.waitForTimeout(400);+ const item = page.locator(".cx-item.is-reminder", { hasText: "Renew the passport" }).first();+ ok((await item.count()) === 1, "Month: the day's reminder is in its cell");+ const time = (await item.locator(".cx-item-time").count()) ? (await item.locator(".cx-item-time").innerText()).trim() : "";+ ok(!/\d/.test(time), `Month: with no time beside it ${JSON.stringify(time)}`);+ await item.click();+ const card = page.locator(".cx-popover.is-reminder");+ await card.waitFor({ timeout: 2000 }).catch(() => {});+ const text = (await card.count()) ? await card.innerText() : "";+ const wanted = `${day.toLocaleDateString("en-GB", { weekday: "long" })}, ${day.toLocaleDateString("en-GB", { day: "numeric", month: "long" })}`;+ ok(text.includes(wanted), `its card names its day, ${wanted} ${JSON.stringify(text.split("\n").slice(0, 3))}`);+ await page.keyboard.press("Escape");+ // The day's list, in Day.+ await page.keyboard.press("Control+1");+ await page.keyboard.press("Shift+Control+T");+ const pad = (n) => String(n).padStart(2, "0");+ await page.getByRole("dialog", { name: "Go to Date" }).getByLabel("Date").fill(`${day.getFullYear()}-${pad(day.getMonth() + 1)}-${pad(day.getDate())}`);+ await page.keyboard.press("Enter");+ await page.waitForTimeout(400);+ const row = page.locator(".cx-pane-reminder", { hasText: "Renew the passport" });+ const when = (await row.count()) ? (await row.locator(".cx-pane-when").innerText()).trim() : "(none)";+ ok((await row.count()) === 1 && !/\d/.test(when), `Day: in the day's list, with no time ${JSON.stringify(when)}`);+ await ctx.close();+}++// West of Greenwich: one on the first day a view reads is there too — 1 January, in Year.+{+ const year = new Date().getFullYear();+ const { ctx, page } = await open("America/New_York", [allDay("ad2", "New year plans", utcDay(year, 0, 1))]);+ await page.keyboard.press("Control+4");+ await page.waitForTimeout(600);+ const jan1 = page.locator(".cal-year button.cx-minimonth-day").first();+ const cls = (await jan1.getAttribute("class")) ?? "";+ ok(/is-busy/.test(cls), `Year: 1 January shows it has something ${JSON.stringify(cls)}`);+ await ctx.close();+}++await b.close();+process.exitCode = failures ? 1 : 0;diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsxindex fddde0d..73ca67c 100644--- a/src/screens/calendar/CalendarView.tsx+++ b/src/screens/calendar/CalendarView.tsx@@ -591,7 +591,10 @@ export function CalendarView() {const [found, cals, reminders, lists, feeds] = await Promise.all([api.calendarEvents(range.from, range.to),api.calendarList(),- api.remindersDueBetween(range.from, range.to),+ // A day either side: an all-day reminder is kept as its day's midnight in UTC, which west+ // of Greenwich is the evening before the view's first local midnight — and was left out.+ // Each is placed by its own day below, so one outside the view is simply not drawn.+ api.remindersDueBetween(range.from - 86_400, range.to + 86_400),api.reminderLists().catch(() => []),calendarFeedsApi.list().catch(() => [] as CalendarSubscription[]),]);@@ -2157,11 +2160,12 @@ const MonthView = memo(function MonthView({className={`cx-item is-reminder${item.reminder.completedAt ? " is-done" : ""}`}style={listColour(item.reminder)}{...showReminder(item.reminder)}- title={dots ? `${item.reminder.title} · ${clock(item.at)}` : item.reminder.title}+ title={dots && !item.reminder.allDay ? `${item.reminder.title} · ${clock(item.at)}` : item.reminder.title}><Ring reminder={item.reminder} quiet /><span className="cx-item-title">{item.reminder.title}</span>- <span className="cx-item-time">{clock(item.at)}</span>+ {/* A day's reminder has no time: "12 AM" beside it said it had one. */}+ {!item.reminder.allDay && <span className="cx-item-time">{clock(item.at)}</span>}</span></li>)@@ -2977,7 +2981,9 @@ function ReminderCard({ reminder, at, list, onClose }: {const due = reminder.dueAt === null ? null : dateOf(reminder.dueAt);const when = due? reminder.allDay- ? dateText(due, { weekday: "long", day: "numeric", month: "long", year: "numeric", timeZone: "UTC" })+ // Its day as read in (`onItsDay`): already this clock's midnight. Read again in UTC, it+ // named the day before east of Greenwich.+ ? dateText(due, { weekday: "long", day: "numeric", month: "long", year: "numeric" }): `${dateText(due, { weekday: "long", day: "numeric", month: "long", year: "numeric" })}, ${timeText(due, { hour: "numeric", minute: "2-digit" })}`: null;return (@@ -3447,7 +3453,7 @@ const DayPane = memo(function DayPane({<div className="cx-pane-reminder" style={listColour(r)} {...showReminder(r)}><Ring reminder={r} quiet /><span className="cx-pane-title">{r.title}</span>- <span className="cx-pane-when">{clock(r.dueAt ?? 0)}</span>+ <span className="cx-pane-when">{r.allDay ? "all-day" : clock(r.dueAt ?? 0)}</span></div></li>))}