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.

Quick Event: 06:15 is a quarter past six in the morning

Yashwanth Kamireddi330066cbdfd0
diff --git a/.uiverify/calendar-quick.test.mjs b/.uiverify/calendar-quick.test.mjs
index 295f9cc..42f0750 100644
--- a/.uiverify/calendar-quick.test.mjs
+++ b/.uiverify/calendar-quick.test.mjs
@@ -94,3 +94,11 @@ test("a range whose am or pm comes at its end is read on that side, on the day n
assert.deepEqual([q("Shift tomorrow 9-5pm").startsAt, q("Shift tomorrow 9-5pm").endsAt], [at(2026, 9, 22, 9), at(2026, 9, 22, 17)]);
assert.deepEqual([q("Party tomorrow 11-1am").startsAt, q("Party tomorrow 11-1am").endsAt], [at(2026, 9, 22, 23), at(2026, 9, 23, 1)]);
});
+
+test("an hour written with its leading zero is a 24-hour clock's: 06:15 is the morning", () => {
+ const r = q("Flight Fri 06:15");
+ assert.equal(r.startsAt, at(2026, 9, 23, 6, 15));
+ assert.equal(q("Train Fri 05:40-07:10").endsAt, at(2026, 9, 23, 7, 10));
+ // Without the zero, a bare hour is still read as people mean one.
+ assert.equal(q("Dentist Fri 3:30").startsAt, at(2026, 9, 23, 15, 30));
+});
diff --git a/src/screens/calendar/quick.ts b/src/screens/calendar/quick.ts
index a544d75..847605b 100644
--- a/src/screens/calendar/quick.ts
+++ b/src/screens/calendar/quick.ts
@@ -34,7 +34,8 @@ const monthOf = (w: string) => MONTHS.findIndex((m) => m.startsWith(w.slice(0, 3
const TIME = String.raw`(noon|midday|midnight|\d{1,2}(?::\d{2}|\.\d{2})?\s*(?:a\.?m\.?|p\.?m\.?)?)`;
const DASH = String.raw`\s*(?:-|–|—|to|till|until)\s*`;
-type Clock = { h: number; m: number; meridiem: "am" | "pm" | null };
+/** `exact`: an hour written with its leading zero ("06:15"), a 24-hour clock's, read as written. */
+type Clock = { h: number; m: number; meridiem: "am" | "pm" | null; exact?: boolean };
function clockOf(raw: string): Clock | null {
const t = raw.trim().toLowerCase();
@@ -47,12 +48,13 @@ function clockOf(raw: string): Clock | null {
if (min > 59) return null;
const meridiem = m[3] ? (m[3][0] === "a" ? "am" : "pm") : null;
if (meridiem ? h < 1 || h > 12 : h > 23) return null;
- return { h, m: min, meridiem };
+ return { h, m: min, meridiem, ...(!meridiem && m[1].length === 2 && m[1][0] === "0" ? { exact: true } : {}) };
}
/** Hours on a 24-hour clock. A bare hour with no am or pm is read as people mean one: 1 to 6
* in the afternoon, 7 to 11 in the morning — "lunch at 1", "gym at 7". */
function hours24(c: Clock, guess: "am" | "pm" | null = null): number {
+ if (c.exact) return c.h;
const meridiem = c.meridiem ?? (c.h > 12 || c.h === 0 ? null : guess ?? (c.h >= 1 && c.h <= 6 ? "pm" : c.h === 12 ? "pm" : "am"));
if (!meridiem) return c.h;
if (meridiem === "am") return c.h === 12 ? 0 : c.h;