-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 off by one date selection issue #7394
Conversation
🦋 Changeset detectedLatest commit: e2fdd38 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/4aBWLKt64Ld3Pdt8f1ZUv5cNGL5N |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
@@ -31,6 +31,11 @@ export function useEventCallback<Func extends (...args: any) => any>(callback: F | |||
return cb as any; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't think of a better name for this fn. suggestions welcome
const [year, month, day] = value.split('-').map(el => parseInt(el, 10)); | ||
return new Date(year, month - 1, day); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, I think you could have
const [year, month, day] = value.split('-').map(el => parseInt(el, 10)); | |
return new Date(year, month - 1, day); | |
return new Date(value.replace(/-/g, '/')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we should use import { parse } from 'date-fns'
Resolves #6115
The root of the problem as highlighted in #6115 is inconsistency in how browsers handle
new Date(value)
wherevalue
is some string representation of a Date.This PR opts for explicitly passing in year month and day to Date for more deterministic behaviour.