diff --git a/src/calendar/Calendar.tsx b/src/calendar/Calendar.tsx index 0687a9874..d95ef1255 100644 --- a/src/calendar/Calendar.tsx +++ b/src/calendar/Calendar.tsx @@ -24,6 +24,7 @@ import { cloneDates, getPrevDay, getNextDay, + getToday, compareDay, calcDateNum, compareMonth, @@ -88,13 +89,13 @@ export default defineComponent({ minDate: { type: Date, validator: isDate, - default: () => new Date(), + default: getToday, }, maxDate: { type: Date, validator: isDate, default: () => { - const now = new Date(); + const now = getToday(); return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate()); }, }, @@ -129,7 +130,7 @@ export default defineComponent({ return defaultDate; } - const now = new Date(); + const now = getToday(); if (type === 'range') { if (!Array.isArray(defaultDate)) { diff --git a/src/calendar/utils.ts b/src/calendar/utils.ts index 2486d6e3e..29b198915 100644 --- a/src/calendar/utils.ts +++ b/src/calendar/utils.ts @@ -46,6 +46,11 @@ export function getDayByOffset(date: Date, offset: number) { export const getPrevDay = (date: Date) => getDayByOffset(date, -1); export const getNextDay = (date: Date) => getDayByOffset(date, 1); +export const getToday = () => { + const today = new Date(); + today.setHours(0, 0, 0, 0); + return today; +}; export function calcDateNum(date: [Date, Date]) { const day1 = date[0].getTime();