Add new implementation of relative time
(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.
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.
I have applied this implementation to roundToSingleUnit in #301, if that is better then this pull request can be discarded.