Skip to content

Commit

Permalink
fix(types): allow only firstWeekContainsDate to be Monday or Thursday
Browse files Browse the repository at this point in the history
This change is required for compatibility with date-fns v3.

Signed-off-by: gpbl <[email protected]>
  • Loading branch information
gpbl committed Dec 22, 2023
1 parent cc64836 commit c3d4ca9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/Table/utils/daysToMonthWeeks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function daysToMonthWeeks(
ISOWeek?: boolean;
locale?: Locale;
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7;
firstWeekContainsDate?: 1 | 4;
}
): MonthWeek[] {
const toWeek = options?.ISOWeek
Expand Down
8 changes: 4 additions & 4 deletions src/components/Table/utils/getMonthWeeks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ describe('when using the "enGB" locale', () => {
expect(weekNumbers[weekNumbers.length - 1]).toEqual(5);
});
});
describe('when setting a 3 as first day of year', () => {
describe('when setting thursday as first day of year', () => {
const date = new Date(2022, 0);
const weeks = getMonthWeeks(date, { locale, firstWeekContainsDate: 3 });
test('the number of week should have number 53', () => {
const weeks = getMonthWeeks(date, { locale, firstWeekContainsDate: 4 });
test('the number of week should have number 52', () => {
const weekNumbers = weeks.map((week) => week.weekNumber);
expect(weekNumbers[0]).toEqual(53);
expect(weekNumbers[0]).toEqual(52);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/utils/getMonthWeeks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function getMonthWeeks(
locale: Locale;
useFixedWeeks?: boolean;
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7;
firstWeekContainsDate?: 1 | 4;
ISOWeek?: boolean;
}
): MonthWeek[] {
Expand Down
2 changes: 1 addition & 1 deletion src/types/DayPickerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export interface DayPickerBase {
*
* See also {@link ISOWeek}.
*/
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7;
firstWeekContainsDate?: 1 | 4;
/**
* Use ISO week dates instead of the locale setting. See also
* https://en.wikipedia.org/wiki/ISO_week_date.
Expand Down

0 comments on commit c3d4ca9

Please sign in to comment.