pickadate:结束日期应比开始日期提前 1 天

pickadate: end date should be 1 day ahead to the start date

我有两个日期选择器(Materializecss) 一个用于入住日期,另一个用于退房日期。我想要的是我希望退房日期最短日期比入住日期提前 1 天。 我在 pickadate js 上得到了这段代码,但问题是第一个日期选择器上的 selected 日期在结束日期选择器中启用。我想要发生的是当我 select 9/22/2017 时,结束日期选择器的最小日期应该是 9/23/2017

$('#dp_ci').pickadate(
    {
        selectMonths: true, // Creates a dropdown to control month
        today: 'Today',
        clear: 'Clear',
        close: 'Ok',
        min: new Date()
      });


    var from_$input = $('#dp_ci').pickadate(),
    from_picker = from_$input.pickadate('picker')

    var to_$input = $('#dp_co').pickadate(),
    to_picker = to_$input.pickadate('picker')


    // Check if there’s a “from” or “to” date to start with.
    if ( from_picker.get('value') ) 
    {
      to_picker.set('min', from_picker.get('select'))
    }
    if ( to_picker.get('value') ) 
    {
      from_picker.set('max', to_picker.get('select'))


    }
    // When something is selected, update the “from” and “to” limits.
    from_picker.on('set', function(event) 
    {

      if ( event.select ) 
      {
        to_picker.set('min', from_picker.get('select'))    
      }

      else if ( 'clear' in event ) 
      {
        to_picker.set('min', false)
      }

    })

    to_picker.on('set', function(event) 
    {
      if ( event.select ) 
      {
        from_picker.set('max', to_picker.get('select'))
      }
      else if ( 'clear' in event ) 
      {
        from_picker.set('max', false)
      }
    })
 $('#dp_ci').pickadate(
    {
        selectMonths: true, // Creates a dropdown to control month
        today: 'Today',
        clear: 'Clear',
        close: 'Ok',
        min: new Date()
      });




    var from_$input = $('#dp_ci').pickadate(),
    from_picker = from_$input.pickadate('picker')

    var to_$input = $('#dp_co').pickadate(),
    to_picker = to_$input.pickadate('picker')


    // Check if there’s a “from” or “to” date to start with.
    if ( from_picker.get('value') ) 

    {        
       var today = new Date($('#dp_ci').val());
       today.setDate(today.getDate() + 1)
      to_picker.set('min', today)
    }
    if ( to_picker.get('value') ) 
    {
       var today = new Date($('#dp_co').val());
    today.setDate(today.getDate() - 1)
      from_picker.set('max', today)


    }
    // When something is selected, update the “from” and “to” limits.
    from_picker.on('set', function(event) 
    {

      if ( event.select ) 
      {
         var today = new Date($('#dp_ci').val());
    today.setDate(today.getDate() + 1)
        to_picker.set('min', today)    
      }

      else if ( 'clear' in event ) 
      {

        to_picker.set('min', false)
      }

    })

    to_picker.on('set', function(event) 
    {
      if ( event.select ) 
      {
        var today = new Date($('#dp_co').val());
    today.setDate(today.getDate() - 1)
        from_picker.set('max', today)
      }
      else if ( 'clear' in event ) 
      {

        from_picker.set('max', false)
      }
    })

我添加了 today 变量(抱歉无法再更改名称:)