Public: anyone can read this; the crew can change it.

A date from another year says its year, so the Closed list never shows last November's sale as "closed Sun, Nov 9" the day before Nov 9 #201

Closed opened this
Closed without merging

mason/deal-clock:mason/197-a-date-from-another-year-says-its-year-s → main 4 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
7 files changed +40 −6
src/dates.test.ts +13
@@ -12,6 +12,8 @@ import {
1212 isHoliday,
1313 nextBusinessDay,
1414 relative,
15 spoken,
16 today,
1517 urgency,
1618 } from "./dates.ts";
1719 import { DEFAULT_LENGTHS, schedule } from "./deadlines.ts";
@@ -143,3 +145,14 @@ test("business days step over a holiday; calendar days do not", () => {
143145 expect(addBusinessDays("2026-11-27", -1)).toBe("2026-11-25");
144146 expect(addDays("2026-11-25", 1)).toBe("2026-11-26");
145147 });
148
149 test("same year omits the year, another year says it", () => {
150 expect(spoken("2026-11-09", "2026-11-08")).toBe("Mon, Nov 9");
151 expect(spoken("2025-11-09", "2026-11-08")).toBe("Sun, Nov 9, 2025");
152 expect(spoken("2025-11-09")).toBe("Sun, Nov 9");
153 });
154 test("Dec 31 to Jan 1 follows the agent's zone", () => {
155 const now = new Date("2027-01-01T03:00:00Z"); // Dec 31 in New York, Jan 1 in UTC
156 expect(spoken("2026-12-31", today("America/New_York", now))).toBe("Thu, Dec 31");
157 expect(spoken("2026-12-31", today("UTC", now))).toBe("Thu, Dec 31, 2026");
158 });
src/dates.ts +15 −2
@@ -186,8 +186,21 @@ const SHORT = new Intl.DateTimeFormat("en-US", {
186186 timeZone: "UTC",
187187 });
188188
189 /** "Fri, Oct 16" — how a person reads a date in a sentence. */
190 export const spoken = (date: string): string => SPOKEN.format(toMs(date));
189 const SPOKEN_YEAR = new Intl.DateTimeFormat("en-US", {
190 weekday: "short",
191 month: "short",
192 day: "numeric",
193 year: "numeric",
194 timeZone: "UTC",
195 });
196
197 /**
198 * "Fri, Oct 16" — how a person reads a date in a sentence. Given the agent's
199 * `on` (today, in their zone), a date from another calendar year also says its
200 * year: "Sun, Nov 9, 2025". Without `on` the year is never spoken.
201 */
202 export const spoken = (date: string, on?: string): string =>
203 on !== undefined && date.slice(0, 4) !== on.slice(0, 4) ? SPOKEN_YEAR.format(toMs(date)) : SPOKEN.format(toMs(date));
191204
192205 const WEEKDAY = new Intl.DateTimeFormat("en-US", { weekday: "long", timeZone: "UTC" });
193206
src/pages/clock.ts +1 −1
@@ -215,7 +215,7 @@ function render(input: {
215215 : `<section id="closed" class="card" data-live="deal.changed">
216216 <h2>Closed <span class="muted">· ${closed.length + fell.length}</span></h2>
217217 ${who.role === "anon" ? "" : `<p class="small"><a href="/deals/csv?closed=1" download>Download spreadsheet with closed deals</a></p>`}
218 <ul class="closed">${closed.map((deal) => `<li><a href="/deals/${deal.id}">${escape(deal.address)}</a> <span class="muted">closed ${escape(spoken(deal.closing))}${deal.sale_price === null ? "" : ` · ${dollars(deal.sale_price)}`}</span> ${sideLabel(deal.side)}</li>`).join("")}${fell.map((deal) => `<li><a href="/deals/${deal.id}">${escape(deal.address)}</a> <b>Fell through</b> <span class="muted">${escape(spoken(fellOn(deal)))} · ${escape(deal.fell_reason ?? "")}</span> ${sideLabel(deal.side)}</li>`).join("")}</ul>
218 <ul class="closed">${closed.map((deal) => `<li><a href="/deals/${deal.id}">${escape(deal.address)}</a> <span class="muted">closed ${escape(spoken(deal.closing, on))}${deal.sale_price === null ? "" : ` · ${dollars(deal.sale_price)}`}</span> ${sideLabel(deal.side)}</li>`).join("")}${fell.map((deal) => `<li><a href="/deals/${deal.id}">${escape(deal.address)}</a> <b>Fell through</b> <span class="muted">${escape(spoken(fellOn(deal)))} · ${escape(deal.fell_reason ?? "")}</span> ${sideLabel(deal.side)}</li>`).join("")}</ul>
219219 </section>`;
220220 const restoreCard =
221221 !mayRestore(who).ok
src/pages/progress.ts +1 −1
@@ -7,7 +7,7 @@ import { progress } from "../progress.ts";
77
88 /** "4 of 7 dates done · 1 overdue · closes …", or "All done · closed …" once the deal has closed. */
99 export function progressText(deal: DealView, on: string): string {
10 if (deal.closed) return `All done · closed ${spoken(closedOn(deal))}`;
10 if (deal.closed) return `All done · closed ${spoken(closedOn(deal), on)}`;
1111 const p = progress(deal, on);
1212 const overdue = p.overdue > 0 ? ` · ${p.overdue} overdue` : "";
1313 return `${p.done} of ${p.total} dates done${overdue} · closes ${spoken(deal.closing)}, ${relative(deal.closing, on)}`;
src/progress.test.ts +7
@@ -78,3 +78,10 @@ test("overdue shows only when there is some; a closed deal reads All done", () =
7878 expect(progress(closed, on)).toMatchObject({ done: closed.deadlines.length, overdue: 0 });
7979 });
8080
81
82 test("a closed deal from another year says its year in the progress line", () => {
83 const id = open();
84 const deal = { ...read(id), closed: true, closing: "2025-11-09" } as DealView;
85 expect(progressText(deal, "2026-11-08")).toBe("All done · closed Sun, Nov 9, 2025");
86 expect(progressText(deal, "2025-11-08")).toBe("All done · closed Sun, Nov 9");
87 });
src/terminal.ts +1 −1
@@ -790,7 +790,7 @@ export function terminal(
790790 lines.push(
791791 "",
792792 bold(`Closed (${closed.length})`),
793 ...closed.map((d) => dim(` ${d.address} — closed ${spoken(closedOn(d))}`)),
793 ...closed.map((d) => dim(` ${d.address} — closed ${spoken(closedOn(d), day)}`)),
794794 dim(showDone ? " Their dates are listed above; u on the Closing date reopens the deal." : " h shows their dates; u on the Closing date reopens the deal."),
795795 );
796796 const fell = all.filter((d) => d.fell_through);
src/week.page.test.ts +2 −1
@@ -36,7 +36,8 @@ test("lists overdue and coming dates with deal, owner and state, and no controls
3636 const card = clock.slice(clock.indexOf('id="week"'));
3737 expect(card).toContain('href="/week"');
3838 const labels = (h: string) => [...h.matchAll(/<b>([^<]+)<\/b>/g)].map((m) => m[1]);
39 for (const l of labels(html.slice(html.indexOf("timeline-list"))).filter((l) => !days.includes(l))) expect(clock).toContain(l!);
39 // The sheet adds an inspection's or walkthrough's time and place to the label; the clock card does not, so compare the label itself.
40 for (const l of labels(html.slice(html.indexOf("timeline-list"))).filter((l) => !days.includes(l))) expect(clock).toContain(l!.split(" · ")[0]!);
4041 });
4142
4243 test("omits done dates and closed deals: one row per open date in the window", async () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs