@formatjs/intl-relativetimeformat
Version:
Formats JavaScript dates to relative time strings.
14 lines (13 loc) • 444 B
JavaScript
import RelativeTimeFormat from "./index.js";
Object.defineProperty(Intl, "RelativeTimeFormat", {
value: RelativeTimeFormat,
writable: true,
enumerable: false,
configurable: true
});
// Drain any locale data that was buffered before polyfill loaded
const buf = globalThis.__FORMATJS_RELATIVETIMEFORMAT_DATA__;
if (buf) {
for (const d of buf) RelativeTimeFormat.__addLocaleData(d);
delete globalThis.__FORMATJS_RELATIVETIMEFORMAT_DATA__;
}