feat: add support for time-zone attribute#316
Merged
TylerJDev merged 5 commits intogithub:mainfrom Aug 20, 2025
Merged
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds support for a time-zone attribute to the <relative-time> element, allowing consumers to specify IANA time zones for formatting. Key changes:
- Introduced tests covering setting, changing, and inheriting
time-zone. - Implemented a
timeZonegetter, observed attribute, and integrated intoIntl.DateTimeFormatoptions. - Updated README with documentation for the new
time-zoneattribute.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/relative-time.js | New test suite for time-zone behavior (setting, updating, inheriting) |
| src/relative-time-element.ts | Added timeZone getter, included 'time-zone' in observedAttributes, and passed timeZone to formatters |
| README.md | Added documentation entry for the time-zone attribute |
Comments suppressed due to low confidence (2)
test/relative-time.js:2590
- [nitpick] The suite name uses camelCase
[timeZone], but the attribute is hyphenatedtime-zone. Rename to[time-zone]for consistency with attribute naming.
suite('[timeZone]', function () {
test/relative-time.js:2630
- Relying on the system default time zone makes this assertion environment-dependent and potentially flaky. Consider mocking the default time zone or explicitly setting a fallback for consistent test results.
assert.equal(el.shadowRoot.textContent, 'Wed, Jan 1, 2020, 4:00:00 PM')
| </relative-time> | ||
| ``` | ||
|
|
||
| If the individual element does not have a `time-zone` attribute then it will traverse upwards in the tree to find the closest element that does, or default the `time-zone` to the browsers default. |
There was a problem hiding this comment.
Grammar: change “browsers default” to “browser's default” to fix the possessive form.
Suggested change
| If the individual element does not have a `time-zone` attribute then it will traverse upwards in the tree to find the closest element that does, or default the `time-zone` to the browsers default. | |
| If the individual element does not have a `time-zone` attribute then it will traverse upwards in the tree to find the closest element that does, or default the `time-zone` to the browser's default. |
Contributor
|
Hey @davhdavh! 👋 Thanks so much for the PR! We'll aim to take a look at it and review it this week! 😁 |
TylerJDev
approved these changes
Jul 7, 2025
|
Hi, what can we do to move forward with this? 🙏 |
Contributor
|
@TylerJDev is this good to merge? |
Contributor
|
Thanks again for the contribution @davhdavh! |
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.
fixes #292