fullcalendar / temporal-polyfill

A lightweight polyfill for Temporal, successor to the JavaScript Date object
MIT License
361 stars 14 forks source link

Non-ISO/gregory calendar support in older browsers #37

Open arshaw opened 7 months ago

arshaw commented 7 months ago

Issue #34 made explicit that non-ISO/gregory calendar support (like chinese, persian, hebrew) have higher minimum browser requirements than other features:

Chrome 80
(Feb 2020)
Firefox 76
(May 2020)
Safari 14.1
(Apr 2021)
Safari iOS 14.5
(Apr 2021)
Edge 80
(Feb 2020)
Node.js 14
(Apr 2020)

This is because temporal-polyfill relies on the Intl.DateTimeFormat constructor supporting the calendar option.

To be able to support older browsers, the calendar option would need be polyfilled. Unfortunately Format.JS explicitly does not support any calendar other than ISO/gregory.

Aside from polyfilling calendar support into Intl.DateTimeFormat, one might be able to hook-in the required calendar computations into temporal-polyfill itself. However, then formatting functions like toLocaleString would not work, nor would passing in Temporal objects to Intl.DatetimeFormat::format(). In my opinion, polyfilling calendar support into Intl.DateTimeFormat is the best way.

This ticket proposes polyfilling calendar support into Intl.DateTimeFormat.

It'd be possible to use @internationalized/date's calendar y/m/w/d computations: https://github.com/adobe/react-spectrum/tree/main/packages/%40internationalized/date/src/calendars

It'd be theoretically possible to scrape-out information about formatting from a modern browser that supports calendar. It would be challenging because nearly every permutation of the Intl.DateTimeFormat must be considered.