Skip to content

feat: add support for time-zone attribute#316

Merged
TylerJDev merged 5 commits intogithub:mainfrom
davhdavh:main
Aug 20, 2025
Merged

feat: add support for time-zone attribute#316
TylerJDev merged 5 commits intogithub:mainfrom
davhdavh:main

Conversation

@davhdavh
Copy link
Contributor

fixes #292

Copilot AI review requested due to automatic review settings June 20, 2025 12:59
@davhdavh davhdavh requested a review from a team as a code owner June 20, 2025 12:59

This comment was marked as outdated.

@davhdavh davhdavh requested a review from Copilot June 24, 2025 02:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 timeZone getter, observed attribute, and integrated into Intl.DateTimeFormat options.
  • Updated README with documentation for the new time-zone attribute.

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 hyphenated time-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.
Copy link

Copilot AI Jun 24, 2025

Choose a reason for hiding this comment

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

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.
Copilot uses AI. Check for mistakes.
@TylerJDev
Copy link
Contributor

Hey @davhdavh! 👋

Thanks so much for the PR! We'll aim to take a look at it and review it this week! 😁

@francinelucca francinelucca requested a review from TylerJDev July 2, 2025 04:39
@brunoprietog
Copy link

Hi, what can we do to move forward with this? 🙏

@francinelucca
Copy link
Contributor

@TylerJDev is this good to merge?

@TylerJDev TylerJDev merged commit 4d0059b into github:main Aug 20, 2025
1 check passed
@TylerJDev
Copy link
Contributor

Thanks again for the contribution @davhdavh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants