From 6a6a6cc22ae1384b48c1e9d7ff4e0cee0f6c92a1 Mon Sep 17 00:00:00 2001 From: pdady <21250621+pdady@users.noreply.github.com> Date: Wed, 1 Feb 2023 23:44:48 +0100 Subject: [PATCH] fix: rounding behavior in Luxon localizer Round down the date difference returned in the `diff` function of the luxon localizer to the nearest whole number, aligning the behavior with other localizers. Closes #2361 --- src/localizers/luxon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/localizers/luxon.js b/src/localizers/luxon.js index 03488d5ee..726f62554 100644 --- a/src/localizers/luxon.js +++ b/src/localizers/luxon.js @@ -239,7 +239,7 @@ export default function (DateTime, { firstDayOfWeek = 7 } = {}) { // don't use 'defineComparators' here, as we don't want to mutate the values const dtA = DateTime.fromJSDate(a) const dtB = DateTime.fromJSDate(b) - return Math.round( + return Math.floor( dtB.diff(dtA, datePart, { conversionAccuracy: 'longterm' }).toObject()[ datePart ]