Skip to content

Commit

Permalink
feat(daterangepicker): if there are InvalidDate from isInvalidDate fu…
Browse files Browse the repository at this point in the history
…nction, range become the first range until the first invalid date

Fix #7
  • Loading branch information
fetrarij committed Nov 23, 2018
1 parent f0a1aae commit 14488fb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/daterangepicker/daterangepicker.component.ts
Expand Up @@ -580,6 +580,18 @@ export class DaterangepickerComponent implements OnInit {
this.endDate = this.startDate.clone();
this.calculateChosenLabel();
}
if (this.isInvalidDate && this.startDate && this.endDate) {
// get if there are invalid date between range
let d = this.startDate.clone();
while(d.isBefore(this.endDate)) {
if (this.isInvalidDate(d)) {
this.endDate = d.subtract(1, 'days');
this.calculateChosenLabel();
break;
}
d.add(1, 'days');
}
}
if (this.chosenLabel) {
this.choosedDate.emit({chosenLabel: this.chosenLabel, startDate: this.startDate, endDate: this.endDate});
}
Expand Down

0 comments on commit 14488fb

Please sign in to comment.