[Proposal] Migrate component date handling from native Date to the modern Temporal API #4751
Unanswered
Caetan
asked this question in
PrimeReact
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi PrimeReact team!
First off, thank you for the amazing library. I wanted to open a discussion about updating how PrimeReact handles dates in components like Calendar, Timeline, and DataTable.
The issue with Date:
As many developers know, the standard JavaScript Date object is notoriously tricky to work with. It causes frequent bugs related to timezones, and because the objects can be unexpectedly modified (mutated), they don't always play nicely with React's state.
The solution:
JavaScript is introducing the new Temporal API to fix the broken Date object. Temporal objects are immutable and handle timezones perfectly right out of the box, without needing heavy external libraries like Moment or Date-fns.
The Proposal:
Is there a plan to support Temporal in PrimeReact?
It would be incredibly helpful if developers could start passing Temporal objects directly to date-based components. A couple of simple ways this could work:
Adding an opt-in prop (like useTemporal={true}) to let the component know it's receiving a Temporal object instead of a Date.
Planning a full migration to Temporal for the next major version of PrimeReact.
I know browser support is still rolling out and requires polyfills for now, but it would be great to start future-proofing the library.
Would love to hear your thoughts or if this is already on the roadmap! Thanks again.
Caetán.
Beta Was this translation helpful? Give feedback.
All reactions