What problem does it solve?
It prevents inconsistent and broken date formatting/parsing across the monorepo, including the common “Invalid Date” and wrong-locale/UTC-vs-local-midnight bugs.
Core Features & Use Cases
- Single, consistent date API: format, parse, validate, and range helpers so UI and routes don’t diverge.
- Locale-aware rendering: resolves locale from next-intl locale codes so English/Spanish output stays correct.
- Safer parsing + relative time: parseDate returns null for garbage input, and RelativeTime renders SSR-safe “x minutes ago” with adaptive ticking and no hydration mismatch.
- Use cases: fixing “Invalid Date” in the UI, adding date columns, building “hace 3 minutos” strings, or parsing user-entered/query-provided dates reliably.
Quick Start
Import and use date helpers from @loyalty/date in your Next.js components and pass the current locale, then use @loyalty/date/react RelativeTime when displaying “time ago”.