Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): firstWeekContainsDate to be only Monday or Thursday #2004

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading