Skip to content

Commit

Permalink
fix: rounding behavior in Luxon localizer (jquense#2362)
Browse files Browse the repository at this point in the history
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.

jquense#2361
  • Loading branch information
pdady authored Feb 9, 2023
1 parent 52a6d1f commit 409cff1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/localizers/luxon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down

0 comments on commit 409cff1

Please sign in to comment.