mui-x
mui-x copied to clipboard
[pickers] Support UTC dates and timezones for DateFns
Summary 💡
We use date-fns
as our date library, and just realized that the timezone
prop only supports DayJs, Luxon & Moment. We have tried some workarounds, but the efforts seem like re-inventing the component. Could you make the timezone
prop works for DateFns? What are the steps & challenges to make that happens?
Examples 🌈
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DateTimePicker timezone="UTC" />
</LocalizationProvider>
Motivation 🔦
No response
Search keywords: timezones date-fns datefns UTC
I kind of remind that the date-fns
has not been added because of an issue. But I don't remember which one
@flaviendelangle is their a specific reason why date-fns has not be done or is it a lack of time?
Sorry for the delay, I missed the notification
Date FNS is using JavaScript Date
object and you can't store a timezone on it (see this article)
There is a version of date-fns
called date-fns-tz
which adds support for timezone (NPM page).
But we need to see how it behaves exactly, because for me we won't be able to do things like adapter.getTimezone
.
Basically it's just a question of priority for exploring what's doable. But we have to keep in mind that we might hit a wall here.
Hey there! Any news regarding this issue?
Hey there! Any news regarding this issue?
I appreciate your interest. 🙏 We are spread a bit too thin and have other priorities, so I can only confirm that we'll not be able to work on this issue before Q3. 😉 I've set the grooming priority for this issue to "Medium" so as not to lose it in the depths of other issues.
date-fns@4
has new APIs for timezone support, this should make this issue doable: https://blog.date-fns.org/v40-with-time-zone-support/
I'm moving it back to "To grooming to discuss the priority