components icon indicating copy to clipboard operation
components copied to clipboard

feat(DATE): Add Temporal Adapter

Open Akxe opened this issue 3 years ago • 4 comments

Feature Description

The Temporal API has been almost done for a year now.

Extract from README.MD:

NOTE: Although this proposal's API is not expected to change, implementers of this proposal MUST NOT ship unflagged Temporal implementations until IETF standardizes timezone/calendar string serialization formats. See https://github.com/tc39/proposal-temporal/issues/1450 for updates.

Use Case

If the adapter were created, people could start to experiment with this. Also, the could be THE final adapter to exist. (If temporal lives to meet expectation)

Akxe avatar Oct 04 '22 08:10 Akxe

This could be solved by adding an adapter method getMonthList that would return a readonly array of length 12.

---------- Original e-mail ---------- I just tried to implement based on the polyfill.

Unfortunately I am running into an issue because the calendar view expects the month to start at 0 ...

See: https://github.com/angular/components/blob/main/src/material/datepicker/month-view.ts#L403C1-L404C1

Since with Temporal the month starts with 1 we can not use index based usage of the month names. I tried working around this by adding a dummy object into the array. But then the month view gets broken...

Another issue is here: https://github.com/angular/components/blob/main/src/material/datepicker/year-view.ts#L306

Using fixed months array results in trying to create a month 0 which is no possible with Temporal

Demo: https://stackblitz-starters-g4yw3h.stackblitz.io

Akxe avatar Aug 23 '23 14:08 Akxe

This could be solved by adding an adapter method getMonthList that would return a readonly array of length 12

Also considering the different calendar options, this might be a better solution (not every calendar has 12 months)

I also was able to implement it by adding or substracting the month where I had to:

Stackblitz

digaus avatar Aug 23 '23 14:08 digaus

Anything planned here?

Temporal is currently supported as a TP in Firefox and Safari (not fully). Seems like it will soon hit all major browsers.

A Temporal date adapter would be nice to have.

https://developer.mozilla.org/en-US/blog/javascript-temporal-is-coming/

gausmadi avatar Feb 17 '25 15:02 gausmadi

Temporal is already supported by Firefox. Also there is a polyfill for it https://www.npmjs.com/package/@js-temporal/polyfill. Can you revise the priority, please?

stasberkov avatar Nov 20 '25 20:11 stasberkov