Skip to content

refactor: replace custom date utilities with date-fns and date-fns-tz

Laxman Reddy requested to merge refactor/date-utils-clean into develop

Description:

Refactored date and time utility functions in src/lib/utils.ts by replacing custom implementations with date-fns and date-fns-tz. This removes manual date/time calculations and improves reliability and maintainability.

  • Replaced formatModernTime with formatDistanceToNow
  • Refactored formatDuration using intervalToDuration and formatDuration from date-fns
  • Replaced getISTDate with toZonedTime using 'Asia/Kolkata'
  • Removed hardcoded timezone offsets and manual logic
  • Preserved existing function signatures to avoid breaking changes
  • Restored missing utility functions (formatMediaDuration, formatRelativeTime, formatISTDateTime) to maintain compatibility across the app

Type of Change:

  • Bug Fix
  • Feature Development
  • Documentation

Testing:

  • Tested on desktop
  • Tested on mobile
  • Tested in different browsers

Screenshots (if applicable):

No UI changes. Refactor is internal and does not affect visual output.


Video Demo

N/A (No UI/feature changes)


Checklist:

  • Code follows project style guidelines
  • Self-review completed
  • No console errors
  • TypeScript types are correct

Merge request reports

Loading