Intl.DateTimeFormat (ESNext)
A spec-compliant polyfill for Intl.DateTimeFormat fully tested by the official ECMAScript Conformance test suite
caution
Right now we only support Gregorian calendar in this polyfill. Therefore we recommend setting calendar: 'gregory' in your options to be safe.
caution
Right now this polyfill supports daylight transition until 2038 due to Year 2038 problem.
Features#
Installation#
- npm
- yarn
Requirements#
This package requires the following capabilities:
Usage#
Simple#
Dynamic import + capability detection#
Adding IANA Timezone Database#
We provide 2 pre-processed IANA Timezone:
Full: contains ALL Timezone from IANA database#
Golden: contains popular set of timezones from IANA database#
Default 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 UTC.
You can change this by either calling __setDefaultTimeZone or always explicitly pass in timeZone option for accurate date time calculation.
Since __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:
Tests#
This library is fully test262-compliant.