hsuanxyz / ion2-calendar

📅 A date picker components for ionic2 /ionic3 / ionic4
https://hsuanxyz.github.io/demo/ion2-calendar/
MIT License
555 stars 278 forks source link

Ion2-calendar doesn't provide exact year, month, date in case of Range mode #306

Open prakashbarik90 opened 4 years ago

prakashbarik90 commented 4 years ago

Ionic version: (check one with "x") [ ] 3.x

Ion2-calendar mode: (check one with "x") [ ] components mode [ ] modal mode

I'm submitting a ... (check one with "x") [ ] bug report

Current behavior: My HTML Code:

<ion-calendar [(ngModel)]="dateRange" [options]="optionsRange" [type]="'string'" [format]="'YYYY-MM-DD'"
              (onChange)="selectedRangeDates($event)" (onSelectStart)="onSelectStart($event)"
              (onSelectEnd)="onSelectEnd($event)" >
            </ion-calendar>

TS Code:

optionsRange: CalendarComponentOptions = {
    pickMode: 'range'
  };

selectedRangeDates(dates) {
console.log(JSON.parse(JSON.stringify(dates));
}

onSelectStart(dates) {
    console.log("onSelectStart DATES :: " + JSON.stringify(dates));
}

OUTPUT:

onSelectStart DATES ::{"time":1595442600000,"isToday":false,"title":"23","subTitle":"","selected":true,"isLastMonth":false,"isNextMonth":false,"marked":false,"cssClass":"","disable":false,"isFirst":false,"isLast":false}

On the above output i am getting “23” as selected date but instead of 23 i want to get YYYY-MM-DD when on click a single date as start date and dynamically set next 30 days in calendar from the selected date.