Skip to content

feat: add an opt-in compact absolute-time preset - #405

Merged
tay1orjones merged 8 commits into
mainfrom
copilot/add-opt-in-compact-absolute-time-preset
Nov 20, 2026
Merged

tay1orjones merged 8 commits into
mainfrom
copilot/add-opt-in-compact-absolute-time-preset

Conversation

@tay1orjones

@tay1orjones tay1orjones commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

<relative-time> can now show compact absolute timestamps in width-constrained layouts. The preset changes presentation, not how the element selects absolute, relative, or duration output.

  • API and precedence: Set absolute-format="compact" or element.absoluteFormat = 'compact'. The preset applies after the user preference, threshold, or format="datetime" selects absolute output. Omitted, empty, unknown, and removed values keep the existing presentation. Setting the property to undefined removes the attribute.
  • Rendering: Today in the effective display time zone uses a localized 12-hour time, such as today at 3:04 PM. Japanese and Chinese locale families, and patterns without a safe connector, join localized today and time with a space. Other days show a localized date with the year and no time, such as Nov 2, 2026. Compact text ignores prefix, format-style, display fields, and hour-cycle. Full titles keep their usual format (including hour-cycle), and datetime, custom titles, and no-title are unchanged.
  • Rollover: The shared observer updates compact labels at calendar boundaries, including for recent timestamps, future dates across New Year, and daylight-saving transitions. With format="datetime" or the user preference, compact text only changes at midnight, so it skips the 1 s and 60 s ticks. Compact text from a threshold keeps them so it can turn relative on time.
<relative-time datetime="2026-11-02T15:04:00Z" format="datetime" absolute-format="compact" lang="en-US">
  Nov 2, 2026
</relative-time>

Verification: Lint, build, the Chromium tests, and a local install of the packed JavaScript, TypeScript declarations, and custom-element manifest passed.

Downstream handoff

PR #405 · Tested commit 28a3589896dad16d429119cf94712b18b60c498d

In the element checkout:

git fetch origin copilot/add-opt-in-compact-absolute-time-preset
git switch --detach 28a3589896dad16d429119cf94712b18b60c498d
npm ci
npm run build
npm pack --pack-destination /tmp

In the wrapper checkout:

npm install --no-save --package-lock=false /tmp/github-relative-time-element-0.0.0-development.tgz

The package contains JavaScript at dist/index.js and dist/bundle.js, declarations at dist/index.d.ts and dist/relative-time-element.d.ts, and metadata at custom-elements.json. No known blockers; no release or hosted tarball is needed.

In some locales (hi, ta, kn, mr, bn, ur), the date postposition attaches to "today", for example hi आज को 3:04 pm बजे. That's within the best-effort note in #404, so wrapper PRs shouldn't treat it as a bug.

Copilot AI linked an issue Nov 19, 2026 that may be closed by this pull request
15 tasks
tay1orjones and others added 2 commits November 19, 2026 19:10
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@tay1orjones tay1orjones changed the title [WIP] Add opt-in compact absolute-time preset feat: add an opt-in compact absolute-time preset Nov 19, 2026
@tay1orjones
tay1orjones requested a max review from Copilot November 19, 2026 19:46

This comment was marked as outdated.

@tay1orjones

Copy link
Copy Markdown
Contributor Author

@copilot address the outstanding review feedback

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@copilot address the outstanding review feedback

Addressed in 84ab6dc: past compact labels now schedule at calendar boundaries, including Casey rollbacks, and skip fine-grained updates. The full test suite passes (695 tests).

This comment was marked as outdated.

@tay1orjones

Copy link
Copy Markdown
Contributor Author

@copilot address the outstanding review feedback

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@copilot address the outstanding review feedback

Applied in adfbb14: initial compact timers are capped at one hour, and the long-delay test advances through hourly updates. npm test passes (695 tests).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human judgment is needed to assess the significance of unnecessary timer ticks that update every element in the shared observer while datetime text remains unchanged.

No open issues 🎉

1 resolved since last review

Review effort: Max

tay1orjones and others added 3 commits November 20, 2026 09:27
The hourly rollover case used `assert.isAtMost`, so a 1 s delay passed.
Removing the recent-past `msUntilNextDay` branch in `getUnitFactor` did
not fail any test.

Assert the first delay from `observe()`, which comes only from the new
element. Later delays also include other elements in the shared
observer, so the loop keeps `isAtMost`.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A future compact timestamp ticked every 60 s in its last hour and every
1 s in its last minute. With explicit `format="datetime"` or the
absolute-time preference, the compact text only changes at midnight, so
those ticks did no work.

The observer now records why compact text is observed:

- `day`: explicit `format="datetime"` or the preference. Schedule the
  next tick at the next day boundary (still capped at one hour).
- `threshold`: compact text from a threshold. It can turn relative
  before midnight, so keep the existing cadence (fine ticks, capped by
  the next day boundary, plus the `micro` threshold time).

Past compact text still waits for the next day boundary. The
`format="datetime"` hourly case now takes the `day` path, so add a
threshold-derived recent-past case to keep coverage of that branch.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The digits test built its expected value with the same `Intl` call as
the element, so it also passed with ASCII digits. Assert the literal
`ar-EG-u-nu-arab` output instead.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tay1orjones
tay1orjones merged commit 7a70f40 into main Nov 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an opt-in compact absolute-time preset

4 participants