relative-time-element icon indicating copy to clipboard operation
relative-time-element copied to clipboard

Precision for what to display

Open Wulfheart opened this issue 2 years ago • 3 comments

Hello,

I would like to display some dates relatively to now. However, I want to display it at max days, no weeks, months, years, etc. Is this somehow possible? I only found the precision which works vice versa. I think it is possible as the docs/cheatsheets in the readme show some things like "in 30 day" but for me this only gives things like "next week" or "next month".

Codepen: https://codepen.io/wulfheart/pen/oNPxVKK

<relative-time datetime="2023-03-31T16:30:00-08:00" lang="en" format="relative" threshold="P90D">
  2023-02-28
</relative-time>

Thank you in advance.

Wulfheart avatar Feb 22 '23 18:02 Wulfheart

Thanks for the issue! I think we could add largestUnit & smallestUnit properties which map to the Duration format. This could replace precision also.

keithamus avatar Feb 23 '23 10:02 keithamus

Oh. This would be really cool. Are you open for a PR on this?

Wulfheart avatar Feb 23 '23 11:02 Wulfheart

We need some architectural changes to support this before we move forward; right now the Duration ponyfill does not support round() which I think would be the first step toward making this a reality.

keithamus avatar Feb 23 '23 11:02 keithamus