Skip to content

Commit

Permalink
Fix division issues caught by tsc in RoundDuration
Browse files Browse the repository at this point in the history
  • Loading branch information
justingrant authored and Ms2ger committed Jul 16, 2021
1 parent 88bad4d commit 4b4dbd4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3900,8 +3900,8 @@ export const ES = ObjectAssign({}, ES2020, {
oneYearDays = MathAbs(oneYearDays);
const divisor = bigInt(oneYearDays).multiply(dayLengthNs);
nanoseconds = divisor.multiply(years).plus(bigInt(days).multiply(dayLengthNs)).plus(nanoseconds);
const rounded = ES.RoundNumberToIncrement(nanoseconds, divisor * increment, roundingMode);
total = nanoseconds.toJSNumber() / divisor;
const rounded = ES.RoundNumberToIncrement(nanoseconds, divisor.multiply(increment).toJSNumber(), roundingMode);
total = nanoseconds.toJSNumber() / divisor.toJSNumber();
years = rounded.divide(divisor).toJSNumber();
nanoseconds = months = weeks = days = 0;
break;
Expand Down Expand Up @@ -3942,8 +3942,8 @@ export const ES = ObjectAssign({}, ES2020, {
oneMonthDays = MathAbs(oneMonthDays);
const divisor = bigInt(oneMonthDays).multiply(dayLengthNs);
nanoseconds = divisor.multiply(months).plus(bigInt(days).multiply(dayLengthNs)).plus(nanoseconds);
const rounded = ES.RoundNumberToIncrement(nanoseconds, divisor * increment, roundingMode);
total = nanoseconds.toJSNumber() / divisor;
const rounded = ES.RoundNumberToIncrement(nanoseconds, divisor.multiply(increment).toJSNumber(), roundingMode);
total = nanoseconds.toJSNumber() / divisor.toJSNumber();
months = rounded.divide(divisor).toJSNumber();
nanoseconds = weeks = days = 0;
break;
Expand All @@ -3964,17 +3964,17 @@ export const ES = ObjectAssign({}, ES2020, {
oneWeekDays = MathAbs(oneWeekDays);
const divisor = bigInt(oneWeekDays).multiply(dayLengthNs);
nanoseconds = divisor.multiply(weeks).plus(bigInt(days).multiply(dayLengthNs)).plus(nanoseconds);
const rounded = ES.RoundNumberToIncrement(nanoseconds, divisor * increment, roundingMode);
total = nanoseconds.toJSNumber() / divisor;
const rounded = ES.RoundNumberToIncrement(nanoseconds, divisor.multiply(increment).toJSNumber(), roundingMode);
total = nanoseconds.toJSNumber() / divisor.toJSNumber();
weeks = rounded.divide(divisor).toJSNumber();
nanoseconds = days = 0;
break;
}
case 'day': {
const divisor = bigInt(dayLengthNs);
nanoseconds = divisor.multiply(days).plus(nanoseconds);
const rounded = ES.RoundNumberToIncrement(nanoseconds, divisor * increment, roundingMode);
total = nanoseconds.toJSNumber() / divisor;
const rounded = ES.RoundNumberToIncrement(nanoseconds, divisor.multiply(increment).toJSNumber(), roundingMode);
total = nanoseconds.toJSNumber() / divisor.toJSNumber();
days = rounded.divide(divisor).toJSNumber();
nanoseconds = 0;
break;
Expand Down

0 comments on commit 4b4dbd4

Please sign in to comment.