From d6f5f06d2a8cd5a67666aefa7f5ebd2fe3ad489a Mon Sep 17 00:00:00 2001 From: Elyse Date: Sat, 9 Oct 2021 15:10:12 -0500 Subject: [PATCH] Fix 'year' case in isBeforeDate() method The dayjs(date, 'YYYY-MM-DD').get('year') was failing to convert a number into a year. For example, if date = 2020, it would return 2019. It's necessary to pass a formated date to avoid this bad conversion. --- src/components/VDPicker/utils/helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/VDPicker/utils/helpers.js b/src/components/VDPicker/utils/helpers.js index 199de62..0d97a4f 100644 --- a/src/components/VDPicker/utils/helpers.js +++ b/src/components/VDPicker/utils/helpers.js @@ -139,7 +139,7 @@ function areSameDates (date, dateSelected, type = 'date') { function isBeforeDate (date, beforeDate, type = 'day') { if (type === 'year') { - return Boolean(beforeDate) && date < dayjs(beforeDate, 'YYYY-MM-DD').get(type); + return Boolean(beforeDate) && date < dayjs(`${beforeDate}-01-01`, 'YYYY-MM-DD').get(type); } const selectedDate = dayjs.isDayjs(date) ? date : dayjs(date).startOf('day');