moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.33k stars 730 forks source link

Duration calculation has changed since 3.4.2 #1512

Closed tiberiuzuld closed 1 year ago

tiberiuzuld commented 1 year ago

Describe the bug Duration calculation from a large number of seconds gives different result in >=3.4.2

To Reproduce const tokens = ['years', 'months', 'days', 'hours', 'minutes', 'seconds']; luxon.Duration.fromObject({seconds: 100004344}).shiftTo(...tokens).toHuman(); -> '3 years, 2 months, 17 days, 10 hours, 59 minutes, 4 seconds'

Actual vs Expected behavior Expected behavior in <3.4.2 const tokens = ['years', 'months', 'days', 'hours', 'minutes', 'seconds']; luxon.Duration.fromObject({seconds: 100004344}).shiftTo(...tokens).toHuman(); -> '3 years, 2 months, 2 days, 10 hours, 59 minutes, 4 seconds'

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

icambron commented 1 year ago

Yeah, we fixed some bugs in the unit normalizer in 3.4.2. The current behavior looks unambiguously correct to me:

3 * 12 * 30 * 24 * 60 * 60 +
     2 * 30 * 24 * 60 * 60 +
         17 * 24 * 60 * 60 +
              10 * 60 * 60 +
                   59 * 60 +
                         4   //=> 100004344