date-io icon indicating copy to clipboard operation
date-io copied to clipboard

Support for Temporal

Open dmtrKovalenko opened this issue 3 years ago • 6 comments

Should we implement an adapter for the provided (for now experimental) proposal for Temporal? https://tc39.es/proposal-temporal/docs/parse-draft.html

dmtrKovalenko avatar Sep 18 '20 09:09 dmtrKovalenko

I would like to say yes, because date-io is used by libraries with separate DatePicker and TimePicker fields and it would be interesting to see those backed by Temporal.PlainDate and Temporal.PlainTime. However Temporal is pretty different from every other date library where only something equivalent to Temporal.Instant is used. I expect a new major with an updated API may be necessary to properly add Temporal.

dantman avatar Jul 27 '21 05:07 dantman

Can anyone point me in the right direction for implementing getFormatHelperText for Temporal? I can see it spits out a date format but i'm not sure how to apply this in Temporal.ZonedDateTime's context.

I'm hacking my way through an implementation for IUtils<Temporal.ZonedDateTime> as I've noticed mui's datepicker conforms to date-io's IUtils interface for its localisation dateAdapter.

mui/mui-x#4399

remy90 avatar Feb 09 '22 12:02 remy90

@remy90 this likely will be complicated native into doesn't have this option so for Luxon we basically omit this feature. I suppose for temporal this will be the only solution as well

dmtrKovalenko avatar Feb 09 '22 12:02 dmtrKovalenko

Thanks for your swift response, after moving past this step, i'm not sure it's currently possible to apply a date format to Temporal.TimeZone string out of the box anyway: https://github.com/js-temporal/proposal-temporal-v2#ability-to-parse-a-user-supplied-string-format-into-temporal-objects

remy90 avatar Feb 09 '22 13:02 remy90

Ok, I see two possibilities for a future date-io that supports Temporal.

  • A) A @date-io/temporal adapter that works like the current adapters so it's "compatible", but throws out most of the advantages of Temporal. i.e. The adapter only accepts Temporal.Instant and Temporal.ZonedDateTime. Anyone wanting to work with other types like Temporal.PlainDate is out of luck. And anyone hoping a date picker using @date-io as an adapter would let them pick Temporal.PlainDate instead of a full datetime is out of luck.
  • B) A new major @date-io with an updated Temporal-first API, where the temporal implementation is aware of things like Temporal.PlainDate and time zones. date() would be replaced with individual functions that are better aware of what is being parsed (a full timestamp, just the day of year, just the time?). And the other adapters use this API, with acknowledgement of course that there are limitations to what they can do.

dantman avatar Feb 26 '22 04:02 dantman

Yes!

wobsoriano avatar Dec 27 '22 19:12 wobsoriano