Skip to content

Show the envelope page's times in the reader's own time zone - #257

Open
gagegreg wants to merge 2 commits into
NYLLON-SOFTWARE:mainfrom
gagegreg:envelope-times-in-reader-zone
Open

gagegreg wants to merge 2 commits into
NYLLON-SOFTWARE:mainfrom
gagegreg:envelope-times-in-reader-zone

Conversation

@gagegreg

@gagegreg gagegreg commented Nov 23, 2026 •

Copy link
Copy Markdown

The envelope page writes its times on the server, so a sender reads them in the server's time zone instead of their own:

  • The timeline gives UTC times and does not say they are UTC. Something a sender in Detroit did at 6:00 PM shows as "Nov 18, 11:00 PM".
  • "You can send another reminder after November 19 at 11:00 PM" is in the server's zone, and the zone is not named.
  • The dates ("Created November 19, 2026", "Signed Nov 19, 2026", "Scheduled to be deleted on …") are UTC dates. In the evening anywhere west of Greenwich they are already tomorrow's.
  • The deadline does say UTC, but the sender still has to convert it.

The fix. The page is now given each moment as a Unix time, and the browser writes it in the reader's own time zone. Wherever a time of day is shown, the zone is named ("Nov 18, 6:00 PM EST"), so two people reading the same envelope in different places can tell they are looking at the same moment. Hovering over a time shows it in UTC.

Emails, signed PDFs, certificates, the audit trail export and the API are not changed and stay in UTC: one copy of each is read by people in different places. The dashboard list still shows UTC dates. I left it out to keep this to one page, and can follow up if you want it.

We have run an earlier version of this on a self-hosted install since 0.4.0.

How to verify

  • Open a sent envelope. The timeline times end in the name of your own zone, and "Expires …" gives the deadline in your time.
  • Change your computer's time zone and click back into the window. The times follow.
  • Open the same envelope from a second computer in another zone. Each reader sees their own time, and the zone names show it is the same moment.

For agents

Code notes

  • src/lib/local-time.ts: formatLocalTime(unixSeconds, format, timeZone), with four formats that match what the page already showed. It is pure, so the unit tests give it fixed zones. It keeps one Intl.DateTimeFormat for each format and zone in use.
  • src/components/shared/local-time.tsx: <LocalTime> renders a <time dateTime>. It reads the browser's zone through useSyncExternalStore with a server snapshot of "UTC". The server render and the hydration render are therefore the same, and the zone is applied in the render after. It reads the zone again when the window regains focus.
  • src/lib/envelopes.ts: EnvelopeDetailData and the types under it carry Unix seconds instead of finished labels: createdAt, deadline.expiresAt, manualReminder.nextAvailableAt, timeline[].timestamp and signers[].statusDetail ({ label, timestamp? }). A deadline_changed timeline item also carries deadlineAt, so the page can write "Deadline set to …" in local time; its description still holds the UTC sentence. formatLongDate, formatTimelineTimestamp and their formatters had no other use and are removed.
  • getEnvelopeDetailDataForUser is called only by the envelope page and by database tests that read timeline[].description, signers, copyRecipients and signatureTypeLabel. Those tests pass unchanged.
  • src/app/(app)/envelopes/[id]/page.tsx: the deletion notice passes deleteAfter instead of a formatted date.
  • Not changed: formatDeadline and formatReminderAvailableAt, which emails and API error messages still use, and the dashboard's createdAtLabel.

Tests added

  • src/lib/local-time.test.ts: the zone is named, the date is the reader's calendar day across UTC midnight, and the hour that repeats when clocks go back is told apart.
  • e2e/viewer-time-zone.spec.ts: a sender in America/Detroit sends an envelope and sees EST or EDT times. A second browser context in Europe/Belgrade opens the same page and sees the same datetime values written as GMT+1 or GMT+2, with no page errors and no hydration warnings. The HTML as the server sends it gives every time of day in UTC, named as UTC. Last, the browser is made to report another zone and the window is focused again, and the times are rewritten in that zone. The spec cannot pass on unmodified main: it looks for <time> elements, and main has none.

Commands run (Linux, Node 24.22.3, Postgres 17, npm ci from the lockfile, on main at 4d16b88)

  • npm run typecheck: exit 0
  • npm run lint: 0 errors and 8 warnings, none of them in the changed files
  • npm run format:check: clean
  • npm test: 490/490 pass
  • npm run test:db: 410/410 pass
  • npx playwright test signing-flow viewer-time-zone: the new spec passes, and 8 of the 9 tests in signing-flow.spec.ts pass. The ninth, "with local disk storage a PDF just under 20 MB uploads, and a larger request is refused", fails the same way on unmodified main on this machine: the upload is still being validated when the 20-second wait ends. I take that to be the machine and not this change.

🤖 Generated with Claude Code

Note

Show envelope page times in the reader's local time zone

  • Adds a LocalTime client component in local-time.tsx that renders UTC on the server, then switches to the browser's time zone via useSyncExternalStore. A window focus event re-reads the zone so an already-open page updates.
  • Adds formatLocalTime in local-time.ts with four display formats, a per-zone formatter cache, and time-zone abbreviations for time-of-day values.
  • Envelope detail data in envelopes.ts now carries raw Unix-second timestamps instead of preformatted UTC strings; the UTC formatters are removed. EnvelopeDetailShell renders created, deletion, signer status, timeline, and deadline times through LocalTime.
  • Adds unit tests for named-zone formatting, reader-zone calendar dates, and repeated daylight-saving hours, plus a Playwright test covering server UTC output, reader-local display, and focus-triggered updates.
  • Behavioral Change: pages no longer render preformatted UTC labels; check the updated EnvelopeDetailData, EnvelopeDetailTimelineItem, and EnvelopeDeletionNotice types if other consumers read them.

Macroscope summarized ebea666.

The envelope page wrote every time on the server. The timeline gave
times in UTC without saying so ("Nov 18, 11:00 PM"), the note about the
next reminder used the server's zone without naming it, and the dates
were UTC dates, a day off for a reader in the evening west of Greenwich.

The page is now given the moments themselves and the browser writes
them in the reader's zone, naming the zone wherever a time of day is
shown. The first draw is in UTC on the server and in the browser alike,
so the two match, and the browser then writes the times again in its
own zone. Emails, signed PDFs, certificates and exports keep UTC.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

@gagegreg is attempting to deploy a commit to the Basic Intelligence Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The envelope page shows dates and times in the reader's zone while keeping UTC available on hover.

Changes since the previous review:

  • Envelope details show dates and times in the reader’s time zone.

Both previous findings are addressed. No new actionable issues were found. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "Reuse the time formatters, and test that..." · Reviewed by Greptile

Comment thread src/lib/local-time.ts Resolved
Comment thread e2e/viewer-time-zone.spec.ts Resolved
Making an Intl.DateTimeFormat costs far more than using one, and a long
timeline made one for every entry on every draw. There is now one for
each format and zone in use.

The browser test also checks the path that had no test: the browser
reports another zone, the reader comes back to the window, and the
times are written again in the new zone.

Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant