diff --git a/datePicker.js b/datePicker.js index 522d359..6d2e435 100644 --- a/datePicker.js +++ b/datePicker.js @@ -181,7 +181,7 @@ function getDateTime(_this, options, element) { // revisit var value = options.readValue.call(_this, element), - date = getDateObject(value || getDateString(new Date(), true)), + date = getDateObject(value || _this.getDateString(new Date(), true)), timeFormat = element.getAttribute(options.timeFormatAttribute), hasAMPM = false, isPM = false; @@ -417,7 +417,7 @@ function addDays(_this, date, add, end) { date = _this.calendar.convertDateString(date, end); date.setDate(date.getDate() + add); - return getDateString(date); + return _this.getDateString(date); } function sortDates(date1, date2) { @@ -450,7 +450,7 @@ (date.AMPM ? ' ' + date.AMPM : '')) : '')); } - function getDateString(date, time) { + DatePicker.prototype.getDateString = function(date, time) { return date.getFullYear() + '-' + lZ(date.getMonth() + 1) + '-' + lZ(date.getDate()) + (time ? ' ' + date.toTimeString().split(' ')[0] : ''); } diff --git a/index.html b/index.html index 08dd35b..5c9a250 100644 --- a/index.html +++ b/index.html @@ -45,8 +45,8 @@

Demo


Range (name based): - - + +
Range with marked range: @@ -211,11 +211,13 @@

calendar.js

* @return {String} The value of the input field */ readValue: function(element) { - if (!element.value && element.getAttribute('data-type') === 'time') { // initial time if empty - return new Date().toTimeString().split(' ')[0]; // triggers default behavior - } - - return element.value; // triggers default behavior + if (!element.value /* && element.getAttribute('data-type') === 'time' */) { // initial time if empty + var d = new Date(); + d.setHours(0, 0, 0); // Set hours, minutes and seconds + return this.getDateString(d,true).replace(/:00$/,'');//today's date string, 00:00 time + // return new Date().toTimeString().split(' ')[0]; // triggers default behavior + } + return element.value; // triggers default behavior } }, /**