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

A pure module names a post's day: Today, Yesterday, or `Mon 20 Oct`, in UTC #6081

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This adds the pure day-label module for #6064. Its 11 tests pass. I didn't get a type check: `bun x tsc --noEmit` failed because the `bun` type definitions weren't installed in the sandbox. Nothing renders these labels yet, so no one can reach them from the feed or the MCP. That wiring is a separate issue.

shipped production is serving it deploy bbd5a0b

opened this

This adds the pure day-label module for #6064. Its 11 tests pass. I didn't get a type check: bun x tsc --noEmit failed because the bun type definitions weren't installed in the sandbox. Nothing renders these labels yet, so no one can reach them from the feed or the MCP. That wiring is a separate issue.

  • dayLabel(iso, now) returns Today, Yesterday, or Tue 20 Oct, all in UTC. A year is added only when it differs from now's, as in Mon 20 Oct 2025. An unparsable time returns "".
  • dividers(items, now, lastDayOnPage?) returns the labels in order, one for each item whose UTC day differs from the previous item's. The day of lastDayOnPage, an ISO time, gets no label again.
  • Unparsable items: an item with an unparsable time gets no label and doesn't split the day around it.
  • Items: an item is an ISO string or an object { at }. The issue didn't fix the shape, so I allowed both.
  • Return type: dividers returns plain strings, as the issue words it, not index and label pairs. A caller that renders them needs its own way to match each label to its item.
  • Tests: test/day-divider.test.ts covers three days in order, midnight UTC on either side, unparsable times and lastDayOnPage suppressing a repeat. It also covers the year suffix, UTC offset input and an empty list.
  • Files: only src/web/studio/day_divider.ts and the test. The module has no dependencies and doesn't touch the db or HTML.

To try it, run bun test test/day-divider.test.ts.

Closes #6064

commented

This adds the pure day-label module for #6064. Its 11 tests pass. I didn't get a type check: bun x tsc --noEmit failed because the bun type definitions weren't installed in the sandbox. Nothing renders these labels yet, so no one can reach them from the feed or the MCP. That wiring is a separate issue.

  • dayLabel(iso, now) returns Today, Yesterday, or Tue 20 Oct, all in UTC. A year is added only when it differs from now's, as in Mon 20 Oct 2025. An unparsable time returns "".
  • dividers(items, now, lastDayOnPage?) returns the labels in order, one for each item whose UTC day differs from the previous item's. The day of lastDayOnPage, an ISO time, gets no label again.
  • Unparsable items: an item with an unparsable time gets no label and doesn't split the day around it.
  • Items: an item is an ISO string or an object { at }. The issue didn't fix the shape, so I allowed both.
  • Return type: dividers returns plain strings, as the issue words it, not index and label pairs. A caller that renders them needs its own way to match each label to its item.
  • Tests: test/day-divider.test.ts covers three days in order, midnight UTC on either side, unparsable times and lastDayOnPage suppressing a repeat. It also covers the year suffix, UTC offset input and an empty list.
  • Files: only src/web/studio/day_divider.ts and the test. The module has no dependencies and doesn't touch the db or HTML.

To try it, run bun test test/day-divider.test.ts.

Approved

Matches #6064 exactly: dayLabel and dividers, UTC, year only when it differs, unparsable times skipped without splitting a day, lastDayOnPage suppression. The weekdays in the tests check out (20 Oct 2026 is Tue, 2025 is Mon). It is pure, has no dependency, no db or HTML, and touches only the two named files. Reachability is deliberately deferred to the wiring issue under #5821, so this is a step, not done-for-a-person yet. Nothing here changes what a visitor sees, so there is no design or keyboard impact. Two things next: (1) the render issue should key each label to its item, since dividers returns bare strings, so consider returning the index of the item each label precedes; (2) when it is wired, render the label as a semantic heading or a <time> element with the ISO date so screen readers and no-JS readers get the day, and add a tty.ts door.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs