Skip to content

Conversation

@briangregoryholmes
Copy link
Contributor

@briangregoryholmes briangregoryholmes commented Jan 13, 2026

This PR removes the use of the adjustOffsetForZone, removeLocalTimezoneOffset and addZoneOffset functions when processing time series data.

Unfortunately, many of the places we render out time series data require JavaScript Date objects for labeling purposes. These objects are always in the user's system time zone regardless of the time zone of the dashboard (or other application view). As such, we want the values of these JavaScript date objects to represent the time in the selected time zone rather than the system time zone. Previously, the functions mentioned above were being used to do this somewhat manually.

Instead, this PR creates two new functions--convertISOStringToJSDateWithSameTimeAsSelectedTimeZone and setJSDateTimeValueToTimeValueInSelectedTimeZone--that are explicit in their purpose and use Luxon's built in keepLocalTime property.

The primary function takes the following steps:

  1. Parse an ISO timestamp in UTC (received from the API) into a Luxon DateTime object in the selected time zone
  2. Set the zone on that DateTime object to the selected zone of the dashboard, but keep the existing local time value
  3. Convert this to a JavaScript Date

As such, an ISO timestamp that falls on midnight (in the selected time zone) will output a JavaScript date that also falls on midnight (in the user's timezone). When converted to a human readable string without reference to a time zone, this value should be correct.

Note: All of this should be unnecessary and we should use Luxon DateTimes and serialization functions as deep into the rendering pipeline as we can.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@briangregoryholmes briangregoryholmes added Type:Bug Something isn't working patch labels Jan 13, 2026
@briangregoryholmes briangregoryholmes merged commit 0deaa92 into main Jan 14, 2026
11 checks passed
@briangregoryholmes briangregoryholmes deleted the bgh/time-zone-adjustment-fix branch January 14, 2026 15:26
briangregoryholmes added a commit that referenced this pull request Jan 14, 2026
* wip

* cleanup

* remove adjustOffsetForZone function

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

Labels

patch Type:Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants