Repository navigation
fix: read time picker ranges in the display time zone - #3445
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 617d98b The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
2 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 1 minor 1 posted as inline comment(s) on the changed lines. 1 listed below. Findings outside the changed lines
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
[Medium impact] The changes affect time-range behavior across search and dashboard workflows. Fix the repeated-hour comparison before merging; it can turn a recent search into an empty range.
|
E2E Test Results✅ All tests passed • 459 passed • 1 skipped • 1373s
Tests ran across 4 shards in parallel. |
Deep Review✅ No critical issues found. This PR fixes a real user-facing bug (time-picker range shifting under "Use UTC time" west of UTC) and the refactor is type-safe end to end — the 🟡 P2 -- recommended
🔵 P3 nitpicks🔵 P3 nitpicks (4)
Reviewers (8): correctness, adversarial, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races, previous-comments. Testing gaps: DST spring-forward (non-existent wall clock) path through Deferred (not blocking): No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
With "Use UTC time" on, the search page writes the range text in UTC but the time picker parsed and re-formatted it in the browser's zone. West of UTC a range ending now parsed as future, got clamped to now, and Apply collapsed it to a zero-length range hours in the past. - Time range helpers take an IANA time zone instead of an isUTC flag, and parse in that zone with each date's own offset across DST changes - The picker's date inputs show and read times in that zone - useDisplayTimeZone resolves the zone from the UTC preference - Add toWallClock/fromWallClock and a timeZone option to formatDate
c410ec4 to
617d98b
Compare
| const nowInstant = currentDate(); | ||
| const now = toWallClock(nowInstant, timeZone); | ||
| const parsedDate = parsedWallClock(parsed, timeZone); |
There was a problem hiding this comment.
normalizeParsedDate compares clock readings before returning the original instant. When New York clocks fall back at 2026-11-01T06:00:00Z, Past 30m starts at 05:30Z, whose clock reads 01:30. Now reads 01:00, so the parser treats that past start as future and clamps it to now. The range becomes empty, hiding the requested logs.
Compare known instants against nowInstant before applying the future-date clamp. Add a test for a short range crossing the rollback; the existing Past 1h test has equal start and end clock readings and misses this case.
## Summary Adds a time zone selector to the time picker on the search and dashboard pages. It overrides the User Preferences time zone for that page only and is kept in the `tz` URL param. - `TimeZoneOverrideProvider` reads `tz`; `useDisplayTimeZone` prefers it over the user setting, so everything on the page switches together. Unknown values are ignored. - The picker input shows the zone in use (e.g. `UTC-7`), highlighted when it isn't the browser's. The popover ends with the selector plus "Default", "UTC" and "Local" buttons; User Preferences gets "UTC" and "Local". - Short zone labels are UTC offsets instead of abbreviations (`UTC-7`, not `PDT`). The selector shows the offset on each option and the selected value, and searches by it. - Links from charts and tables to Search and other dashboards carry `tz`. External links don't. The override isn't saved with saved searches or dashboards. ### Screenshots or video <img width="529" height="243" alt="Screenshot 2026-10-30 at 10 39 50" src="https://github.com/user-attachments/assets/5cab281b-441d-48f0-9ae9-74d2c51abad7" /> <img width="664" height="319" alt="Screenshot 2026-10-30 at 10 40 02" src="https://github.com/user-attachments/assets/1822d592-ab3a-4597-b84f-78ba141d5349" /> ### How to test on Vercel preview **Preview routes:** /search, /dashboards **Steps:** 1. On /search, click the time picker input (`data-testid="time-picker-input"`), click the "Time zone" field (`data-testid="time-picker-time-zone-select"`), type "tokyo" and click "Asia/Tokyo". 2. Verify the badge (`data-testid="time-picker-time-zone"`) shows "UTC+9" and the URL contains `tz=Asia%2FTokyo`. 3. Open the time picker, click "Default" (`data-testid="time-picker-time-zone-default"`), and verify `tz` is no longer in the URL. 4. On /dashboards, open any dashboard, repeat step 1, and verify the badge shows "UTC+9". ### References - Linear Issue: Closes HDX-5741 - Related PRs: #3445, #3447, #3449
Summary
Fixes the time picker shifting ranges when "Use UTC time" is on and the browser is west of UTC, and makes the time range helpers take a time zone name so later PRs can add a time zone setting.
parseTimeRangeInput,formatTimeRangeText,rangeNeedsExplicitYear,timeRangeInputToSeconds,dateParseranddateRangeToStringtake an IANA time zone (undefined= local) instead of anisUTCflag.useDisplayTimeZonehook resolves the zone from the UTC preference. The picker,timeQuery.tsand the dashboard page use it.common-utils:formatDateacceptstimeZone; newtoWallClock/fromWallClockhelpers convert between instants and clock readings in a zone.How this sets up the follow-up work
Follow-up PRs add a time zone selector in two places: User Preferences, where it replaces the "Use UTC time" switch as the global setting, and the search page time picker, where it overrides the global setting for that page. Both selectors keep UTC and Local at the top. This PR does the groundwork so those stay small:
Asia/Tokyo) needs no more parsing or formatting changes.useDisplayTimeZoneis the single place that decides the zone. The global setting only changes what this hook returns, and the search page override can wrap the page in a provider that the hook reads.How to reproduce
Setup: set browser time to west of UTC (Chromium: DevTools → ⋮ → More tools → Sensors → Location → "San Francisco")
On
main:Oct 22 12:00:00 - Oct 22 13:00:00.06:00).On this branch:
12:00:00and13:00:00.References