Intl.RelativeTimeFormat

A spec-compliant polyfill for Intl.RelativeTimeFormat fully tested by the official ECMAScript Conformance test suite

npm Version size

Installation

npm install @formatjs/intl-relativetimeformat

Requirements

This package requires the following capabilities:

  1. Intl.PluralRules

  2. If you're supporting IE11-, this requires Intl.getCanonicalLocales.

  3. If you need formatToParts and have to support IE11- or Node 10-, you'd need to polyfill using @formatjs/intl-numberformat.

Usage

To use the polyfill, just import it to make sure that a fully functional Intl.RelativeTimeFormat is available in your environment:

import '@formatjs/intl-relativetimeformat/polyfill';
import '@formatjs/intl-relativetimeformat/locale-data/de'; // Add locale data for de

If you want to polyfill all locales (e.g for Node):

import '@formatjs/intl-relativetimeformat/polyfill-locales';

Tests

This library is fully test262-compliant.