Repository navigation
feat: add an opt-in compact absolute-time preset - #405
Conversation
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>
|
@copilot address the outstanding review feedback |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Addressed in |
|
@copilot address the outstanding review feedback |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Applied in |
There was a problem hiding this comment.
🔵 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
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>

<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.absolute-format="compact"orelement.absoluteFormat = 'compact'. The preset applies after the user preference, threshold, orformat="datetime"selects absolute output. Omitted, empty, unknown, and removed values keep the existing presentation. Setting the property toundefinedremoves the attribute.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 asNov 2, 2026. Compact text ignoresprefix,format-style, display fields, andhour-cycle. Full titles keep their usual format (includinghour-cycle), anddatetime, custom titles, andno-titleare unchanged.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.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
28a3589896dad16d429119cf94712b18b60c498dIn the element checkout:
In the wrapper checkout:
The package contains JavaScript at
dist/index.jsanddist/bundle.js, declarations atdist/index.d.tsanddist/relative-time-element.d.ts, and metadata atcustom-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.