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.

Contacts: a birthday shows on the card and can be set

Yashwanth Kamireddid46a5e6517b1
diff --git a/.uiverify/contact-birthday.mjs b/.uiverify/contact-birthday.mjs
new file mode 100644
index 0000000..6cb1610
--- /dev/null
+++ b/.uiverify/contact-birthday.mjs
@@ -0,0 +1,46 @@
+// A contact's birthday, as Contacts shows and edits it — the source the Birthdays calendar
+// draws from, which could be neither seen nor set here.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub } from "./stub.mjs";
+
+const b = await engine.launch();
+const ctx = await b.newContext({ viewport: { width: 1280, height: 820 } });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null,
+ calendarFixture: false, notesFixture: false, contactsFixture: true, driveFixture: false, remindersFixture: false });
+await ctx.addInitScript(() => {
+ const internals = window.__TAURI_INTERNALS__;
+ const invoke = internals.invoke;
+ internals.invoke = async (cmd, args) => {
+ const answer = await invoke(cmd, args);
+ if (cmd === "contacts_list" && Array.isArray(answer)) return answer.map((c) => (c.guid === "c1" ? { ...c, birthday: "1604-03-17" } : c));
+ return answer;
+ };
+});
+const page = await ctx.newPage();
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await page.locator(".nav-item", { hasText: "Contacts" }).click();
+await page.waitForTimeout(400);
+await page.locator(".contact-row", { hasText: "Zoya" }).click();
+await page.waitForTimeout(300);
+
+let failures = 0;
+const ok = (pass, yes, no) => { console.log(pass ? `PASS ${yes}` : `FAIL ${no}`); if (!pass) failures++; };
+
+const card = await page.locator(".contact-detail").innerText();
+ok(/birthday\s*(17 March|March 17)/i.test(card) && !card.includes("1604"),
+ "the card shows the birthday, without Apple's no-year 1604", `the card: ${card.replace(/\s+/g, " ").slice(0, 160)}`);
+
+await page.getByRole("button", { name: "Edit", exact: true }).click();
+await page.waitForTimeout(200);
+const noYear = page.getByLabel("Year unknown");
+ok(await noYear.isChecked(), "editing keeps it as a birthday with no year", "the year-unknown box is not ticked");
+await noYear.uncheck();
+await page.getByLabel("Birthday").fill("1998-03-17");
+await page.getByRole("button", { name: "Save" }).click();
+await page.waitForTimeout(300);
+const sent = await page.evaluate(() => (window.__contactSaves ?? []).at(-1));
+const birthday = JSON.stringify(sent ?? {}).match(/"birthday":"([^"]*)"/)?.[1];
+ok(birthday === "1998-03-17", "and a birthday set here goes to iCloud as Apple writes it", `sent: ${birthday}`);
+
+await b.close();
+process.exitCode = failures === 0 ? 0 : 1;
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index b543d63..8f02f5a 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -171,7 +171,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
for (const n of noteList) per.set(n.folderGuid, (per.get(n.folderGuid) ?? 0) + 1);
return [noteList.length, [...per.entries()]];
}
- case "contact_save": return "C-new";
+ case "contact_save": (window.__contactSaves ??= []).push(args); return "C-new";
case "contact_delete": return null;
case "contacts_list": return !contactsFixture ? [] : contactList;
case "drive_children": return !driveFixture ? [] : driveItems;
diff --git a/check.sh b/check.sh
index c42e82f..8bc1df5 100755
--- a/check.sh
+++ b/check.sh
@@ -46,6 +46,7 @@ step "a screen failing" node .uiverify/boundary.mjs
step "coming back" node .uiverify/resume.mjs
step "birthdays, holidays" node .uiverify/occasions.mjs
step "drive folders" node .uiverify/drive-nav.mjs
+step "birthdays in contacts" node .uiverify/contact-birthday.mjs
# The same screens in WebKit, the engine Quince draws in. Chromium above catches most things;
# this catches what only WebKit does — pointer capture, blur on removal, its own layout.
diff --git a/src/screens/ContactsView.tsx b/src/screens/ContactsView.tsx
index 2b8f4fb..5869844 100644
--- a/src/screens/ContactsView.tsx
+++ b/src/screens/ContactsView.tsx
@@ -334,6 +334,40 @@ export function ContactsView() {
Add phone, email or link
</button>
+ <div className="contact-birthday-field">
+ <label>
+ <span>Birthday</span>
+ <input
+ type="date"
+ aria-label="Birthday"
+ value={draft.birthday ? (draft.birthday.startsWith(NO_YEAR) ? `2000${draft.birthday.slice(4, 10)}` : draft.birthday.slice(0, 10)) : ""}
+ onChange={(e) => {
+ const v = e.target.value;
+ if (!v) return setDraft({ ...draft, birthday: null });
+ const unknown = draft.birthday?.startsWith(NO_YEAR) ?? false;
+ setDraft({ ...draft, birthday: unknown ? `${NO_YEAR}${v.slice(4)}` : v });
+ }}
+ />
+ </label>
+ {draft.birthday && (
+ <label className="contact-birthday-noyear">
+ <input
+ type="checkbox"
+ checked={draft.birthday.startsWith(NO_YEAR)}
+ onChange={(e) =>
+ setDraft({
+ ...draft,
+ birthday: e.target.checked
+ ? `${NO_YEAR}${draft.birthday!.slice(4, 10)}`
+ : `${new Date().getFullYear()}${draft.birthday!.slice(4, 10)}`,
+ })
+ }
+ />
+ Year unknown
+ </label>
+ )}
+ </div>
+
<label className="contact-notes-field">
<span>Notes</span>
<textarea
@@ -391,9 +425,15 @@ export function ContactsView() {
</dd>
</div>
))}
+ {open.birthday && (
+ <div>
+ <dt>birthday</dt>
+ <dd>{birthdayText(open.birthday)}</dd>
+ </div>
+ )}
</dl>
- {open.methods.length === 0 && (
+ {open.methods.length === 0 && !open.birthday && (
<p className="cal-empty">No phone numbers or addresses saved.</p>
)}
{open.notes && <p className="contact-notes">{open.notes}</p>}
@@ -423,3 +463,14 @@ export function ContactsView() {
</div>
);
}
+
+/** The year Apple writes for a birthday given without one. */
+const NO_YEAR = "1604";
+
+/** "17 March", or "17 March 1998" when the year is known — as a contact card shows it. */
+function birthdayText(raw: string): string {
+ const [y, m, d] = raw.slice(0, 10).split("-").map(Number);
+ if (!m || !d) return raw;
+ const date = new Date(y === Number(NO_YEAR) ? 2000 : y, m - 1, d);
+ return date.toLocaleDateString(undefined, y === Number(NO_YEAR) ? { day: "numeric", month: "long" } : { dateStyle: "long" });
+}
diff --git a/src/styles/app.css b/src/styles/app.css
index cdad919..24e608c 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -1638,3 +1638,8 @@
/* A screen that failed to draw, in place of the screen — the rest of the app carries on. */
.screen-failed { max-width: 46ch; margin: 64px auto 0; text-align: center; color: var(--text-2); }
.screen-failed p { margin: 0 0 12px; font-size: var(--t-13); }
+
+.contact-birthday-field { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0; }
+.contact-birthday-field label:first-child { display: flex; flex-direction: column; gap: 4px; font-size: var(--t-11); color: var(--text-2); }
+.contact-birthday-field input[type="date"] { padding: 4px 8px; border: 1px solid var(--field-edge); border-radius: 6px; background: var(--field); color: var(--text); font: inherit; font-size: var(--t-13); color-scheme: light dark; }
+.contact-birthday-noyear { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; font-size: var(--t-13); color: var(--text-2); }