t1m0n / air-datepicker

Lightweight, dependency-free JavaScript datepicker.
https://air-datepicker.com
MIT License
2.62k stars 1.37k forks source link

TimeSlider does not work well with maxDate #607

Open JNBG opened 5 months ago

JNBG commented 5 months ago

Options used for the Init:

let options:any = {
    altField: input.prev()[0],
    locale: localeDe,
    options.selectedDates = [1713330000000];
    options.altFieldFormat = 'T';
    options.dateFormat = 'dd.MM.yyyy';
    options.timeFormat = 'HH:mm';
    options.timepicker = true;
    options.minDate = new Date('2024-04-01 06:00');
    options.maxDate = new Date('2024-04-30 18:00');
};

Bug 1: Max Date can be set out of Bounds

  1. Set a maxDate Option to e.g. "2024-04-30 18:00"
  2. Select an earlier Day
  3. Set Hours to anything below 18 (Minutes don't really matter)
  4. Select configured max Date (2024-04-30 from above)
  5. MinuteSlider is now unlocked and the date can be set to "2024-04-30 18:59", so up to 59mins over the Max. => Expected Behaviour would be the Minute Slider to lock to 0 with the hour 18 selected

Bug 2: Minutes can't be selected after maxDate locked

  1. Set a maxDate Option to e.g. "2024-04-30 18:00"
  2. Select an earlier Day
  3. Set Hours to anything above 18 (Minutes don't really matter)
  4. Select configured max Date (2024-04-30 from above)
  5. As expected Time is auto-set to 18:00 and MinuteSlider is locked
  6. Select an Hour below 18
  7. Minute-Slider does not unlock to allow selection of e.g. 17:59 => Expected Behaviour would be for the Miunte Slider to lock/unlock dynamically on selection of the Hourslider

I hope you can add a Fix for this, as otherwise the Picker is doing a formidable Job :)

t1m0n commented 4 months ago

Hi, I'll try to check it. Did you try to use maxMinutes \ maxHours options?

JNBG commented 4 months ago

I did not, I thought those were for limiting each day and not just setting a max/min date

14nd90 commented 4 months ago

+1 also having this issue