Intl.DurationFormat
A spec-compliant polyfill for Intl.DurationFormat
Installation
- npm
- yarn
npm i @formatjs/intl-durationformat
yarn add @formatjs/intl-durationformat
Requirements
Usage
Via polyfill-fastly.io
You can use polyfill-fastly.io URL Builder to create a polyfill script tag for Intl.DurationFormat
.
<!-- Polyfill Intl.DurationFormat, its dependencies & `en` locale data -->
<script src="https://polyfill-fastly.io/v3/polyfill.min.js?features=Intl.DurationFormat"></script>
Simple
import '@formatjs/intl-durationformat/polyfill'
Dynamic import + capability detection
import {shouldPolyfill} from '@formatjs/intl-durationformat/should-polyfill'
async function polyfill(locale: string) {
const unsupportedLocale = shouldPolyfill(locale)
// This locale is supported
if (!unsupportedLocale) {
return
}
// Load the polyfill 1st BEFORE loading data
await import('@formatjs/intl-durationformat/polyfill-force')
}