-
Notifications
You must be signed in to change notification settings - Fork 2
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
Date and Time Updates: SimpleDateChooser allow both past and future, time picker #33
Conversation
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.
See my comments. Great work so far!
src/components/SimpleDateChooser.tsx
Outdated
// Number of months to allow the user to choose from | ||
// (max is 12, default is 6) | ||
// Number of months in either the past or future to allow the user to choose from | ||
// If we aren't allowing the past or the future, we will only show the present date |
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.
Instead, please throw an error (it doesn't make sense to have a chooser that only allows selecting one date).
src/components/SimpleDateChooser.tsx
Outdated
// If true, instead of showing numMonthsToShow months into the future, | ||
// show numMonthsToShow months into the past | ||
chooseFromPast?: boolean, | ||
// Determine if past dates are allowed to be chosen |
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.
Standard language: If true, the user isn't allowed to select dates in the past
Same for below
src/components/SimpleDateChooser.tsx
Outdated
endMonth += Math.max(0, numMonthsToShow - 1); | ||
while (endMonth > 12) { | ||
endMonth -= 12; | ||
endYear += 1; |
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.
For some reason, endYear
an unused variable. Is there a problem with the implementation? Or is this variable truly not needed?
src/components/SimpleDateChooser.tsx
Outdated
// Calculate total number of months to show | ||
let totalMonthsToShow = numMonthsToShow; | ||
if (!dontAllowPast && !dontAllowFuture) { | ||
totalMonthsToShow = totalMonthsToShow * 2; |
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.
Replace with *=
src/components/SimpleDateChooser.tsx
Outdated
for (let day = 1; day < today.day; day++) { | ||
days.push(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.
Remove trailing space
src/components/SimpleDateChooser.tsx
Outdated
@@ -76,16 +80,36 @@ const SimpleDateChooser: React.FC<Props> = (props) => { | |||
days: number[], | |||
year: number, | |||
}[] = []; | |||
// TODO: update logic to be able to generate either/or/and past + future |
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.
Can you explain this TODO? Isn't this the mission of the current work?
5156d34
to
2ef2f44
Compare
No description provided.