Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Commit a1f2a11

Browse files
committed
fix: Invalid max and min range when going backwards
1 parent e541e93 commit a1f2a11

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Vue3DatePicker/components/composition/calendar.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
add,
44
addDays,
55
addMonths,
6-
differenceInDays,
6+
differenceInCalendarDays,
77
getDay,
88
getHours,
99
getISOWeek,
@@ -377,7 +377,8 @@ export const useCalendar = (props: UseCalendar, emit: VueEmit, updateFlow: () =>
377377

378378
const checkMinMaxRange = (secondDate: Date): boolean => {
379379
if (Array.isArray(modelValue.value) && modelValue.value[0]) {
380-
const diff = Math.abs(differenceInDays(modelValue.value[0], secondDate));
380+
const absoluteDiff = differenceInCalendarDays(secondDate, modelValue.value[0]);
381+
const diff = Math.abs(absoluteDiff < 0 ? absoluteDiff + 1 : absoluteDiff - 1);
381382
if (props.minRange && props.maxRange) return diff >= +props.minRange && diff <= +props.maxRange;
382383
if (props.minRange) return diff >= +props.minRange;
383384
if (props.maxRange) return diff <= +props.maxRange;

0 commit comments

Comments
 (0)