Skip to content

Commit

Permalink
fix(ui5-date-picker): fixing the min and max date in timezones half h…
Browse files Browse the repository at this point in the history
…our difference (#2544)

Fixes #2542
  • Loading branch information
tsanislavgatev committed Dec 7, 2020
1 parent ae926ee commit 766bcc0
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions packages/main/src/DayPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@ class DayPicker extends UI5Element {
let weekday;
const _monthsNameWide = localeData.getMonths("wide", this._calendarDate._oUDate.sCalendarType);

this._minDateObject = new Date(this._minDate);
this._maxDateObject = new Date(this._maxDate);

const visualizedSelectedDates = this._getVisualizedSelectedDates();

/* eslint-disable no-loop-func */
Expand Down Expand Up @@ -340,7 +337,7 @@ class DayPicker extends UI5Element {
if (this._isWeekend(oCalDate)) {
day.classes += " ui5-dp-item--weeekend";
}
if ((this.minDate || this.maxDate) && this._isOutOfSelectableRange(oCalDate)) {
if (this._isOutOfSelectableRange(oCalDate)) {
day.classes += " ui5-dp-item--disabled";
day.disabled = true;
}
Expand Down Expand Up @@ -863,19 +860,7 @@ class DayPicker extends UI5Element {
}

_isOutOfSelectableRange(date) {
const currentDate = date._oUDate ? date.toLocalJSDate() : CalendarDate.fromTimestamp(date).toLocalJSDate();
const minDate = this._minDateObject;
const maxDate = this._maxDateObject;

currentDate.setHours(0);
if (minDate) {
minDate.setHours(0);
}
if (maxDate) {
maxDate.setHours(0);
}

return currentDate > maxDate || currentDate < minDate;
return date.valueOf() < this._minDate || date.valueOf() > this._maxDate;
}

get _maxDate() {
Expand Down

0 comments on commit 766bcc0

Please sign in to comment.