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: AllDay read and written — a date says whether it is a day or a time, a time carries its zone, an all-day date rings no alarm

Yashwanth Kamireddid1b05cc12ed3
diff --git a/crates/quince-core/src/reminders.rs b/crates/quince-core/src/reminders.rs
index dd12623..d797c5f 100644
--- a/crates/quince-core/src/reminders.rs
+++ b/crates/quince-core/src/reminders.rs
@@ -176,6 +176,10 @@ pub struct Reminder {
/// file, never from the reminder — Apple does not record it on the reminder at all.
#[serde(default)]
pub section_guid: Option<String>,
+ /// Due on a day, not at a time — Apple's `AllDay`. Its `DueDate` is that day's midnight,
+ /// and it rings no alarm.
+ #[serde(default)]
+ pub all_day: bool,
}
/// What every entry in the sidebar is holding.
@@ -454,7 +458,7 @@ impl Library {
let mut stmt = self.conn.prepare(
"SELECT r.guid, r.list_guid, r.title, r.notes, r.due_at, r.completed_at,
r.priority, r.flagged, r.parent_guid, r.recur_frequency, r.recur_interval,
- r.etag, r.timezone, r.section_guid
+ r.etag, r.timezone, r.section_guid, r.all_day
FROM reminders r
JOIN reminder_lists l ON l.guid = r.list_guid
WHERE l.enabled = 1 AND r.due_at IS NOT NULL
@@ -479,6 +483,7 @@ impl Library {
raw: None,
timezone: row.get(12)?,
section_guid: row.get(13)?,
+ all_day: row.get::<_, i64>(14)? != 0,
})
})?;
Ok(rows.collect::<rusqlite::Result<Vec<_>>>()?)
@@ -554,7 +559,7 @@ impl Library {
let sql = format!(
"SELECT r.guid, r.list_guid, r.title, r.notes, r.due_at, r.completed_at,
r.priority, r.flagged, r.parent_guid, r.recur_frequency, r.recur_interval,
- r.etag, r.timezone, r.section_guid
+ r.etag, r.timezone, r.section_guid, r.all_day
FROM reminders r
JOIN reminder_lists l ON l.guid = r.list_guid
WHERE l.enabled = 1 AND {clause}
@@ -579,6 +584,7 @@ impl Library {
raw: None,
timezone: row.get(12)?,
section_guid: row.get(13)?,
+ all_day: row.get::<_, i64>(14)? != 0,
})
})?;
Ok(rows.collect::<rusqlite::Result<Vec<_>>>()?)
@@ -685,8 +691,8 @@ impl Library {
let mut stmt = tx.prepare(
"INSERT INTO reminders (guid, list_guid, title, notes, due_at, completed_at,
priority, flagged, parent_guid, recur_frequency,
- recur_interval, etag, raw, timezone, updated_at)
- VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15)
+ recur_interval, etag, raw, timezone, updated_at, all_day)
+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16)
ON CONFLICT(guid) DO UPDATE SET
list_guid = excluded.list_guid, title = excluded.title,
notes = excluded.notes, due_at = excluded.due_at,
@@ -696,6 +702,7 @@ impl Library {
recur_interval = excluded.recur_interval,
etag = excluded.etag, raw = excluded.raw,
timezone = excluded.timezone,
+ all_day = excluded.all_day,
updated_at = excluded.updated_at",
)?;
let stamp = now();
@@ -715,7 +722,8 @@ impl Library {
r.etag,
r.raw,
r.timezone,
- stamp
+ stamp,
+ i64::from(r.all_day)
])?;
}
}
@@ -798,7 +806,7 @@ impl Library {
let mut stmt = self.conn.prepare(
"SELECT r.guid, r.list_guid, r.title, r.notes, r.due_at, r.completed_at, r.priority,
r.flagged, r.parent_guid, r.recur_frequency, r.recur_interval, r.etag,
- r.timezone, r.section_guid
+ r.timezone, r.section_guid, r.all_day
FROM reminders r
JOIN reminder_lists l ON l.guid = r.list_guid
WHERE l.enabled = 1 AND r.completed_at IS NULL
@@ -821,6 +829,7 @@ impl Library {
raw: None,
timezone: row.get(12)?,
section_guid: row.get(13)?,
+ all_day: row.get::<_, i64>(14)? != 0,
})
})?;
let mut found = Vec::new();
@@ -844,7 +853,7 @@ impl Library {
.find(|l| l.guid == list_guid);
let mut stmt = self.conn.prepare(
"SELECT guid, list_guid, title, notes, due_at, completed_at, priority, flagged,
- parent_guid, recur_frequency, recur_interval, etag, timezone, section_guid,
+ parent_guid, recur_frequency, recur_interval, etag, timezone, section_guid, all_day,
CASE WHEN json_valid(raw)
THEN json_extract(raw, '$.fields.CreationDate.value') END
FROM reminders
@@ -868,8 +877,9 @@ impl Library {
raw: None,
timezone: row.get(12)?,
section_guid: row.get(13)?,
+ all_day: row.get::<_, i64>(14)? != 0,
},
- row.get::<_, Option<i64>>(14).unwrap_or(None),
+ row.get::<_, Option<i64>>(15).unwrap_or(None),
))
})?;
let mut found = rows.collect::<rusqlite::Result<Vec<_>>>()?;
@@ -915,6 +925,7 @@ mod tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}
}
@@ -1105,6 +1116,7 @@ mod smart_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}
}
@@ -1249,6 +1261,7 @@ mod count_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}
}
@@ -1347,6 +1360,7 @@ mod payload_tests {
raw: Some(apples_record),
timezone: None,
section_guid: None,
+ all_day: false,
};
let sent = serde_json::to_string(&reminder).unwrap();
@@ -1383,6 +1397,7 @@ mod payload_tests {
raw: Some("y".repeat(5_000)),
timezone: None,
section_guid: None,
+ all_day: false,
})
.collect();
let bytes = serde_json::to_vec(&many).unwrap().len();
@@ -1414,6 +1429,7 @@ mod raw_column_tests {
raw: Some("z".repeat(5_000)),
timezone: None,
section_guid: None,
+ all_day: false,
}
}
@@ -1497,6 +1513,7 @@ mod bound_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
})
.collect();
lib.put_reminders(&rows).unwrap();
@@ -1586,6 +1603,7 @@ mod recurrence_daylight_tests {
raw: None,
timezone: Some(zone.into()),
section_guid: None,
+ all_day: false,
}
}
@@ -1666,6 +1684,7 @@ mod section_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}
}
@@ -1798,6 +1817,7 @@ mod search_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}
}
@@ -1875,6 +1895,7 @@ mod list_sorting_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}
}
diff --git a/crates/quince-core/src/schema.rs b/crates/quince-core/src/schema.rs
index d93741e..f1f4d1d 100644
--- a/crates/quince-core/src/schema.rs
+++ b/crates/quince-core/src/schema.rs
@@ -365,4 +365,10 @@ pub const MIGRATIONS: &[&str] = &[
) STRICT;
UPDATE sync_state SET token = NULL WHERE service = 'reminders';
"#,
+ // All-day reminders: Apple's `AllDay`, so a reminder due on a day shows as that day and
+ // not as midnight. The position is forgotten so the next pass reads it on every reminder.
+ r#"
+ ALTER TABLE reminders ADD COLUMN all_day INTEGER NOT NULL DEFAULT 0;
+ UPDATE sync_state SET token = NULL WHERE service = 'reminders';
+ "#,
];
diff --git a/crates/quince-icloud/src/reminders.rs b/crates/quince-icloud/src/reminders.rs
index 70bdaff..63e117c 100644
--- a/crates/quince-icloud/src/reminders.rs
+++ b/crates/quince-icloud/src/reminders.rs
@@ -60,6 +60,7 @@ fn reminder_from(v: &Value) -> Option<Reminder> {
raw: serde_json::to_string(v).ok(),
timezone: None,
section_guid: None,
+ all_day: v.get("isAllDay").and_then(Value::as_bool).unwrap_or(false),
})
}
@@ -453,6 +454,8 @@ fn reminder_from_record(record: &Value) -> Option<Reminder> {
// moves an hour on each of the two days a year a clock changes.
timezone: field::string(record, "TimeZone"),
section_guid: None,
+ // `NUMBER_INT64` 0 or 1 on every dated reminder on a real account.
+ all_day: field::flag(record, "AllDay"),
})
}
@@ -1363,6 +1366,10 @@ pub struct ReminderEdit {
pub notes: Option<Option<String>>,
/// Unix seconds. `Some(None)` clears the due date.
pub due_at: Option<Option<i64>>,
+ /// With a due date: whether it is a day rather than a time. A day is sent as that day's
+ /// midnight in UTC, as Apple's clients read an all-day date back.
+ #[serde(default)]
+ pub all_day: Option<bool>,
pub flagged: Option<bool>,
pub completed: Option<bool>,
/// Apple's scale, shared with EventKit: 0 none, 1 high, 5 medium, 9 low.
@@ -1455,6 +1462,21 @@ pub async fn edit_cloudkit(
}
if let Some(due) = &edit.due_at {
+ // Day or time, said every time a date is set: a time given to a reminder the phone
+ // made all-day kept `AllDay` 1 and still showed as a day. A timed date carries the
+ // zone it was set in, as every dated reminder on a real account does.
+ let all_day = edit.all_day.unwrap_or(false) && due.is_some();
+ fields.insert(
+ "AllDay".into(),
+ serde_json::json!({ "type": "NUMBER_INT64", "value": i64::from(all_day) }),
+ );
+ if due.is_some() && !all_day {
+ let zone = jiff::tz::TimeZone::system();
+ fields.insert(
+ "TimeZone".into(),
+ serde_json::json!({ "type": "STRING", "value": zone.iana_name().unwrap_or("UTC") }),
+ );
+ }
fields.insert(
"DueDate".into(),
match due {
@@ -2103,6 +2125,7 @@ mod write_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
};
delete_cloudkit(&reqwest::Client::new(), &server.uri(), vec![], &reminder)
.await
@@ -2195,6 +2218,7 @@ mod edit_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}
}
@@ -2322,6 +2346,48 @@ mod edit_tests {
assert_eq!(body["operations"][0]["record"]["recordChangeTag"], "fresh");
}
+ /// A day is a day: `AllDay` 1 and no zone. A time says it is a time and carries its zone —
+ /// otherwise a time given to a reminder the phone made all-day still showed as a day.
+ #[tokio::test]
+ async fn a_date_says_whether_it_is_a_day_or_a_time() {
+ let day = accepting().await;
+ edit_cloudkit(
+ &reqwest::Client::new(),
+ &day.uri(),
+ vec![],
+ &reminder(),
+ &ReminderEdit {
+ due_at: Some(Some(1_757_030_400)),
+ all_day: Some(true),
+ ..Default::default()
+ },
+ )
+ .await
+ .unwrap();
+ let fields = sent(&day).await;
+ assert_eq!(fields["AllDay"]["value"], 1);
+ assert!(fields.get("TimeZone").is_none());
+
+ let time = accepting().await;
+ edit_cloudkit(
+ &reqwest::Client::new(),
+ &time.uri(),
+ vec![],
+ &reminder(),
+ &ReminderEdit {
+ due_at: Some(Some(1_757_000_000)),
+ ..Default::default()
+ },
+ )
+ .await
+ .unwrap();
+ let fields = sent(&time).await;
+ assert_eq!(fields["AllDay"]["value"], 0);
+ assert!(fields["TimeZone"]["value"]
+ .as_str()
+ .is_some_and(|z| !z.is_empty()));
+ }
+
/// Seconds in, milliseconds out — a due date landing on the wrong day is worse than none.
#[tokio::test]
async fn a_due_date_is_written_in_milliseconds_and_can_be_cleared() {
@@ -2684,6 +2750,7 @@ mod recurring_tick_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}
}
@@ -2883,6 +2950,7 @@ mod priority_and_move_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}
}
@@ -3064,6 +3132,7 @@ mod tombstone_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}])
.unwrap();
library
@@ -3200,6 +3269,7 @@ mod recurrence_write_tests {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
}
}
diff --git a/probe/examples/at_scale.rs b/probe/examples/at_scale.rs
index 851222f..bc6c82d 100644
--- a/probe/examples/at_scale.rs
+++ b/probe/examples/at_scale.rs
@@ -55,6 +55,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
raw: Some("z".repeat(5_000)),
timezone: None,
section_guid: None,
+ all_day: false,
})
.collect();
let t = Instant::now();
diff --git a/probe/examples/reminder_allday_raw.rs b/probe/examples/reminder_allday_raw.rs
new file mode 100644
index 0000000..bfdcd05
--- /dev/null
+++ b/probe/examples/reminder_allday_raw.rs
@@ -0,0 +1,51 @@
+//! Live, read-only: how reminders with a date store it — AllDay, DueDate, TimeZone.
+use anyhow::{anyhow, Result};
+#[tokio::main]
+async fn main() -> Result<()> {
+ let dir = std::path::PathBuf::from(std::env::var("HOME")?).join(".local/share/quince-probe");
+ let mut client = quince_auth::Client::new(&dir)?;
+ if !client.resume().await? {
+ return Err(anyhow!("no session"));
+ }
+ let root = client
+ .session()
+ .service_url("ckdatabasews")
+ .ok_or_else(|| anyhow!("no ckdatabasews"))?;
+ let zc = quince_icloud::cloudkit::ZoneClient::new(
+ client.http(),
+ &root,
+ "com.apple.reminders",
+ client.service_params(),
+ );
+ let walk = zc.all_records("Reminders", None).await?;
+ let mut seen = (0, 0);
+ for r in walk
+ .records
+ .iter()
+ .filter(|r| r["recordType"] == "Reminder" && r["fields"].get("DueDate").is_some())
+ {
+ let f = &r["fields"];
+ let all = f["AllDay"]["value"].as_i64().unwrap_or(-1);
+ if (all == 1 && seen.0 < 3) || (all != 1 && seen.1 < 2) {
+ if all == 1 {
+ seen.0 += 1
+ } else {
+ seen.1 += 1
+ }
+ println!(
+ "AllDay={} ({}) DueDate={} StartDate={} TimeZone={} keys={:?}",
+ f["AllDay"]["value"],
+ f["AllDay"]["type"],
+ f["DueDate"]["value"],
+ f["StartDate"]["value"],
+ f["TimeZone"],
+ f.as_object()
+ .unwrap()
+ .keys()
+ .filter(|k| k.contains("Date") || k.contains("Time") || k.contains("All"))
+ .collect::<Vec<_>>()
+ );
+ }
+ }
+ Ok(())
+}
diff --git a/probe/src/main.rs b/probe/src/main.rs
index 8e2c2ee..e57ce9f 100644
--- a/probe/src/main.rs
+++ b/probe/src/main.rs
@@ -1370,6 +1370,7 @@ async fn main() -> Result<()> {
raw: None,
timezone: None,
section_guid: None,
+ all_day: false,
};
// Subtasks: nest one reminder under another, read it back, free it.
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 027b9c7..88aab85 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -796,7 +796,8 @@ async fn reminder_edit(
// The edit is already on Apple by now. If the alert fails, the library is still re-read
// before saying so: returning early left the old date on screen though Apple had the new
// one, and the next edit was made against a reminder that was not there any more.
- let alarm = match edit.due_at {
+ // An all-day reminder rings no alarm, as on the phone.
+ let alarm = match edit.due_at.filter(|_| !edit.all_day.unwrap_or(false)) {
Some(due) => {
let zone = jiff::tz::TimeZone::system();
quince_icloud::reminders::set_alarm_cloudkit(