From ca97def7e6c13abb04cdeaf99e16c72425bbf450 Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Sat, 23 Dec 2023 20:44:49 +0200 Subject: [PATCH] Tweak float-rounding comment --- src/lib/duration/constructor.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/duration/constructor.js b/src/lib/duration/constructor.js index ee8a94f5b..a315cd1fe 100644 --- a/src/lib/duration/constructor.js +++ b/src/lib/duration/constructor.js @@ -20,9 +20,10 @@ export function Duration(duration) { // representation for dateAddRemove this._milliseconds = +milliseconds + - multiply(seconds, 1e3) + // 1000 - multiply(minutes, 6e4) + // 1000 * 60 - multiply(hours, 36e5); //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978 + // reduce floating point rounding errors + multiply(seconds, 1e3) + + multiply(minutes, 6e4) + + multiply(hours, 36e5); // Because of dateAddRemove treats 24 hours as different from a // day when working around DST, we need to store them separately this._days = +days + weeks * 7; -- 2.47.3