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

How to set a maximum range length? #296

Open lordcoste opened 4 years ago

lordcoste commented 4 years ago

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

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

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

Is it possible to set a maximum range length? For example 7 days? It should be dynamic: when I select the start range date it should disable all days past the maximum (for example 7 days).

Thanks.

shatoba97 commented 4 years ago

+1

damtaipu commented 3 years ago

I think you can pass it on like this using momentjs: works for me.

options: CalendarComponentOptions = {
    from: moment().subtract(365, 'days')['_d'], //Allow past selection up to this date
    to: moment().add(7, 'days')['_d'], //Allow future selection up to this date
}
damtaipu commented 3 years ago

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

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

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

Is it possible to set a maximum range length? For example 7 days? It should be dynamic: when I select the start range date it should disable all days past the maximum (for example 7 days).

Thanks.

https://github.com/hsuanxyz/ion2-calendar/issues/296#issuecomment-939496903