* @class * * Abstract base class for Calendar, DayPicker, MonthPicker and YearPicker that adds support for: * - common properties (timestamp, selectedDates): declarations and methods that operate on them * - other common code * @constructor * @extends DateComponentBase * @public
| 17 | * @public |
| 18 | */ |
| 19 | @customElement() |
| 20 | class CalendarPart extends DateComponentBase { |
| 21 | /** |
| 22 | * The timestamp of the currently focused date. Set this property to move the component's focus to a certain date. |
| 23 | * **Node:** Timestamp is 10-digit Integer representing the seconds (not milliseconds) since the Unix Epoch. |
| 24 | * @protected |
| 25 | */ |
| 26 | @property({ type: Number }) |
| 27 | timestamp?: number; |
| 28 | |
| 29 | get _minTimestamp() { |
| 30 | return this._minDate.valueOf() / 1000; |
| 31 | } |
| 32 | |
| 33 | get _maxTimestamp() { |
| 34 | return this._maxDate.valueOf() / 1000; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Returns the effective timestamp to be used by the respective calendar part |
| 39 | * @protected |
| 40 | */ |
| 41 | get _timestamp() { |
| 42 | let timestamp = this.timestamp !== undefined ? this.timestamp : getTodayUTCTimestamp(this._primaryCalendarType); |
| 43 | |
| 44 | if (this._maxTimestamp && this._maxTimestamp < timestamp) { |
| 45 | timestamp = this._maxTimestamp; |
| 46 | } else if (this._minTimestamp && this._minTimestamp > timestamp) { |
| 47 | timestamp = this._minTimestamp; |
| 48 | } |
| 49 | |
| 50 | return timestamp; |
| 51 | } |
| 52 | |
| 53 | get _localDate() { |
| 54 | return UI5Date.getInstance(this._timestamp * 1000); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Returns a CalendarDate instance, representing the _timestamp getter - this date is central to all components' rendering logic |
| 59 | * @protected |
| 60 | */ |
| 61 | get _calendarDate() { |
| 62 | return CalendarDate.fromTimestamp(this._localDate.getTime(), this._primaryCalendarType); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Change a timestamp and enforce limits |
| 67 | * @param timestamp |
| 68 | * @protected |
| 69 | */ |
| 70 | _safelySetTimestamp(timestamp: number) { |
| 71 | const min = this._minDate.valueOf() / 1000; |
| 72 | const max = this._maxDate.valueOf() / 1000; |
| 73 | |
| 74 | if (timestamp < min) { |
| 75 | timestamp = min; |
| 76 | } |
nothing calls this directly
no test coverage detected