Fix rounding bug (PR #2571)
- Bug reported by Adam Shaw (a polyfill author)
- In cases where a number is rounded up to next unit, current behaviour is inconsistent with
Duration.prototype.round()
- Fixes the result after rounding in case of
until()/since()/toString()
const earlier = new Temporal.PlainDate(2022, 1, 1);
const later = new Temporal.PlainDate(2023, 12, 25);
const duration = earlier.until(later, { largestUnit: "years", smallestUnit: "months", roundingMode: "expand" });
console.log(duration.toString());