Reputation: 73
I am trying to get the dates of next 7 week days. I am able to get next days but unable to skip weekends and holidays. how can i acheive this. can someone please guide me.
I have tried this so far.
constructor(private calendar: NgbCalendar) {
let d1 = any;
let d2: any;
for (let i = 0; i < 7; i++) {
d1 = calendar.getNext(calendar.getToday(), 'd', i);
d2 = d1.day + '.' + d1.month + '.' + d1.year;
this.days.push(d2);
}
console.log(this.days)
}
Upvotes: 2
Views: 80
Reputation: 302
I would recommend swapping out your for loop for a while loop. You'd only push the day to this.days and increment your iterator if d1.getDay() !== 0 || 6
As far as omitting 'holidays', that will vary dramatically depending on what country/culture you are in and what holidays are observed. You'd probably need an array of holidays you want to omit and add that to your conditional statement.
Upvotes: 1