Render deploy History times in the viewer's local timezone - #375
Open
nickhammond wants to merge 2 commits into
Open
Render deploy History times in the viewer's local timezone#375nickhammond wants to merge 2 commits into
nickhammond wants to merge 2 commits into
Conversation
The deploy History/Activity page formatted each deploy timestamp in the organization's configured timezone, so viewers in other timezones had to convert in their head. Format it client-side in the viewer's own browser timezone instead. - Add a local-time marker class to the deploy <time> element and emit the timestamp as iso8601 (Time#to_s is not reliably parseable by new Date()). - In the existing turbo:load handler, format time.local-time elements with Intl.DateTimeFormat using the browser's own locale/timezone, guarding against invalid dates so the server-rendered fallback stays put. The server-rendered org-timezone string remains as the no-JS fallback.
There was a problem hiding this comment.
Pull request overview
Updates the deploy History (“Activity”) page to display deploy timestamps in each viewer’s local browser timezone (client-side), while keeping the existing server-rendered organization-timezone text as a no-JS fallback.
Changes:
- Mark the History page
<time>element with alocal-timeclass and emit an ISO8601datetimeattribute for reliable JS parsing. - On
turbo:load, formattime.local-timeelements usingIntl.DateTimeFormatwith the browser’s locale/timezone and include a timezone abbreviation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/views/destinations/deploys.html.erb | Adds local-time class and switches <time datetime> to recorded_at.iso8601 for client-side parsing. |
| app/javascript/application.js | Formats time.local-time timestamps on page load using Intl.DateTimeFormat in the viewer’s local timezone. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+19
to
+24
| document.querySelectorAll('time.local-time').forEach((el) => { | ||
| const date = new Date(el.getAttribute('datetime')); | ||
| if (!isNaN(date.getTime())) { | ||
| el.textContent = localTimeFormatter.format(date); | ||
| } | ||
| }); |
recorded_at is validated presence: true, but the column is nullable, so legacy rows (predating that validation) can hold nil. Both the datetime attribute and the visible timestamp call methods on it, so a nil would raise and break the History page. Fall back to the record's created_at (null: false) for the display.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
On the deploy History / "Activity" page, each deploy's timestamp now renders in the viewer's own browser timezone, formatted client-side — instead of the organization's configured timezone.
Same deploy, same instant:
Aug 12, 2026, 11:45 AM EDTAug 13, 2026, 12:45 AM JSTThe timezone abbreviation is shown so it's unambiguous. No per-user configuration — it reads the browser's timezone automatically.
Why
Times were formatted server-side in the org's
selected_time_zone, so anyone on a team spread across timezones had to convert in their head. This is per-viewer, resolved in each person's browser.How
app/views/destinations/deploys.html.erb— add alocal-timemarker class to the deploy<time>element and emit the timestamp as.iso8601(Ruby's defaultTime#to_s, e.g."2026-08-12 15:45:00 UTC", is not reliably parseable by JSnew Date()).app/javascript/application.js— in the existingturbo:loadhandler, formattime.local-timeelements withIntl.DateTimeFormat(undefined, { dateStyle, timeStyle, timeZoneName }).undefinedlocale + no explicittimeZonemakes it use the browser's own locale/timezone. AnisNaNguard leaves the fallback in place on a bad date.The server-rendered org-timezone string stays as the inner text — it's the no-JS fallback, overwritten client-side on load.
Scope / notes
timeago.jswiring are untouched.distance_of_time_in_words("… before") is a duration between two deploys, already timezone-independent — left alone.Deployhas nobroadcastson this view, so nothing is missed.Intlis built into the browser), no Stimulus controller, no system test.Testing
bundle exec standardrb— clean.selected_time_zoneno longer affects it. With JS disabled, the server-rendered org-timezone fallback still shows.