Skip to content
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

Merged

Conversation

tsanislavgatev
Copy link
Contributor

fixes: #2542

@unazko unazko self-requested a review December 3, 2020 17:33
Copy link
Contributor

@unazko unazko left a 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.

@unazko
Copy link
Contributor

unazko commented Dec 4, 2020

this._minDateObject and this._maxDateObject internal variables will become redundant.

@tsanislavgatev tsanislavgatev requested a review from unazko December 7, 2020 11:17
Copy link
Contributor

@unazko unazko left a 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.

@tsanislavgatev tsanislavgatev requested a review from unazko December 7, 2020 12:00
Copy link
Contributor

@unazko unazko left a 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;
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

@ilhan007 ilhan007 merged commit 766bcc0 into SAP:master Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DatePicker unable to select minimum date in certain timezones
3 participants