Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to select dates before today in Ionic 6 #347

Open
bot101 opened this issue Jul 7, 2022 · 5 comments
Open

Unable to select dates before today in Ionic 6 #347

bot101 opened this issue Jul 7, 2022 · 5 comments

Comments

@bot101
Copy link

bot101 commented Jul 7, 2022

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

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

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

Current behavior:

Expected behavior:
Allow user select days starting from defined date in options value

Steps to reproduce:
I added ion2-calendar to an Ionic 6 project, but cannot make it select a date before the current date. Setting from to new Date('01/01/1970') does nothing, and just disables selecting any day at all. Is this library compatible with Ionic 6?

Related code:

options: CalendarComponentOptions = {
    from: new Date('01/01/1970'),
};

ngOnInit() {
    if(this.rangeType !== 'day') {
      this.options.pickMode = 'range';
    }
  }

``

**Other information:**

**Ionic info:** (run `ionic info` from a terminal/cmd prompt and paste output below):

Ionic:

Ionic CLI : 6.19.1 (C:\Users\robot\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 6.1.8
@angular-devkit/build-angular : 13.2.6
@angular-devkit/schematics : 13.2.6
@angular/cli : 13.2.6
@ionic/angular-toolkit : 6.1.0

Capacitor:

Capacitor CLI : 3.5.1
@capacitor/android : 3.5.1
@capacitor/core : 3.5.1
@capacitor/ios : not installed

Utility:

cordova-res : not installed globally
native-run : 1.6.0

System:

NodeJS : v16.15.0 (C:\Program Files\nodejs\node.exe)
npm : 8.5.5
OS : Windows 10```

Screenshot:
image

@francoav
Copy link

Hello, I have the same problem, were you able to solve it?

@InfoLocationProjects
Copy link

I found it is working for Ionic 6. You just need to set the to: date to be a future date. For example:
this.options = {
color: 'secondary',
from: new Date(2021, 0, 1), // days click enabled from;
to: new Date(2024, 8, 15), // days click enabled to;
showMonthPicker: false,
daysConfig: _daysConfig,
};

@eugenedw
Copy link

I took this approach to get it working:

options: CalendarModalOptions = {
    pickMode: 'multi',
    showMonthPicker: true,
    from: moment().add(-1,'year').toDate(),
    to: moment().add(1,'year').toDate()
};

@11joselu
Copy link

I found that the "minimum" from date is 1971

  const options: CalendarModalOptions = {
      title: '',
      from: new Date(1971, 0, 1),
      to: 0,
      defaultDate: new Date(),
   };

image

If you set before 1971 it will show all elements as a disabled

  const options: CalendarModalOptions = {
      title: '',
      from: new Date(1970, 0, 1),
      to: 0,
      defaultDate: new Date(),
   };

image

@heliomarpm
Copy link

Unfortunately this repository was abandoned, to solve my problems with dates before 1970 and updates, I released a new version with corrections and new features.

https://www.npmjs.com/package/@heliomarpm/ion-calendar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants