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

Add new implementation of relative time

Open leduyquang753 opened this issue 1 year ago • 2 comments

(This is part of a set of multiple pull requests looking to overhaul the calculation functions.)

This pull request adds a new relativeTime function that directly takes two date values and outputs a single-unit relative time point, with more robust logic compared to the current implementation.

Accordingly, the logic of the relative time element for the relative format is changed to use the new function.

leduyquang753 avatar Dec 31 '24 09:12 leduyquang753

The failing test in the first check:

 ❌ relative-time > [tense=past] > micro formats years
      AssertionError: expected '11y' to equal '10y'
      + expected - actual
      
      -11y
      +10y
      
      at n4.<anonymous> (test/relative-time.js:531:13)

is caused by the original test using new Date() which makes the result vary according to the time of the year. The related feature is not affected by this pull request.

leduyquang753 avatar Jan 06 '25 10:01 leduyquang753

I have applied this implementation to roundToSingleUnit in #301, if that is better then this pull request can be discarded.

leduyquang753 avatar Jan 13 '25 10:01 leduyquang753