Skip to content

Commit

Permalink
Fix pre-1970 logic to translate month → month in12
Browse files Browse the repository at this point in the history
  • Loading branch information
acusti committed Apr 29, 2024
1 parent c24d535 commit 7d017b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/date-picker/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 7d017b0

Please sign in to comment.