fix: convert dates/timestamps to JS dates for rendering #8633
+77
−75
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.
This PR removes the use of the
adjustOffsetForZone,removeLocalTimezoneOffsetandaddZoneOffsetfunctions 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--
convertISOStringToJSDateWithSameTimeAsSelectedTimeZoneandsetJSDateTimeValueToTimeValueInSelectedTimeZone--that are explicit in their purpose and use Luxon's built inkeepLocalTimeproperty.The primary function takes the following steps:
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: