Using 2 datepickers, when selecting last day of month, 2 datepicker shows blank days

Using 2 datepickers, when selecting last day of month, 2 datepicker shows blank days

Anyone see anything wrong with this? When you select a date from the 1st datepicker, onSelect it should auto-fill tomorrow's date in the 2nd datepicker. However if you select the last day of the month, in this case it happens to be August 31, the 2nd datepicker's value becomes equal to August 31 (should by +1day) and breaks everything. Any clue?

  1.   $('#subscription_suspend_on').datepicker({
  2.       dateFormat: 'yy-mm-dd',
  3.       numberOfMonths: 2,
  4.       showOn: 'both',
  5.       buttonImage: '/publisher/images/calendar-select.png',
  6.       buttonImageOnly: false,
  7.       minDate: '0D',
  8.       maxDate: '+30D',
  9.       onSelect: function(dateStr) {
  10.           var newDate = $(this).datepicker('getDate');
  11.           var newMaxDate = $(this).datepicker('getDate');
  12.           var checkResumeDate = $('#subscription_resume_on').datepicker('getDate');
  13.           if(newDate) { //not null
  14.               newDate.setDate(newDate.getDate() + 1);
  15.               newMaxDate.setDate(newDate.getDate() + 30);
  16.           }
  17.           if(checkResumeDate == '') {
  18.               checkResumeDate.setDate(newDate.getDate() + 30);
  19.           }
  20.           if(checkResumeDate) {
  21.               checkResumeDate.setDate(newDate.getDate() + 1);
  22.           }
  23.           alert(newMaxDate);
  24.           //$('#subscription_resume_on').datepicker("option", "minDate", new Date(newDate));
  25.           $('#subscription_resume_on').datepicker("option", {minDate: newDate});
  26.           $('#subscription_resume_on').datepicker("option", {maxDate: newMaxDate});
  27.           $('#subscription_resume_on').datepicker("setDate", new Date(checkResumeDate));
  28.       }
  29.   });
  30.   $('#subscription_resume_on').datepicker({
  31.       dateFormat: 'yy-mm-dd',
  32.       numberOfMonths: 2,
  33.       showOn: 'both',
  34.       buttonImage: '/publisher/images/calendar-select.png',
  35.       buttonImageOnly: false
  36.   });