Skip to content

fix(leaderboard): normalize timezone display in timestamp helpers - #88

Open
praveenchand-2005 wants to merge 1 commit into
SPaulse-Org:mainfrom
praveenchand-2005:fix/leaderboard-timezone-normalization
Open

fix(leaderboard): normalize timezone display in timestamp helpers#88
praveenchand-2005 wants to merge 1 commit into
SPaulse-Org:mainfrom
praveenchand-2005:fix/leaderboard-timezone-normalization

Conversation

@praveenchand-2005

Copy link
Copy Markdown

Summary

Fixes the inconsistent timezone display on the leaderboard by repairing the timestamp helpers.

The original helpers.ts contained merge-conflict artifacts:

  • Duplicate toTimestampMs - the first copy returned Date.now() for invalid input (so bad timestamps rendered as "now"), the second was the correct normalizer.
  • Duplicate formatDate, formatTime, timeAgo, formatEventTime definitions.
  • formatDate used a hardcoded inline threshold (4_102_444_800) instead of the shared toTimestampMs normalizer, so seconds/millisecond handling could diverge from every other call site.

Changes

  • Removed all duplicate definitions and dead code.
  • formatDate / formatTime now route through the single shared toTimestampMs, so a Unix-seconds timestamp and the same instant in milliseconds render identically in the viewer's local timezone with a timezone label.
  • formatEventTime now uses Intl.DateTimeFormat consistently with the rest of the file (previously mixed toLocaleString).
  • Added tests for formatEventTime, including invalid-input handling.

Test evidence

vitest run - 15 files / 217 tests passing:

  • helpers.test.ts: 66 tests passing (formatDate/formatTime timezone-aware, seconds+ms normalization, invalid input -> em dash, formatEventTime).
  • Full suite: 217 passed.

Verified with tsc --noEmit - no errors.

- Remove duplicate toTimestampMs/formatDate/formatTime/timeAgo definitions
  left by a bad merge; the duplicate toTimestampMs returned Date.now() for
  invalid input instead of the invalid sentinel.
- Route formatDate/formatTime through the shared toTimestampMs so seconds
  and milliseconds are normalized identically everywhere.
- Make formatEventTime use Intl.DateTimeFormat consistently with the rest
  of the file.
- Add coverage for formatEventTime including invalid-input handling.
@praveenchand-2005

Copy link
Copy Markdown
Author

/claim #80

@praveenchand-2005

Copy link
Copy Markdown
Author

Test & Check Evidence (verified locally)

Vitest (full suite):

Test Files  15 passed (15)
Tests       217 passed (217)
Duration    57.90s
  • helpers.test.ts: 66 tests passing, covering timezone-aware formatDate/formatTime, seconds+ms normalization, invalid input -> em dash, and formatEventTime (incl. invalid-input handling).
    TypeScript: tsc --noEmit - no errors.

PR status: Changes can be cleanly merged. Repo has no CI workflow configured (Checks 0), so verification is provided via the local suite above.

Summary of fix: Removed merge-conflict duplicate definitions in helpers.ts (the first toTimestampMs returned Date.now() for invalid input; formatDate used an inline threshold instead of the shared normalizer). Now all timestamps render consistently in the viewer's locale/timezone.

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