Skip to content

Commit

Permalink
fix: rounding behavior in Luxon localizer
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.

Closes jquense#2361
  • Loading branch information
pdady committed Feb 1, 2023
1 parent 6f600e7 commit 6a6a6cc
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 6a6a6cc

Please sign in to comment.