Jquery datetimepicker проблема в новом Chrome браузере - PullRequest
0 голосов
/ 04 февраля 2020

Я отключил время из палитры datetime в зависимости от текущего времени. Эта функциональность работает на Windows 10 + Chrome всех версиях, но не работает на Ma c OS + chrome 76,78,79.

Screen with issue

working screen

$(function() {
  /* $('#datetimepicker').datetimepicker({    maxDate: new Date() ,*/

  var fivedays;
  fivedays = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 32);
  //fivedays = new Date(new Date().getFullYear(), new Date().getMonth()+1);

  var dt = $('#datetimepicker');

  dt.datetimepicker({
    minDate: new Date(),
    maxDate: fivedays,
    beforeShowDay: function(date) {
      if (date.getDay() > 0 && date.getDay() < 6) {
        return [true, ''];
      } else {
        return [true, ''];
      }
    },
    monthStart: new Date().getMonth(),
    monthEnd: new Date().getMonth(),
    yearStart: new Date().getFullYear(),
    yearEnd: new Date().getFullYear(),
    prevButton: true,
    nextButton: true,
    timepicker: false,
    format: 'Y/m/d',
    scrollMonth: false,
    scrollInput: false
  });

  dt.on('change', function() {
    var selectedDate = $(this).val();
    var cDate = (new Date().getFullYear()) + '/' + (new Date().getMonth()) + '/' + (new Date().getDate());
    var min = (new Date().getMinutes());
    var cTime = (new Date().getHours()) + ':' + (min.length == 1 ? '0' + min : min);

    if (new Date(selectedDate) > new Date()) {
      $('#datetimepicker3').find('option[disabled]').removeAttr('disabled');
    } else {
      $.each($('#datetimepicker3').children("option").not(':first'), function() {
        if (Date.parse(cDate + " " + $(this).attr('data-start')) <= Date.parse(cDate + " " + cTime)) {
          $(this).prop("disabled", true);
        } else {
          $(this).removeAttr("disabled");
        }
      });
    }
  });

  var dt2 = $('#datetimepicker2');
  //var dtset2 = new Date(new Date(dt).getFullYear(), new Date(dt).getMonth(), new Date(dt).getDate());

  dt2.datetimepicker({
    minDate: new Date(),
    maxDate: fivedays
      //dt2.datetimepicker({  minDate: dt, maxDate: dt
      ,
    beforeShowDay: function(date) {
      if (date.getDay() > 0 && date.getDay() < 6) {
        return [true, ''];
      } else {
        return [false, ''];
      }
    },
    monthStart: new Date().getMonth(),
    monthEnd: new Date().getMonth(),
    yearStart: new Date().getFullYear(),
    yearEnd: new Date().getFullYear(),
    prevButton: true,
    nextButton: true,
    timepicker: false,
    format: 'Y/m/d',
    scrollMonth: false,
    scrollInput: false
  });

  dt2.on('change', function() {
    var selectedDate = $(this).val();
    var cDate = (new Date().getFullYear()) + '/' + (new Date().getMonth()) + '/' + (new Date().getDate());
    var min = (new Date().getMinutes());
    var cTime = (new Date().getHours()) + ':' + (min.length == 1 ? '0' + min : min);

    if (new Date(selectedDate) > new Date()) {
      $('#datetimepicker4').find('option[disabled]').removeAttr('disabled');
    } else {
      $.each($('#datetimepicker4').children("option").not(':first'), function() {
        if (Date.parse(cDate + " " + $(this).attr('data-start')) <= Date.parse(cDate + " " + cTime)) {
          $(this).prop("disabled", true);
        } else {
          $(this).removeAttr("disabled");
        }
      });

    }
  });

  // $('#datetimepicker3').datetimepicker({ showClear: true, format: "H:i", timerangepicker:true, datepicker:false, step: 30, minTime: "7.00", maxTime: "19.00"});
  // $('#datetimepicker4').datetimepicker({ format: 'H:i', datepicker:false,  step: 30,minTime: "7.00", maxTime: "19.00"});
});

1 Ответ

0 голосов
/ 09 февраля 2020

Я обнаружил, что проблем не было, но дата на кросс-браузерной платформе была настроена на другой часовой пояс, поэтому я не отключал время.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...