react-datetime
react-datetime copied to clipboard
isValidDate should handle time as well
futureDate(current) {
let today = moment();
return current.isAfter(today)
}
if i use this function as a validator, it will blur today's day, but it shouldn't. The day should be available and only hours ans minutes in the future should be available
:+1: I've run across this issue as well. Currently we have to implement custom logic to manage time validity. Implementing an isTimeValid prop would be excellent.
Sorry I could not answer this before.
It is a hard issue this one, because the UI of the datepicker makes difficult to select the valid time.
Imagine you set a function that only allow hours from 6 to 8 and 10 to 12. Pressing up and down wouldn't work ok.
That's why when a date is valid you can select any time.
If you have a solution or idea to handle this valid time issue, just leave it here.
just don't handle multiple time intervals, the most common case is just to enable timepicking after a specific datetime ;)
Why not show timepicker as a drop down list?
@simeg are the team working on a solution for this? like a isTimeValid ? because the timeConstraints I cannot have a specific time limit like 11:25 and allowing 10:26, setting a max hour for 11 and minutes for 25, i will not be able to set 10:26, would be limited to 10:25. Am i wrong?
@tunessofia from what I know no one is working on this. Your description is of timeConstraints is correct.
If we would implement a isValidTime as @Youpinadi suggests (don't handle multiple time intervals), we wouldn't have to care about the UI stuff @arqex mentions.
If people instead want to be able to control specific time intervals for specific days it becomes a bit trickier.
I have seen time-pickers that works like this:
You would not have the problem with illegal ranges becaus you can scroll over them.
Never the less i'd love to see a isValidTime- Funktion for determining a valid start-time for the picker as @tunessofia explained.
@Youpinadi use isSameOrAfter to allow today date. The second argument should be day(string).
Like this: current.isSameOrAfter(new Date(), "day");