Add micro tense phrasing#358
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reintroduces the previously merged “micro tense phrasing” work onto main, making format="micro" produce localized tense-aware output when tense is explicitly set to past or future (while keeping the existing compact output for tense="auto").
Changes:
- Add
Intl.RelativeTimeFormat-backed narrow tense phrasing forformat="micro"whentenseispast/future. - Refactor micro-duration handling into a dedicated helper (
#getMicroDuration) and add a micro-specific relative formatter (#getMicroRelativeFormat). - Update/extend tests and README documentation to reflect the new micro tense behavior and ensure datetime/absolute-time fallbacks do not add tense text.
Show a summary per file
| File | Description |
|---|---|
| test/relative-time.js | Adds and updates assertions for micro tense phrasing, including fallback behaviors. |
| src/relative-time-element.ts | Implements micro tense phrasing via Intl.RelativeTimeFormat and refactors micro duration handling. |
| README.md | Documents micro tense phrasing behavior and updates the tense cheatsheet/table. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 3
Comment on lines
+531
to
+540
| test('micro tense phrasing respects lang attribute', async () => { | ||
| const now = new Date(Date.now() + 3 * 60 * 60 * 24 * 1000).toISOString() | ||
| const time = document.createElement('relative-time') | ||
| time.setAttribute('datetime', now) | ||
| time.setAttribute('format', 'micro') | ||
| time.setAttribute('lang', 'es') | ||
| time.setAttribute('tense', 'future') | ||
| await Promise.resolve() | ||
| assert.equal(time.shadowRoot.textContent, 'dentro de 3 d') | ||
| }) |
TylerJDev
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-opens #355 against
main. The original PR was merged into themb/micro-explicit-thresholdfeature branch instead ofmain, so the changes never landed in 5.1.0.