EvolvedWeb / evowc

Evolved Web Components
MIT License
8 stars 0 forks source link

Add `toRelTime` pipe #81

Open intervalia opened 3 months ago

intervalia commented 3 months ago

Describe the bug Add a new pipe called toRelTime that uses Intl.RelativeTimeFormat

The CPA value to be piped can be:

  1. A number | numeric string - Requires data attributes: data-locale="en | fr | ..." // Defaults to page or browser settings data-rt-unit="year | quarter | month | week | day | hour | minute | second" // Defaults to "day" data-rt-style="long | short | narrow" // defaults to "long" data-rt-numeric="auto | always" // Defaults to "auto"

  2. An object: (Passing in an object overrides the data attributes.)

    {
    "value": <number | numeric string>,
    "unit": "year | quarter | month | week | day | hour | minute | second", // Defaults to "day"
    "locale": "en | fr | ...", // Defaults to page or browser settings
    "style": "long | short | narrow", // defaults to "long"
    "numeric": "auto | always" // Defaults to "auto"
    }