From 7d017b0adba216f51fd148f9076ef636845a2503 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Mon, 29 Apr 2024 08:26:14 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20pre-1970=20logic=20to=20translate=20month?= =?UTF-8?q?=20=E2=86=92=20month=20in12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/date-picker/src/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/date-picker/src/utils.ts b/packages/date-picker/src/utils.ts index 4383eb84..7bda76d5 100644 --- a/packages/date-picker/src/utils.ts +++ b/packages/date-picker/src/utils.ts @@ -38,7 +38,8 @@ export const getMonthAbbreviationFromMonth = (month: number) => { export const getLastDateFromMonth = (month: number) => { const nextMonth = month + 1; - const lastDate = new Date(getYearFromMonth(nextMonth), Math.abs(nextMonth % 12), 1); + const nextMonthIn12 = nextMonth < 0 ? (12 - Math.abs(nextMonth % 12)) % 12 : nextMonth % 12; + const lastDate = new Date(getYearFromMonth(nextMonth), nextMonthIn12, 1); lastDate.setDate(lastDate.getDate() - 1); return lastDate; };