Skip to content

feat(js): Add timezone providers #91805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025

Conversation

evanpurkhiser
Copy link
Member

@evanpurkhiser evanpurkhiser commented May 16, 2025

This implements a new top-level provider that provides the timezone to
components like <DateTime />. This provider exposes two provider components and one hook.

By default the provider uses the browsers timezone.

  • useTimezone - Get the currently set timezone by the user

  • TimezoneProvider - The simplest provider that provides the timezone using the interface

    <TimezoneProvider timezone="America/Los_Angeles">
      ...
    </TimezoneProvider>
  • UserTimezoneProvider - Provides the timezone from the ConfigStore user. Reacts to
    changes to the user.

@evanpurkhiser evanpurkhiser requested a review from a team as a code owner May 16, 2025 17:04
@evanpurkhiser evanpurkhiser requested review from a team and removed request for a team May 16, 2025 17:04
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 16, 2025
@@ -74,14 +73,13 @@ export function DateTime({
// UTC time.
timeZone: timeZone ?? utc,
seconds,
...options,
Copy link
Member Author

Choose a reason for hiding this comment

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

This was a mistake before. We were spreading the entire user.options object into the getFormat function.

Copy link

codecov bot commented May 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #91805      +/-   ##
==========================================
- Coverage   80.27%   80.27%   -0.01%     
==========================================
  Files       10348    10348              
  Lines      586564   586563       -1     
  Branches    22574    22574              
==========================================
- Hits       470880   470879       -1     
  Misses     114452   114452              
  Partials     1232     1232              

@ryan953 ryan953 requested a review from a team May 16, 2025 17:08
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-js-add-timezoneprovider branch from 8734977 to 174e081 Compare May 16, 2025 17:23
@evanpurkhiser evanpurkhiser changed the title feat(js): Add TimezoneProvider feat(js): Add timezone providers May 16, 2025
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-js-add-timezoneprovider branch 3 times, most recently from a352a67 to 14deb5d Compare May 16, 2025 19:54
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-js-add-timezoneprovider branch from 14deb5d to 6560288 Compare May 16, 2025 19:57
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-js-add-timezoneprovider branch from 6560288 to ec186b8 Compare May 16, 2025 20:04
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-js-add-timezoneprovider branch from ec186b8 to 283e982 Compare May 16, 2025 21:05
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-js-add-timezoneprovider branch from 283e982 to e90978e Compare May 16, 2025 21:13
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-js-add-timezoneprovider branch from e90978e to c4d54f9 Compare May 16, 2025 21:16
@evanpurkhiser evanpurkhiser merged commit 40a702d into master May 16, 2025
41 checks passed
@evanpurkhiser evanpurkhiser deleted the evanpurkhiser/feat-js-add-timezoneprovider branch May 16, 2025 21:53
Copy link

sentry-io bot commented May 17, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ Error: The data does not contain any plottable values. /insights/backend/http/domains/ View Issue
  • ‼️ Error: The data does not contain any plottable values. /organizations/:orgId/explore/logs/ View Issue
  • ‼️ Error: The data does not contain any plottable values. /issues/ View Issue
  • ‼️ TypeError: Cannot read properties of undefined (reading 'map') /insights/mobile/http/domains/ View Issue
  • ‼️ Error: The data does not contain any plottable values. /insights/backend/http/domains/ View Issue

Did you find this useful? React with a 👍 or 👎

andrewshie-sentry pushed a commit that referenced this pull request May 20, 2025
This implements a new top-level provider that provides the timezone to
components like `<DateTime />`. This provider exposes two provider
components and one hook.

By default the provider uses the browsers timezone.

 - `useTimezone` - Get the currently set timezone by the user

- `TimezoneProvider` - The simplest provider that provides the timezone
using the interface
  
   ```tsx
   <TimezoneProvider timezone="America/Los_Angeles">
     ...
   </TimezoneProvider>
   ```

- `UserTimezoneProvider` - Provides the timezone from the `ConfigStore`
user. Reacts to
   changes to the user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants