A spec-compliant polyfill for Intl.DateTimeFormat fully tested by the official ECMAScript Conformance test suite
Right now we only support Gregorian calendar in this polyfill. Therefore we recommend setting
calendar: 'gregory' in your options to be safe.
Right now this polyfill supports daylight transition until 2038 due to Year 2038 problem.
This package requires the following capabilities:
You can use polyfill.io URL Builder to create a polyfill script tag for
Intl.DateTimeFormat. By default the created URL does not come with any locale data. In order to add locale data, append
Intl.DateTimeFormat.~locale.<locale>, as well as locale data for any required polyfills, to your list of features. For example:
We provide 2 pre-processed IANA Timezone:
Since JS Engines do not expose default timezone, there's currently no way for us to detect local timezone that a browser is in. Therefore, the default timezone in this polyfill is
You can change this by either calling
__setDefaultTimeZone or always explicitly pass in
timeZone option for accurate date time calculation.
__setDefaultTimeZone is not in the spec, you should make sure to check for its existence before calling it & after tz data has been loaded, e.g:
This library is fully test262-compliant.