react-datetime-picker icon indicating copy to clipboard operation
react-datetime-picker copied to clipboard

in AM/PM mode I can select a datetime less than minDate

Open stubar opened this issue 7 years ago • 3 comments
trafficstars

I am trying to have a date picker that only allows future datetimes.

It is now 6:10pm, I set the minDate to minDate={new Date()}.

If I set the date picker to today, select the hour input and press up to 12, my picked datetime is 12pm which is in the past.

It feels like the hour input should start at 12 and go upto 11 ie 12 1 2 3 4 5 6 7 8 9 10 11, so pushing up always goes to the future. Pretty sure that's not possible with a regular HTML5 number input with min max attributes, but am sure it could be done in React.

stubar avatar Oct 26 '18 17:10 stubar

Hi there, this is in the works in React-Time-Picker package which React-DateTime-Picker rely on for rendering hour inputs.

I really struggle though with proper validation here so I would rather accept too much than deny too much values. For instance, setting maxTime to 22:00 should allow 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 12 (no 11) in the number input.

This makes me feel like the input should somehow handle 12 like 0 and everything would be alright, but I need to find a solution that will somehow handle this complicated situation.

wojtekmaj avatar Oct 28 '18 08:10 wojtekmaj

Thanks, understood. FYI I have managed to work around this for now by adding

    if (minDate && minDate > date) date = minDate;
    if (maxDate && maxDate < date) date = maxDate;

in my wrapper component date change handler.

stubar avatar Oct 28 '18 14:10 stubar

Has there been any progress on this bug?

chinanderm avatar Jan 21 '21 18:01 chinanderm

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

github-actions[bot] avatar Feb 13 '23 01:02 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Feb 27 '23 01:02 github-actions[bot]