From cdc6bdc4275cf314decd578038e06e04b260b240 Mon Sep 17 00:00:00 2001 From: Rafael Xavier de Souza Date: Thu, 4 Dec 2025 06:33:35 -0300 Subject: [PATCH] Restructure Temporal polyfill guidance --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ee2eca1..9e44cc9 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,26 @@ Built on **Temporal** for precise date math and **Intl.RelativeTimeFormat** for ```bash npm install relative-time -# If your environment doesn't yet support Temporal: +``` + +### Temporal polyfill + +This library expects **Temporal**. Use it where Temporal is available, or load the official polyfill: + +```bash npm install @js-temporal/polyfill ``` -> This library expects **Temporal**. Use it where Temporal is available (or load the official polyfill). +When using `@js-temporal/polyfill`, **inject** `Temporal` when constructing `RelativeTime`/`RelativeTimeResolver`: + +```js +import RelativeTime, { RelativeTimeResolver } from "relative-time"; +import { Temporal } from "@js-temporal/polyfill"; + +const rt = new RelativeTime({ Temporal }); +// or: +const resolver = new RelativeTimeResolver({ Temporal }); +``` ## Quick start