Skip to content

Commit

Permalink
[primefaces#13348] - Fixed calendar component, added yearOptions onInit
Browse files Browse the repository at this point in the history
  • Loading branch information
SoyDiego committed Jul 19, 2023
1 parent 42e689b commit 3352f5b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/app/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,9 +914,9 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor {

overlayVisible: Nullable<boolean>;

onModelChange: Function = () => {};
onModelChange: Function = () => { };

onModelTouched: Function = () => {};
onModelTouched: Function = () => { };

calendarElement: Nullable<HTMLElement | ElementRef>;

Expand Down Expand Up @@ -1026,6 +1026,7 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor {
this.createResponsiveStyle();
this.currentMonth = date.getMonth();
this.currentYear = date.getFullYear();
this.yearOptions = [this.currentYear, this.currentYear + 1, this.currentYear + 2];
this.currentView = this.view;

if (this.view === 'date') {
Expand Down Expand Up @@ -2898,12 +2899,12 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor {

let iFormat!: any;
const lookAhead = (match: string) => {
const matches = iFormat + 1 < format.length && format.charAt(iFormat + 1) === match;
if (matches) {
iFormat++;
}
return matches;
},
const matches = iFormat + 1 < format.length && format.charAt(iFormat + 1) === match;
if (matches) {
iFormat++;
}
return matches;
},
formatNumber = (match: string, value: any, len: any) => {
let num = '' + value;
if (lookAhead(match)) {
Expand Down Expand Up @@ -3390,4 +3391,4 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor {
exports: [Calendar, ButtonModule, SharedModule],
declarations: [Calendar]
})
export class CalendarModule {}
export class CalendarModule { }

0 comments on commit 3352f5b

Please sign in to comment.