xdan / datetimepicker

jQuery Plugin Date and Time Picker
https://xdsoft.net/jqplugins/datetimepicker/
MIT License
3.5k stars 1.52k forks source link

setOption minTime appears to be boolean rather than a time string #772

Closed obxpete closed 2 years ago

obxpete commented 3 years ago

The only way I could get minTime to truly work, was not to write this.minTime: "11:00" as shown in the documentation, but rather only by setting it to true or false. That is, per the code below, I set the value to true if the date is today, but if not, then there is no minTime.

Note: that this is inside of a angular TS file, but i don't think that should make a difference. please correct me if i'm wrong. Either way, this post might be useful to someone else.

    minTime:true,

    onChangeDateTime:function( selectedDateTime ){

      var date = new Date();
      var baseTodayAsNumber = new Date(date.getTime()).setHours(0,0,0);

      var baseSelectedDate = new Date(selectedDateTime).setHours(0,0,0);

      if(!(new Date(baseTodayAsNumber).toString() == new Date(baseSelectedDate).toString())) {
        this.setOptions({
            minTime: false
        })
      } else {
        this.setOptions({
          minTime: true
        })
      }

    },
obxpete commented 2 years ago

see solution in this issue comment:

https://github.com/xdan/datetimepicker/issues/577#issuecomment-327395174 ...