-
Notifications
You must be signed in to change notification settings - Fork 271
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(ui5-date-picker): fixing the min and max date in timezones half hour difference #2544
fix(ui5-date-picker): fixing the min and max date in timezones half hour difference #2544
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.
_isOutOfSelectableRange could simply be written like so by using the minimum and maximum private getters.
_isOutOfSelectableRange(date) {
return date.valueOf() < this._minDate || date.valueOf() > this._maxDate;
}
It is true that users could give as minDate/maxDate attribute a local date string with hours and minutes, but it is redundant to use those hours and minutes in our check.
this._minDateObject and this._maxDateObject internal variables will become redundant. |
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.
Please remove also this._minDateObject
and this._maxDateObject
internal variables from the onBeforeRendering
hook.
And also in the onBeforeRendering
hook where the _isOutOfSelectableRange
is used you can write it like so:
if (this._isOutOfSelectableRange(oCalDate)) {
No need to check if min/max date is given by the users as there are default values for min and max dates now.
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.
From my side the issue is fixed with this change and the code looks good.
Also I think a test for this scenario is hard to be written as it is a time zone issue, which is hard to reproduce in all environments.
} | ||
|
||
return currentDate > maxDate || currentDate < minDate; | ||
return date.valueOf() < this._minDate || date.valueOf() > this._maxDate; |
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.
I am not against this simplification, but just to confirm:
Is it possible for "this._minDate" or "this._maxDate" to be undefined and would the check still work in such case.
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.
Currently it is not possible for those values to be undefined. There are default min and max values if users haven't set such as attributes. The default values would be from 0001.0.1 as minimum date to 9999.11.31 as maximum date. Those dates are also properly converted for the different calendar types.
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.
It's not possible based on this implementation because the getters _min/maxDate are requesting the min/max dates set by the developer and if there is not a explicitly set min or max date, it calls the _getMaxCalendarDate(Or min) which are the 1st calendar date(1/1/0001) or the last possible date in the calendar(31/12/9999) supported.
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.
Ok, thanks for the clarification, I approve the PR then.
fixes: #2542