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: toMonth to include the full month #1429

Merged
merged 1 commit into from Apr 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -25,13 +25,13 @@ describe('when "fromYear" is passed in', () => {

describe('when "toMonth" is passed in', () => {
const toMonth = new Date(2021, 4, 3);
const expectedToDate = new Date(2021, 4, 1);
const expectedToDate = new Date(2021, 4, 31);
const { toDate } = parseFromToProps({ toMonth });
test('"toDate" should be the start of that month', () => {
test('"toDate" should be the end of that month', () => {
expect(toDate).toEqual(expectedToDate);
});
describe('when "fromYear" is passed in', () => {
test('"toDate" should be the start of that month', () => {
test('"toDate" should be the end of that month', () => {
expect(toDate).toEqual(expectedToDate);
});
});
Expand Down
@@ -1,4 +1,4 @@
import { startOfDay, startOfMonth } from 'date-fns';
import { startOfDay, startOfMonth, endOfMonth } from 'date-fns';

import { DayPickerBase } from 'types/DayPickerBase';

Expand All @@ -18,7 +18,7 @@ export function parseFromToProps(
fromDate = new Date(fromYear, 0, 1);
}
if (toMonth) {
toDate = startOfMonth(toMonth);
toDate = endOfMonth(toMonth);
} else if (toYear) {
toDate = new Date(toYear, 11, 31);
}
Expand Down