mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
commit
7d945b6024
@ -575,10 +575,8 @@ var datetimepickerFactory = function ($) {
|
|||||||
maxDate: false,
|
maxDate: false,
|
||||||
minTime: false,
|
minTime: false,
|
||||||
maxTime: false,
|
maxTime: false,
|
||||||
minDateTime: false,
|
minDateTime: false,
|
||||||
|
maxDateTime: false,
|
||||||
disabledMinTime: false,
|
|
||||||
disabledMaxTime: false,
|
|
||||||
|
|
||||||
allowTimes: [],
|
allowTimes: [],
|
||||||
opened: false,
|
opened: false,
|
||||||
@ -1263,6 +1261,10 @@ var datetimepickerFactory = function ($) {
|
|||||||
options.minDateTime = _xdsoft_datetime.strToDateTime(options.minDateTime).dateFormat(options.formatDate);
|
options.minDateTime = _xdsoft_datetime.strToDateTime(options.minDateTime).dateFormat(options.formatDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.maxDateTime && /^\+(.*)$/.test(options.maxDateTime)) {
|
||||||
|
options.maxDateTime = _xdsoft_datetime.strToDateTime(options.maxDateTime).dateFormat(options.formatDate);
|
||||||
|
}
|
||||||
|
|
||||||
applyButton.toggle(options.showApplyButton);
|
applyButton.toggle(options.showApplyButton);
|
||||||
|
|
||||||
month_picker
|
month_picker
|
||||||
@ -1669,7 +1671,8 @@ var datetimepickerFactory = function ($) {
|
|||||||
today = _xdsoft_datetime.now(),
|
today = _xdsoft_datetime.now(),
|
||||||
maxDate = false,
|
maxDate = false,
|
||||||
minDate = false,
|
minDate = false,
|
||||||
minDateTime = false,
|
minDateTime = false,
|
||||||
|
maxDateTime = false,
|
||||||
hDate,
|
hDate,
|
||||||
day,
|
day,
|
||||||
d,
|
d,
|
||||||
@ -1716,6 +1719,16 @@ var datetimepickerFactory = function ($) {
|
|||||||
minDateTime = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), minDateTime.getHours(), minDateTime.getMinutes(), minDateTime.getSeconds());
|
minDateTime = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), minDateTime.getHours(), minDateTime.getMinutes(), minDateTime.getSeconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.maxDateTime !== false) {
|
||||||
|
maxDateTime = _xdsoft_datetime.strToDate(options.maxDateTime);
|
||||||
|
maxDateTime = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), maxDateTime.getHours(), maxDateTime.getMinutes(), maxDateTime.getSeconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
var maxDateTimeDay;
|
||||||
|
if (maxDateTime !== false) {
|
||||||
|
maxDateTimeDay = ((maxDateTime.getFullYear() * 12) + maxDateTime.getMonth()) * 31 + maxDateTime.getDate();
|
||||||
|
}
|
||||||
|
|
||||||
while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
|
while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
|
||||||
classes = [];
|
classes = [];
|
||||||
i += 1;
|
i += 1;
|
||||||
@ -1747,7 +1760,8 @@ var datetimepickerFactory = function ($) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((maxDate !== false && start > maxDate) || (minDateTime !== false && start < minDateTime) || (minDate !== false && start < minDate) || (customDateSettings && customDateSettings[0] === false)) {
|
var currentDay = ((start.getFullYear() * 12) + start.getMonth()) * 31 + start.getDate();
|
||||||
|
if ((maxDate !== false && start > maxDate) || (minDateTime !== false && start < minDateTime) || (minDate !== false && start < minDate) || (maxDateTime !== false && currentDay > maxDateTimeDay) || (customDateSettings && customDateSettings[0] === false)) {
|
||||||
classes.push('xdsoft_disabled');
|
classes.push('xdsoft_disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1824,22 +1838,45 @@ var datetimepickerFactory = function ($) {
|
|||||||
h = '';
|
h = '';
|
||||||
m = '';
|
m = '';
|
||||||
|
|
||||||
|
var minTimeMinutesOfDay = 0;
|
||||||
|
if (options.minTime !== false) {
|
||||||
|
var t = _xdsoft_datetime.strtotime(options.minTime);
|
||||||
|
minTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
|
||||||
|
}
|
||||||
|
var maxTimeMinutesOfDay = 24 * 60;
|
||||||
|
if (options.maxTime !== false) {
|
||||||
|
var t = _xdsoft_datetime.strtotime(options.maxTime);
|
||||||
|
maxTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.minDateTime !== false) {
|
||||||
|
var t = _xdsoft_datetime.strToDateTime(options.minDateTime);
|
||||||
|
var currentDayIsMinDateTimeDay = dateHelper.formatDate(_xdsoft_datetime.currentTime, options.formatDate) === dateHelper.formatDate(t, options.formatDate);
|
||||||
|
if (currentDayIsMinDateTimeDay) {
|
||||||
|
var m = 60 * t.getHours() + t.getMinutes();
|
||||||
|
if (m > minTimeMinutesOfDay) minTimeMinutesOfDay = m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.maxDateTime !== false) {
|
||||||
|
var t = _xdsoft_datetime.strToDateTime(options.maxDateTime);
|
||||||
|
var currentDayIsMaxDateTimeDay = dateHelper.formatDate(_xdsoft_datetime.currentTime, options.formatDate) === dateHelper.formatDate(t, options.formatDate);
|
||||||
|
if (currentDayIsMaxDateTimeDay) {
|
||||||
|
var m = 60 * t.getHours() + t.getMinutes();
|
||||||
|
if (m < maxTimeMinutesOfDay) maxTimeMinutesOfDay = m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
line_time = function line_time(h, m) {
|
line_time = function line_time(h, m) {
|
||||||
var now = _xdsoft_datetime.now(), optionDateTime, current_time,
|
var now = _xdsoft_datetime.now(), current_time,
|
||||||
isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
|
isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
|
||||||
now.setHours(h);
|
now.setHours(h);
|
||||||
h = parseInt(now.getHours(), 10);
|
h = parseInt(now.getHours(), 10);
|
||||||
now.setMinutes(m);
|
now.setMinutes(m);
|
||||||
m = parseInt(now.getMinutes(), 10);
|
m = parseInt(now.getMinutes(), 10);
|
||||||
optionDateTime = new Date(_xdsoft_datetime.currentTime);
|
|
||||||
optionDateTime.setHours(h);
|
|
||||||
optionDateTime.setMinutes(m);
|
|
||||||
classes = [];
|
classes = [];
|
||||||
if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
|
var currentMinutesOfDay = 60 * h + m;
|
||||||
classes.push('xdsoft_disabled');
|
if (input.is('[disabled]') || (currentMinutesOfDay >= maxTimeMinutesOfDay) || (currentMinutesOfDay < minTimeMinutesOfDay)) {
|
||||||
} else if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || ((options.disabledMinTime !== false && now.getTime() > _xdsoft_datetime.strtotime(options.disabledMinTime).getTime()) && (options.disabledMaxTime !== false && now.getTime() < _xdsoft_datetime.strtotime(options.disabledMaxTime).getTime()))) {
|
|
||||||
classes.push('xdsoft_disabled');
|
|
||||||
} else if (input.is('[disabled]')) {
|
|
||||||
classes.push('xdsoft_disabled');
|
classes.push('xdsoft_disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1866,6 +1903,9 @@ var datetimepickerFactory = function ($) {
|
|||||||
if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
|
if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
|
||||||
for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
|
for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
|
||||||
for (j = 0; j < 60; j += options.step) {
|
for (j = 0; j < 60; j += options.step) {
|
||||||
|
var currentMinutesOfDay = i * 60 + j;
|
||||||
|
if (currentMinutesOfDay < minTimeMinutesOfDay) continue;
|
||||||
|
if (currentMinutesOfDay >= maxTimeMinutesOfDay) continue;
|
||||||
h = (i < 10 ? '0' : '') + i;
|
h = (i < 10 ? '0' : '') + i;
|
||||||
m = (j < 10 ? '0' : '') + j;
|
m = (j < 10 ? '0' : '') + j;
|
||||||
line_time(h, m);
|
line_time(h, m);
|
||||||
|
2
build/jquery.datetimepicker.full.min.js
vendored
2
build/jquery.datetimepicker.full.min.js
vendored
File diff suppressed because one or more lines are too long
1
build/jquery.datetimepicker.min.js
vendored
Normal file
1
build/jquery.datetimepicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -565,10 +565,8 @@ var datetimepickerFactory = function ($) {
|
|||||||
maxDate: false,
|
maxDate: false,
|
||||||
minTime: false,
|
minTime: false,
|
||||||
maxTime: false,
|
maxTime: false,
|
||||||
minDateTime: false,
|
minDateTime: false,
|
||||||
|
maxDateTime: false,
|
||||||
disabledMinTime: false,
|
|
||||||
disabledMaxTime: false,
|
|
||||||
|
|
||||||
allowTimes: [],
|
allowTimes: [],
|
||||||
opened: false,
|
opened: false,
|
||||||
@ -1255,6 +1253,10 @@ var datetimepickerFactory = function ($) {
|
|||||||
options.minDateTime = _xdsoft_datetime.strToDateTime(options.minDateTime).dateFormat(options.formatDate);
|
options.minDateTime = _xdsoft_datetime.strToDateTime(options.minDateTime).dateFormat(options.formatDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.maxDateTime && /^\+(.*)$/.test(options.maxDateTime)) {
|
||||||
|
options.maxDateTime = _xdsoft_datetime.strToDateTime(options.maxDateTime).dateFormat(options.formatDate);
|
||||||
|
}
|
||||||
|
|
||||||
applyButton.toggle(options.showApplyButton);
|
applyButton.toggle(options.showApplyButton);
|
||||||
|
|
||||||
month_picker
|
month_picker
|
||||||
@ -1661,7 +1663,8 @@ var datetimepickerFactory = function ($) {
|
|||||||
today = _xdsoft_datetime.now(),
|
today = _xdsoft_datetime.now(),
|
||||||
maxDate = false,
|
maxDate = false,
|
||||||
minDate = false,
|
minDate = false,
|
||||||
minDateTime = false,
|
minDateTime = false,
|
||||||
|
maxDateTime = false,
|
||||||
hDate,
|
hDate,
|
||||||
day,
|
day,
|
||||||
d,
|
d,
|
||||||
@ -1708,6 +1711,16 @@ var datetimepickerFactory = function ($) {
|
|||||||
minDateTime = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), minDateTime.getHours(), minDateTime.getMinutes(), minDateTime.getSeconds());
|
minDateTime = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), minDateTime.getHours(), minDateTime.getMinutes(), minDateTime.getSeconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.maxDateTime !== false) {
|
||||||
|
maxDateTime = _xdsoft_datetime.strToDate(options.maxDateTime);
|
||||||
|
maxDateTime = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), maxDateTime.getHours(), maxDateTime.getMinutes(), maxDateTime.getSeconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
var maxDateTimeDay;
|
||||||
|
if (maxDateTime !== false) {
|
||||||
|
maxDateTimeDay = ((maxDateTime.getFullYear() * 12) + maxDateTime.getMonth()) * 31 + maxDateTime.getDate();
|
||||||
|
}
|
||||||
|
|
||||||
while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
|
while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
|
||||||
classes = [];
|
classes = [];
|
||||||
i += 1;
|
i += 1;
|
||||||
@ -1739,7 +1752,8 @@ var datetimepickerFactory = function ($) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((maxDate !== false && start > maxDate) || (minDateTime !== false && start < minDateTime) || (minDate !== false && start < minDate) || (customDateSettings && customDateSettings[0] === false)) {
|
var currentDay = ((start.getFullYear() * 12) + start.getMonth()) * 31 + start.getDate();
|
||||||
|
if ((maxDate !== false && start > maxDate) || (minDateTime !== false && start < minDateTime) || (minDate !== false && start < minDate) || (maxDateTime !== false && currentDay > maxDateTimeDay) || (customDateSettings && customDateSettings[0] === false)) {
|
||||||
classes.push('xdsoft_disabled');
|
classes.push('xdsoft_disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1816,22 +1830,45 @@ var datetimepickerFactory = function ($) {
|
|||||||
h = '';
|
h = '';
|
||||||
m = '';
|
m = '';
|
||||||
|
|
||||||
|
var minTimeMinutesOfDay = 0;
|
||||||
|
if (options.minTime !== false) {
|
||||||
|
var t = _xdsoft_datetime.strtotime(options.minTime);
|
||||||
|
minTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
|
||||||
|
}
|
||||||
|
var maxTimeMinutesOfDay = 24 * 60;
|
||||||
|
if (options.maxTime !== false) {
|
||||||
|
var t = _xdsoft_datetime.strtotime(options.maxTime);
|
||||||
|
maxTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.minDateTime !== false) {
|
||||||
|
var t = _xdsoft_datetime.strToDateTime(options.minDateTime);
|
||||||
|
var currentDayIsMinDateTimeDay = dateHelper.formatDate(_xdsoft_datetime.currentTime, options.formatDate) === dateHelper.formatDate(t, options.formatDate);
|
||||||
|
if (currentDayIsMinDateTimeDay) {
|
||||||
|
var m = 60 * t.getHours() + t.getMinutes();
|
||||||
|
if (m > minTimeMinutesOfDay) minTimeMinutesOfDay = m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.maxDateTime !== false) {
|
||||||
|
var t = _xdsoft_datetime.strToDateTime(options.maxDateTime);
|
||||||
|
var currentDayIsMaxDateTimeDay = dateHelper.formatDate(_xdsoft_datetime.currentTime, options.formatDate) === dateHelper.formatDate(t, options.formatDate);
|
||||||
|
if (currentDayIsMaxDateTimeDay) {
|
||||||
|
var m = 60 * t.getHours() + t.getMinutes();
|
||||||
|
if (m < maxTimeMinutesOfDay) maxTimeMinutesOfDay = m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
line_time = function line_time(h, m) {
|
line_time = function line_time(h, m) {
|
||||||
var now = _xdsoft_datetime.now(), optionDateTime, current_time,
|
var now = _xdsoft_datetime.now(), current_time,
|
||||||
isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
|
isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
|
||||||
now.setHours(h);
|
now.setHours(h);
|
||||||
h = parseInt(now.getHours(), 10);
|
h = parseInt(now.getHours(), 10);
|
||||||
now.setMinutes(m);
|
now.setMinutes(m);
|
||||||
m = parseInt(now.getMinutes(), 10);
|
m = parseInt(now.getMinutes(), 10);
|
||||||
optionDateTime = new Date(_xdsoft_datetime.currentTime);
|
|
||||||
optionDateTime.setHours(h);
|
|
||||||
optionDateTime.setMinutes(m);
|
|
||||||
classes = [];
|
classes = [];
|
||||||
if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
|
var currentMinutesOfDay = 60 * h + m;
|
||||||
classes.push('xdsoft_disabled');
|
if (input.is('[disabled]') || (currentMinutesOfDay >= maxTimeMinutesOfDay) || (currentMinutesOfDay < minTimeMinutesOfDay)) {
|
||||||
} else if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || ((options.disabledMinTime !== false && now.getTime() > _xdsoft_datetime.strtotime(options.disabledMinTime).getTime()) && (options.disabledMaxTime !== false && now.getTime() < _xdsoft_datetime.strtotime(options.disabledMaxTime).getTime()))) {
|
|
||||||
classes.push('xdsoft_disabled');
|
|
||||||
} else if (input.is('[disabled]')) {
|
|
||||||
classes.push('xdsoft_disabled');
|
classes.push('xdsoft_disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1858,6 +1895,9 @@ var datetimepickerFactory = function ($) {
|
|||||||
if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
|
if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
|
||||||
for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
|
for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
|
||||||
for (j = 0; j < 60; j += options.step) {
|
for (j = 0; j < 60; j += options.step) {
|
||||||
|
var currentMinutesOfDay = i * 60 + j;
|
||||||
|
if (currentMinutesOfDay < minTimeMinutesOfDay) continue;
|
||||||
|
if (currentMinutesOfDay >= maxTimeMinutesOfDay) continue;
|
||||||
h = (i < 10 ? '0' : '') + i;
|
h = (i < 10 ? '0' : '') + i;
|
||||||
m = (j < 10 ? '0' : '') + j;
|
m = (j < 10 ? '0' : '') + j;
|
||||||
line_time(h, m);
|
line_time(h, m);
|
||||||
|
Loading…
Reference in New Issue
Block a user