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.

Reminders: how long it takes stays in the title

Yashwanth Kamireddi38f64c36f9e2
diff --git a/.uiverify/reminder-quick.test.mjs b/.uiverify/reminder-quick.test.mjs
index a078ef0..b29b39c 100644
--- a/.uiverify/reminder-quick.test.mjs
+++ b/.uiverify/reminder-quick.test.mjs
@@ -46,3 +46,13 @@ test("a place is kept in the title", () => {
const q = parseReminder("Pick up parcel at the post office tomorrow", now, true);
assert.match(q.title, /post office/);
});
+
+test("how long it takes is part of what to do: it stays in the title", () => {
+ // A reminder has no length. Read as one, "for 20 minutes" went from the title unsaid.
+ const read = parseReminder("Read for 20 minutes daily", now, true);
+ assert.deepEqual([read.title, read.repeat], ["Read for 20 minutes", { frequency: 0, interval: 1 }]);
+ const piano = parseReminder("Practice piano for an hour tomorrow", now, true);
+ assert.deepEqual([piano.title, piano.dueAt, piano.allDay], ["Practice piano for an hour", local(2026, 9, 23), true]);
+ const run = parseReminder("Run for 30 mins tomorrow 7am", now, true);
+ assert.deepEqual([run.title, run.dueAt, run.allDay], ["Run for 30 mins", local(2026, 9, 23, 7), false]);
+});
diff --git a/src/screens/calendar/quick.ts b/src/screens/calendar/quick.ts
index 0474a42..9242a0c 100644
--- a/src/screens/calendar/quick.ts
+++ b/src/screens/calendar/quick.ts
@@ -79,7 +79,9 @@ function dayFirst(): boolean {
}
}
-export function parseQuick(text: string, now: Date = new Date(), dmy: boolean = dayFirst()): Quick {
+/** `lengths`: whether "for an hour" is read as how long it lasts — an event's, not a
+ * reminder's, which has no length and keeps the words. */
+export function parseQuick(text: string, now: Date = new Date(), dmy: boolean = dayFirst(), lengths = true): Quick {
let rest = ` ${text.replace(/\s+/g, " ").trim()} `;
const today = midnightOf(now);
let day = null as Date | null;
@@ -176,7 +178,7 @@ export function parseQuick(text: string, now: Date = new Date(), dmy: boolean =
if (!c) return false;
start = c;
});
- take(w(String.raw`for\s+(\d+(?:\.\d+)?|an?|half\s+an?)\s*(minutes?|mins?|m|hours?|hrs?|h)`), (m) => {
+ if (lengths) take(w(String.raw`for\s+(\d+(?:\.\d+)?|an?|half\s+an?)\s*(minutes?|mins?|m|hours?|hrs?|h)`), (m) => {
const n = /half/i.test(m[1]) ? 0.5 : /^an?$/i.test(m[1]) ? 1 : Number(m[1]);
minutes = Math.round(n * (/^h/i.test(m[2]) ? 60 : 1));
if (!(minutes > 0 && minutes <= 14 * 24 * 60)) return false;
diff --git a/src/screens/reminderQuick.ts b/src/screens/reminderQuick.ts
index eac63fd..6ed5bf0 100644
--- a/src/screens/reminderQuick.ts
+++ b/src/screens/reminderQuick.ts
@@ -30,7 +30,8 @@ export function parseReminder(text: string, now: Date = new Date(), dayFirst?: b
priority = PRIORITY[(bang[1] ?? bang[2]).length];
line = (line.slice(0, bang.index) + " " + line.slice(bang.index + bang[0].length)).trim();
}
- const q = parseQuick(line, now, dayFirst);
+ // How long is not a reminder's to know ("Read for 20 minutes daily"): those words stay.
+ const q = parseQuick(line, now, dayFirst, false);
// Where Quick Event took out a place, it goes back: a reminder keeps "at the office" as
// words, as the phone does when typed.
let title = q.location ? `${q.title} at ${q.location}`.trim() : q.title;