Skip to content

fix(utils): consolidate date and datetime formatting helpers (#28) - #96

Open
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/consolidate-date-formatting-28
Open

fix(utils): consolidate date and datetime formatting helpers (#28)#96
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/consolidate-date-formatting-28

Conversation

@ghzhost

@ghzhost ghzhost commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Consolidates duplicated and divergent date formatting implementations between src/lib/utils.ts and src/utils/format.ts (fixes #28).

Changes

  • Updated src/lib/utils.ts's formatDate, formatDateTime, and timeAgo to validate new Date(iso) against isNaN(d.getTime()), preventing invalid timestamp renderings.
  • Refactored src/utils/format.ts to delegate formatDate and formatDateTime to src/lib/utils.ts, accepting both Date instances and ISO strings with consistent behavior and graceful fallbacks on malformed date strings.
  • Added comprehensive unit tests in src/utils/format.test.ts verifying date-only formatting, date-time formatting, Date objects vs strings, and unparseable input fallbacks.

Verification

  • NODE_ENV=test pnpm test (all 27 test suites / 117 tests passing)
  • pnpm run build (clean TypeScript compilation & Vite build)

…Send#28)

- Update lib/utils.ts date helpers to validate parsed dates against isNaN
- Make utils/format.ts delegate formatDate and formatDateTime to lib/utils.ts
- Support Date instances and string inputs consistently with graceful unparseable fallbacks
- Add test coverage for formatDate and formatDateTime across strings and Date objects
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.

lib/utils.ts and utils/format.ts each implement their own, differently-configured date formatting, causing inconsistent date display across the app

1 participant