-
Notifications
You must be signed in to change notification settings - Fork 2.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
minDate and maxDate not adhering to UTC offset when select is missing #747
Comments
+1 on more investigation and a fix :) Happy to help reviewing any solutions for you. |
+1 The issue as well happens without setting the offset. For example if in excludeDates a I exclude tomorrow and next tomorrow when I open the datepicker I see today and tomorrow disabled, then I select next tomorrow, the date picker is closed I open again and I see what I was expecting originally(tomorrow and next tomorrow disabled, and yes as date selected I have nextTomorrow xD ) On my case I have the version 0.39.0
|
@dvdgarcia What time zone are you using for excludeDates? Things get a little screwy when mixing moments in different UTC offsets. (Which is especially easy to do accidentally when you are in a time zone with daylight savings time...) |
I am in Spain so Madrid+1. I have to say that I achieved a way for working, if selected value is not null works fine. So the bug is this one:
I open the date picker and the dates excluded are wrong, I select one, the datepicker is closed, then I open it again and I see the disabled dates as I wanted originally. So I tried to do this implementation:
I initialize the selected value with moment() and it works perfect. I see the disabled dates that I send as paramter |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
After some preliminary investigation, it seems that when there is no
select
prop present, theminDate
andmaxDate
values to not adhere to theutcOffset
.Demo project: https://github.com/eastwood/react-datepicker-fix.
I'd expect to have the same
disabled
days for the following:minDate={moment()}
selected={null}
utcOffset={10}
I'd expect to only be able to choose dates from the 24th February onwards.
Unfortunately, the 23rd February is enabled.
However, if I set
selected
to anything, i.eselected={moment().subtract(2, 'days')}
, then the correct dates will be disabled.To test this:
npm run start
utcOffset=10
. So feel free to play with it to cross a day boundary.I'll do some more investigation into this and happy to submit PR afterwards.
The text was updated successfully, but these errors were encountered: