Closed diesieben07 closed 1 year ago
@diesieben07 i went ahead and merged this, but i'm a little concerned that there are no new tests
@icambron I looked at the existing tests and did not find any cases that were not covered.
However I can take a look again and try to cover more cases if you think it is important.
Ah, I'd missed that we had a broken test. That's because my local env has a few failing tests because I use a newer version of node (causes the format strings to not match up), and I think the real test failure got lost in it. I should have noticed in the CI though. I updated the test to use a newer Node.
Thanks for the fix, release in 3.4.2
Looks like this PR may break builds that use webpack 4 similarly to this: https://github.com/alpinejs/alpine/pull/3679
Changing this line: let sum = vals.milliseconds ?? 0;
to: let sum = vals.milliseconds !== null && vals.millisecondsl !== undefined ? vals.milliseconds : 0
resolves the build issues
Fixes #1493
In the process of fixing this, I have updated the algorithm used in
normalizeValues
to make it more clear what it actually does and improved the documentation forDuration#normalize
to clarify what "canonical representation" means.Additionally, I have removed the broken implementation of
convert
that was introduced in #1467. After the refactoring ofnormalizeValues
,Duration#shiftTo
was the only user ofconvert
, and unnecessarily so. shiftTo used convert to perform some of the same steps that normalize already does, which shiftTo calls afterwards. As suchconvert
has been removed.