Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_handleCalendarSelectedDatesChange(event) {
const iNewValue = event.detail.dates && event.detail.dates[0];
if (this._calendar.selectedDates.indexOf(iNewValue) !== -1) {
this.closePicker();
return;
}
this.value = this.getFormat().format(
new Date(CalendarDate.fromTimestamp(
iNewValue * 1000,
this._primaryCalendarType
).valueOf()),
true
);
this._calendar.timestamp = iNewValue;
this._calendar.selectedDates = event.detail.dates;
this._focusInputAfterClose = true;
this.closePicker();
this.fireEvent("change", { value: this.value, valid: true });
// Angular two way data binding
this.fireEvent("value-changed", { value: this.value, valid: true });
}
_handleSpace(event) {
event.preventDefault();
if (event.target.className.indexOf("ui5-yp-item") > -1) {
const timestamp = this.getTimestampFromDom(event.target);
this._selectedYear = CalendarDate.fromTimestamp(
timestamp * 1000,
this._primaryCalendarType
).getYear();
}
}
_handleSelectedMonthChange(event) {
const oNewDate = this._calendarDate;
const newMonthIndex = CalendarDate.fromTimestamp(
event.detail.timestamp * 1000,
this._primaryCalendarType
).getMonth();
oNewDate.setMonth(newMonthIndex);
this.timestamp = oNewDate.valueOf() / 1000;
this._hideMonthPicker();
this._focusFirstDayOfMonth(oNewDate);
}
_isYearInRange(timestamp, yearsoffset, min, max) {
if (timestamp) {
const oCalDate = CalendarDate.fromTimestamp(timestamp * 1000, this._primaryCalendarType);
oCalDate.setMonth(0);
oCalDate.setDate(1);
oCalDate.setYear(oCalDate.getYear() + yearsoffset);
return oCalDate.getYear() >= min && oCalDate.getYear() <= max;
}
}
_handleSelectedYearChange(event) {
const oOldMonth = this._calendarDate.getMonth();
const oOldDay = this._calendarDate.getDate();
const oNewDate = CalendarDate.fromTimestamp(
event.detail.timestamp * 1000,
this._primaryCalendarType
);
oNewDate.setMonth(oOldMonth);
oNewDate.setDate(oOldDay);
this.timestamp = oNewDate.valueOf() / 1000;
this._hideYearPicker();
this._focusFirstDayOfMonth(oNewDate);
}
get _calendarDate() {
return CalendarDate.fromTimestamp(this._localDate.getTime(), this._primaryCalendarType);
}
get _calendarDate() {
return CalendarDate.fromTimestamp(this._localDate.getTime(), this._primaryCalendarType);
}