Skip to content

fix(leaderboard): localize timestamps safely after hydration - #87

Open
juan-fernandez-gotherlabs wants to merge 1 commit into
Steller-StellarPulse-org:mainfrom
juan-fernandez-gotherlabs:agent/leaderboard-timezone-hydration
Open

fix(leaderboard): localize timestamps safely after hydration#87
juan-fernandez-gotherlabs wants to merge 1 commit into
Steller-StellarPulse-org:mainfrom
juan-fernandez-gotherlabs:agent/leaderboard-timezone-hydration

Conversation

@juan-fernandez-gotherlabs

Copy link
Copy Markdown

Fixes #80

/claim #80

Summary

  • normalize Unix timestamps supplied in either seconds or milliseconds;
  • consolidate the duplicated and malformed timestamp helpers while preserving
    their public exports;
  • render leaderboard timestamps through one hydration-safe component;
  • use deterministic UTC markup for SSR and the first client render, then switch
    to the viewer's locale and IANA timezone after mount;
  • keep exact machine-readable values in semantic <time dateTime="...">
    elements;
  • add regression coverage for SSR, real React hydration, multiple timezones,
    relative timestamps, invalid inputs, and leaderboard integration.

Why a component is needed

The leaderboard page is a client component, but Next.js may still pre-render it
on the server. Formatting immediately with server defaults can put server-local
text in the HTML, while reading navigator from shared utilities is unsafe
during SSR.

LocalizedTimestamp uses the same en-US/UTC snapshot on the server and the
first browser render. Its effect then resolves navigator.languages and the
browser's IANA timezone. This avoids hydration mismatches without exposing
browser globals to shared helpers.

Validation

  • npm test — 16 test files, 218/218 tests passed;
  • npx tsc --noEmit — passed;
  • npm run build — passed, including the statically generated leaderboard;
  • git diff --check — passed;
  • clean-patch application against commit
    74a2491333f1ef0151e819a80d6514967a949498 — passed.

No production dependency is added.

@juan-fernandez-gotherlabs
juan-fernandez-gotherlabs marked this pull request as ready for review August 6, 2026 14:59
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.

[wave] Fix inconsistent timezone display in leaderboard

1 participant