mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[pickers] Support UTC dates and timezones for DateFns

Open vu-dao-93 opened this issue 1 year ago • 4 comments

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

vu-dao-93 avatar Oct 04 '23 10:10 vu-dao-93

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?

alexfauquette avatar Oct 05 '23 10:10 alexfauquette

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.

flaviendelangle avatar Oct 25 '23 07:10 flaviendelangle

Hey there! Any news regarding this issue?

hutsul avatar May 09 '24 08:05 hutsul

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.

LukasTy avatar May 17 '24 13:05 LukasTy

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

flaviendelangle avatar Sep 17 '24 06:09 flaviendelangle