diff --git a/dist/javascripts/jquery.datetimepicker.js b/dist/javascripts/jquery.datetimepicker.js
index 90e76d8..5e483ac 100644
--- a/dist/javascripts/jquery.datetimepicker.js
+++ b/dist/javascripts/jquery.datetimepicker.js
@@ -1076,7 +1076,7 @@
setPos,
timer = 0,
timer1 = 0,
- xd_datetime;
+ _xdsoft_datetime;
month_picker
.find('.' + XDC_MONTH + ' span')
@@ -1098,8 +1098,8 @@
month_picker
.find('.' + XDC_SELECT)
.hide();
- if (xd_datetime.currentTime) {
- val = xd_datetime.currentTime[$(this).hasClass(XDC_MONTH) ? 'getMonth' : 'getFullYear']();
+ if (_xdsoft_datetime.currentTime) {
+ val = _xdsoft_datetime.currentTime[$(this).hasClass(XDC_MONTH) ? 'getMonth' : 'getFullYear']();
}
select[visible ? 'hide' : 'show']();
@@ -1124,20 +1124,20 @@
event.preventDefault();
})
.on(XDE_MOUSEDOWN, '.' + XDC_OPTION, function(event) {
- var year = xd_datetime.currentTime.getFullYear();
- if (xd_datetime && xd_datetime.currentTime) {
- xd_datetime.currentTime[$(this).parent().parent().hasClass(XDC_MONTHSELECT) ? 'setMonth' : 'setFullYear']($(this).data('value'));
+ var year = _xdsoft_datetime.currentTime.getFullYear();
+ if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
+ _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass(XDC_MONTHSELECT) ? 'setMonth' : 'setFullYear']($(this).data('value'));
}
$(this).parent().parent().hide();
datetimepicker.trigger(XDE_XCHANGE);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
- options.onChangeMonth.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
- if (year !== xd_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
- options.onChangeYear.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
+ options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
});
@@ -1187,7 +1187,7 @@
if (input && input.val) {
input.val(options.value);
}
- xd_datetime.setCurrentTime(options.value);
+ _xdsoft_datetime.setCurrentTime(options.value);
}
setDayOfWeekStart(options);
@@ -1197,11 +1197,11 @@
}
if (options.minDate && /^-(.*)$/.test(options.minDate)) {
- options.minDate = xd_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
+ options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
}
if (options.maxDate && /^\+(.*)$/.test(options.maxDate)) {
- options.maxDate = xd_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
+ options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
}
month_picker
@@ -1330,7 +1330,7 @@
$(this).val(null);
datetimepicker.data(XDC_DATETIME).empty();
} else if (!Date.parseDate($(this).val(), options.format)) {
- $(this).val((xd_datetime.now()).dateFormat(options.format));
+ $(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
datetimepicker.data(XDC_DATETIME).setCurrentTime($(this).val());
} else {
datetimepicker.data(XDC_DATETIME).setCurrentTime($(this).val());
@@ -1445,11 +1445,11 @@
_this.currentTime.setMonth(month);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
- options.onChangeMonth.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
- options.onChangeYear.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
datetimepicker.trigger(XDE_XCHANGE);
@@ -1470,7 +1470,7 @@
);
_this.currentTime.setMonth(month);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
- options.onChangeMonth.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
datetimepicker.trigger(XDE_XCHANGE);
return month;
@@ -1495,7 +1495,7 @@
}
if (tmpDate && tmpDate[2]) {
timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
- currentTime = new Date((xd_datetime.now()).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
+ currentTime = new Date((_xdsoft_datetime.now()).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
} else {
currentTime = sDateTime ? Date.parseDate(sDateTime, options.format) : _this.now();
}
@@ -1536,16 +1536,16 @@
_this.currentTime = this.now();
};
- xd_datetime = new XDSoft_datetime();
+ _xdsoft_datetime = new XDSoft_datetime();
month_picker
.find('.' + XDC_TODAY_BUTTON)
.on(XDE_MOUSEDOWN, function() {
datetimepicker.data('changed', true);
- xd_datetime.setCurrentTime(0);
+ _xdsoft_datetime.setCurrentTime(0);
datetimepicker.trigger(XDE_AFTEROPEN);
}).on(XDE_DBLCLICK, function() {
- input.val(xd_datetime.str());
+ input.val(_xdsoft_datetime.str());
datetimepicker.trigger(XDE_CLOSE);
});
month_picker
@@ -1556,11 +1556,11 @@
stop = false;
(function arguments_callee1(v) {
- var month = xd_datetime.currentTime.getMonth();
+ var month = _xdsoft_datetime.currentTime.getMonth();
if ($this.hasClass(options.next)) {
- xd_datetime.nextMonth();
+ _xdsoft_datetime.nextMonth();
} else if ($this.hasClass(options.prev)) {
- xd_datetime.prevMonth();
+ _xdsoft_datetime.prevMonth();
}
if (options.monthChangeSpinner) {
if (!stop) {
@@ -1613,10 +1613,10 @@
clearTimeout(xchangeTimer);
xchangeTimer = setTimeout(function() {
var table = '',
- start = new Date(xd_datetime.currentTime.getFullYear(), xd_datetime.currentTime.getMonth(), 1, 12, 0, 0),
+ start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
i = 0,
j,
- today = xd_datetime.now(),
+ today = _xdsoft_datetime.now(),
maxDate = false,
minDate = false,
d,
@@ -1648,23 +1648,23 @@
table += '
';
if (options.maxDate !== false) {
- maxDate = xd_datetime.strToDate(options.maxDate);
+ maxDate = _xdsoft_datetime.strToDate(options.maxDate);
maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
}
if (options.minDate !== false) {
- minDate = xd_datetime.strToDate(options.minDate);
+ minDate = _xdsoft_datetime.strToDate(options.minDate);
minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
}
- while (i < xd_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || xd_datetime.currentTime.getMonth() === start.getMonth()) {
+ while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
classes = [];
i += 1;
d = start.getDate();
y = start.getFullYear();
m = start.getMonth();
- w = xd_datetime.getWeekOfYear(start);
+ w = _xdsoft_datetime.getWeekOfYear(start);
classes.push(XDC_DATE);
@@ -1684,11 +1684,11 @@
classes.push(customDateSettings[1]);
}
- if (xd_datetime.currentTime.getMonth() !== m) {
+ if (_xdsoft_datetime.currentTime.getMonth() !== m) {
classes.push(XDC_OTHER_MONTH);
}
- if ((options.defaultSelect || datetimepicker.data('changed')) && xd_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
+ if ((options.defaultSelect || datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
classes.push(XDC_CURRENT);
}
@@ -1727,27 +1727,27 @@
calendar.html(table);
- month_picker.find('.' + XDC_LABEL + ' span').eq(0).text(getI18n(options.lang,'months')[xd_datetime.currentTime.getMonth()]);
- month_picker.find('.' + XDC_LABEL + ' span').eq(1).text(xd_datetime.currentTime.getFullYear());
+ month_picker.find('.' + XDC_LABEL + ' span').eq(0).text(getI18n(options.lang,'months')[_xdsoft_datetime.currentTime.getMonth()]);
+ month_picker.find('.' + XDC_LABEL + ' span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
// generate timebox
time = '';
h = '';
m = '';
line_time = function line_time(h, m) {
- var now = xd_datetime.now();
+ var now = _xdsoft_datetime.now();
now.setHours(h);
h = parseInt(now.getHours(), 10);
now.setMinutes(m);
m = parseInt(now.getMinutes(), 10);
- var optionDateTime = new Date(xd_datetime.currentTime);
+ var optionDateTime = new Date(_xdsoft_datetime.currentTime);
optionDateTime.setHours(h);
optionDateTime.setMinutes(m);
classes = [];
- if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && xd_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && xd_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
+ 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())) {
classes.push(XDC_DISABLED);
}
- if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && parseInt(xd_datetime.currentTime.getHours(), 10) === parseInt(h, 10) && (options.step > 59 || Math[options.roundTime](xd_datetime.currentTime.getMinutes() / options.step) * options.step === parseInt(m, 10))) {
+ if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && parseInt(_xdsoft_datetime.currentTime.getHours(), 10) === parseInt(h, 10) && (options.step > 59 || Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step === parseInt(m, 10))) {
if (options.defaultSelect || datetimepicker.data('changed')) {
classes.push(XDC_CURRENT);
} else if (options.initTime) {
@@ -1770,8 +1770,8 @@
}
} else {
for (i = 0; i < options.allowTimes.length; i += 1) {
- h = xd_datetime.strtotime(options.allowTimes[i]).getHours();
- m = xd_datetime.strtotime(options.allowTimes[i]).getMinutes();
+ h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
+ m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
line_time(h, m);
}
}
@@ -1782,13 +1782,13 @@
i = 0;
for (i = parseInt(options.yearStart, 10) + options.yearOffset; i <= parseInt(options.yearEnd, 10) + options.yearOffset; i += 1) {
- opt += '' + i + '
';
+ opt += '' + i + '
';
}
yearselect.children().eq(0)
.html(opt);
for (i = 0, opt = ''; i <= 11; i += 1) {
- opt += '' + getI18n(options.lang,'months')[i] + '
';
+ opt += '' + getI18n(options.lang,'months')[i] + '
';
}
monthselect.children().eq(0).html(opt);
$(datetimepicker)
@@ -1824,11 +1824,11 @@
xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
timerclick += 1;
var $this = $(this),
- currentTime = xd_datetime.currentTime;
+ currentTime = _xdsoft_datetime.currentTime;
if (currentTime === undefined || currentTime === null) {
- xd_datetime.currentTime = xd_datetime.now();
- currentTime = xd_datetime.currentTime;
+ _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
+ currentTime = _xdsoft_datetime.currentTime;
}
if ($this.hasClass(XDC_DISABLED)) {
@@ -1842,13 +1842,13 @@
datetimepicker.trigger(XDE_SELECT, [currentTime]);
- input.val(xd_datetime.str());
+ input.val(_xdsoft_datetime.str());
if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === 0 && !options.timepicker))) && !options.inline) {
datetimepicker.trigger(XDE_CLOSE);
}
if (options.onSelectDate && $.isFunction(options.onSelectDate)) {
- options.onSelectDate.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), xdevent);
+ options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
}
datetimepicker.data('changed', true);
@@ -1863,11 +1863,11 @@
.on(XDE_CLICK, 'div', function(xdevent) {
xdevent.stopPropagation();
var $this = $(this),
- currentTime = xd_datetime.currentTime;
+ currentTime = _xdsoft_datetime.currentTime;
if (currentTime === undefined || currentTime === null) {
- xd_datetime.currentTime = xd_datetime.now();
- currentTime = xd_datetime.currentTime;
+ _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
+ currentTime = _xdsoft_datetime.currentTime;
}
if ($this.hasClass(XDC_DISABLED)) {
@@ -1877,13 +1877,13 @@
currentTime.setMinutes($this.data('minute'));
datetimepicker.trigger(XDE_SELECT, [currentTime]);
- datetimepicker.data('input').val(xd_datetime.str());
+ datetimepicker.data('input').val(_xdsoft_datetime.str());
if (!options.inline) {
datetimepicker.trigger(XDE_CLOSE);
}
if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
- options.onSelectTime.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), xdevent);
+ options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
}
datetimepicker.data('changed', true);
datetimepicker.trigger(XDE_XCHANGE);
@@ -1897,9 +1897,9 @@
return true;
}
if (event.deltaY < 0) {
- xd_datetime.nextMonth();
+ _xdsoft_datetime.nextMonth();
} else {
- xd_datetime.prevMonth();
+ _xdsoft_datetime.prevMonth();
}
return false;
});
@@ -1922,7 +1922,7 @@
if (options.datepicker && !options.timepicker) {
datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
if (input.val) {
- input.val(xd_datetime.str());
+ input.val(_xdsoft_datetime.str());
}
datetimepicker.trigger(XDE_CHANGEDATETIME);
return false;
@@ -1933,14 +1933,14 @@
.on(XDE_CHANGEDATETIME, function(event) {
if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
var $input = datetimepicker.data('input');
- options.onChangeDateTime.call(datetimepicker, xd_datetime.currentTime, $input, event);
+ options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
delete options.value;
$input.trigger('change');
}
})
.on(XDE_GENERATE, function() {
if (options.onGenerate && $.isFunction(options.onGenerate)) {
- options.onGenerate.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
if (triggerAfterOpen) {
datetimepicker.trigger(XDE_AFTEROPEN);
@@ -1983,7 +1983,7 @@
.on(XDE_OPEN, function(event) {
var onShow = true;
if (options.onShow && $.isFunction(options.onShow)) {
- onShow = options.onShow.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), event);
+ onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
}
if (onShow !== false) {
datetimepicker.show();
@@ -2007,7 +2007,7 @@
.find('.' + XDC_SELECT)
.hide();
if (options.onClose && $.isFunction(options.onClose)) {
- onClose = options.onClose.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), event);
+ onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
}
if (onClose !== false && !options.opened && !options.inline) {
datetimepicker.hide();
@@ -2026,7 +2026,7 @@
timer = 0;
timer1 = 0;
- datetimepicker.data(XDC_DATETIME, xd_datetime);
+ datetimepicker.data(XDC_DATETIME, _xdsoft_datetime);
datetimepicker.setOptions(options);
function getCurrentValue() {
@@ -2035,22 +2035,22 @@
time;
if (options.startDate) {
- ct = xd_datetime.strToDate(options.startDate);
+ ct = _xdsoft_datetime.strToDate(options.startDate);
} else {
ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
if (ct) {
- ct = xd_datetime.strToDateTime(ct);
+ ct = _xdsoft_datetime.strToDateTime(ct);
} else if (options.defaultDate) {
- ct = xd_datetime.strToDate(options.defaultDate);
+ ct = _xdsoft_datetime.strToDate(options.defaultDate);
if (options.defaultTime) {
- time = xd_datetime.strtotime(options.defaultTime);
+ time = _xdsoft_datetime.strtotime(options.defaultTime);
ct.setHours(time.getHours());
ct.setMinutes(time.getMinutes());
}
}
}
- if (ct && xd_datetime.isValidDate(ct)) {
+ if (ct && _xdsoft_datetime.isValidDate(ct)) {
datetimepicker.data('changed', true);
} else {
ct = '';
@@ -2059,7 +2059,7 @@
return ct || 0;
}
- xd_datetime.setCurrentTime(getCurrentValue());
+ _xdsoft_datetime.setCurrentTime(getCurrentValue());
input
.data(XDC_DATETIMEPICKER, datetimepicker)
@@ -2074,7 +2074,7 @@
}
triggerAfterOpen = true;
- xd_datetime.setCurrentTime(getCurrentValue());
+ _xdsoft_datetime.setCurrentTime(getCurrentValue());
datetimepicker.trigger(XDE_OPEN);
}, 100);
@@ -2165,401 +2165,20 @@
};
$.fn.datetimepicker.defaults = default_options;
$.fn.datetimepicker.setNamespace=setNamespace;
- // Parse and Format Library
- //http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
- /*
- * Copyright (C) 2004 Baron Schwartz
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation, version 2.1.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- */
- Date.parseFunctions = {
- count: 0
- };
- Date.parseRegexes = [];
- Date.formatFunctions = {
- count: 0
- };
- Date.prototype.dateFormat = function(b) {
- if (b == "unixtime") {
- return parseInt(this.getTime() / 1000);
- }
- if (Date.formatFunctions[b] == null) {
- Date.createNewFormat(b);
- }
- var a = Date.formatFunctions[b];
- return this[a]();
- };
- Date.createNewFormat = function(format) {
- var funcName = "format" + Date.formatFunctions.count++;
- Date.formatFunctions[format] = funcName;
- var code = "Date.prototype." + funcName + " = function() {return ";
- var special = false;
- var ch = "";
- for (var i = 0; i < format.length; ++i) {
- ch = format.charAt(i);
- if (!special && ch == "\\") {
- special = true;
- } else {
- if (special) {
- special = false;
- code += "'" + String.escape(ch) + "' + ";
- } else {
- code += Date.getFormatCode(ch);
- }
- }
- }
- eval(code.substring(0, code.length - 3) + ";}");
- };
- Date.getFormatCode = function(a) {
- switch (a) {
- case "d":
- return "String.leftPad(this.getDate(), 2, '0') + ";
- case "D":
- return "Date.dayNames[this.getDay()].substring(0, 3) + ";
- case "j":
- return "this.getDate() + ";
- case "l":
- return "Date.dayNames[this.getDay()] + ";
- case "S":
- return "this.getSuffix() + ";
- case "w":
- return "this.getDay() + ";
- case "z":
- return "this.getDayOfYear() + ";
- case "W":
- return "this.getWeekOfYear() + ";
- case "F":
- return "Date.monthNames[this.getMonth()] + ";
- case "m":
- return "String.leftPad(this.getMonth() + 1, 2, '0') + ";
- case "M":
- return "Date.monthNames[this.getMonth()].substring(0, 3) + ";
- case "n":
- return "(this.getMonth() + 1) + ";
- case "t":
- return "this.getDaysInMonth() + ";
- case "L":
- return "(this.isLeapYear() ? 1 : 0) + ";
- case "Y":
- return "this.getFullYear() + ";
- case "y":
- return "('' + this.getFullYear()).substring(2, 4) + ";
- case "a":
- return "(this.getHours() < 12 ? 'am' : 'pm') + ";
- case "A":
- return "(this.getHours() < 12 ? 'AM' : 'PM') + ";
- case "g":
- return "((this.getHours() %12) ? this.getHours() % 12 : 12) + ";
- case "G":
- return "this.getHours() + ";
- case "h":
- return "String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";
- case "H":
- return "String.leftPad(this.getHours(), 2, '0') + ";
- case "i":
- return "String.leftPad(this.getMinutes(), 2, '0') + ";
- case "s":
- return "String.leftPad(this.getSeconds(), 2, '0') + ";
- case "O":
- return "this.getGMTOffset() + ";
- case "T":
- return "this.getTimezone() + ";
- case "Z":
- return "(this.getTimezoneOffset() * -60) + ";
- default:
- return "'" + String.escape(a) + "' + ";
- }
- };
- Date.parseDate = function(a, c) {
- if (c == "unixtime") {
- return new Date(!isNaN(parseInt(a)) ? parseInt(a) * 1000 : 0);
- }
- if (Date.parseFunctions[c] == null) {
- Date.createParser(c);
- }
- var b = Date.parseFunctions[c];
- return Date[b](a);
- };
- Date.createParser = function(format) {
- var funcName = "parse" + Date.parseFunctions.count++;
- var regexNum = Date.parseRegexes.length;
- var currentGroup = 1;
- Date.parseFunctions[format] = funcName;
- var code = "Date." + funcName + " = function(input) {\nvar y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, z = -1;\nvar d = new Date();\ny = d.getFullYear();\nm = d.getMonth();\nd = d.getDate();\nvar results = input.match(Date.parseRegexes[" + regexNum + "]);\nif (results && results.length > 0) {";
- var regex = "";
- var special = false;
- var ch = "";
- for (var i = 0; i < format.length; ++i) {
- ch = format.charAt(i);
- if (!special && ch == "\\") {
- special = true;
- } else {
- if (special) {
- special = false;
- regex += String.escape(ch);
- } else {
- obj = Date.formatCodeToRegex(ch, currentGroup);
- currentGroup += obj.g;
- regex += obj.s;
- if (obj.g && obj.c) {
- code += obj.c;
- }
- }
- }
- }
- code += "if (y > 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";
- code += "if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";
- Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$");
- eval(code);
- };
- Date.formatCodeToRegex = function(b, a) {
- switch (b) {
- case "D":
- return {
- g: 0,
- c: null,
- s: "(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"
- };
- case "j":
- case "d":
- return {
- g: 1,
- c: "d = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{1,2})"
- };
- case "l":
- return {
- g: 0,
- c: null,
- s: "(?:" + Date.dayNames.join("|") + ")"
- };
- case "S":
- return {
- g: 0,
- c: null,
- s: "(?:st|nd|rd|th)"
- };
- case "w":
- return {
- g: 0,
- c: null,
- s: "\\d"
- };
- case "z":
- return {
- g: 1,
- c: "z = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{1,3})"
- };
- case "W":
- return {
- g: 0,
- c: null,
- s: "(?:\\d{2})"
- };
- case "F":
- return {
- g: 1,
- c: "m = parseInt(Date.monthNumbers[results[" + a + "].substring(0, 3)], 10);\n",
- s: "(" + Date.monthNames.join("|") + ")"
- };
- case "M":
- return {
- g: 1,
- c: "m = parseInt(Date.monthNumbers[results[" + a + "]], 10);\n",
- s: "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"
- };
- case "n":
- case "m":
- return {
- g: 1,
- c: "m = parseInt(results[" + a + "], 10) - 1;\n",
- s: "(\\d{1,2})"
- };
- case "t":
- return {
- g: 0,
- c: null,
- s: "\\d{1,2}"
- };
- case "L":
- return {
- g: 0,
- c: null,
- s: "(?:1|0)"
- };
- case "Y":
- return {
- g: 1,
- c: "y = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{4})"
- };
- case "y":
- return {
- g: 1,
- c: "var ty = parseInt(results[" + a + "], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
- s: "(\\d{1,2})"
- };
- case "a":
- return {
- g: 1,
- c: "if (results[" + a + "] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",
- s: "(am|pm)"
- };
- case "A":
- return {
- g: 1,
- c: "if (results[" + a + "] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",
- s: "(AM|PM)"
- };
- case "g":
- case "G":
- case "h":
- case "H":
- return {
- g: 1,
- c: "h = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{1,2})"
- };
- case "i":
- return {
- g: 1,
- c: "i = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{2})"
- };
- case "s":
- return {
- g: 1,
- c: "s = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{2})"
- };
- case "O":
- return {
- g: 0,
- c: null,
- s: "[+-]\\d{4}"
- };
- case "T":
- return {
- g: 0,
- c: null,
- s: "[A-Z]{3}"
- };
- case "Z":
- return {
- g: 0,
- c: null,
- s: "[+-]\\d{1,5}"
- };
- default:
- return {
- g: 0,
- c: null,
- s: String.escape(b)
- };
- }
- };
- Date.prototype.getTimezone = function() {
- return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/, "$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3");
- };
- Date.prototype.getGMTOffset = function() {
- return (this.getTimezoneOffset() > 0 ? "-" : "+") + String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset()) / 60), 2, "0") + String.leftPad(Math.abs(this.getTimezoneOffset()) % 60, 2, "0");
- };
- Date.prototype.getDayOfYear = function() {
- var a = 0;
- Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
- for (var b = 0; b < this.getMonth(); ++b) {
- a += Date.daysInMonth[b];
- }
- return a + this.getDate();
- };
- Date.prototype.getWeekOfYear = function() {
- var b = this.getDayOfYear() + (4 - this.getDay());
- var a = new Date(this.getFullYear(), 0, 1);
- var c = (7 - a.getDay() + 4);
- return String.leftPad(Math.ceil((b - c) / 7) + 1, 2, "0");
- };
- Date.prototype.isLeapYear = function() {
- var a = this.getFullYear();
- return ((a & 3) == 0 && (a % 100 || (a % 400 == 0 && a)));
- };
- Date.prototype.getFirstDayOfMonth = function() {
- var a = (this.getDay() - (this.getDate() - 1)) % 7;
- return (a < 0) ? (a + 7) : a;
- };
- Date.prototype.getLastDayOfMonth = function() {
- var a = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
- return (a < 0) ? (a + 7) : a;
- };
- Date.prototype.getDaysInMonth = function() {
- Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
- return Date.daysInMonth[this.getMonth()];
- };
- Date.prototype.getSuffix = function() {
- switch (this.getDate()) {
- case 1:
- case 21:
- case 31:
- return "st";
- case 2:
- case 22:
- return "nd";
- case 3:
- case 23:
- return "rd";
- default:
- return "th";
- }
- };
- String.escape = function(a) {
- return a.replace(/('|\\)/g, "\\$1");
- };
- String.leftPad = function(d, b, c) {
- var a = new String(d);
- if (c == null) {
- c = " ";
- }
- while (a.length < b) {
- a = c + a;
- }
- return a;
- };
- Date.daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
- Date.monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
- Date.dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
- Date.y2kYear = 50;
- Date.monthNumbers = {
- Jan: 0,
- Feb: 1,
- Mar: 2,
- Apr: 3,
- May: 4,
- Jun: 5,
- Jul: 6,
- Aug: 7,
- Sep: 8,
- Oct: 9,
- Nov: 10,
- Dec: 11
- };
- Date.patterns = {
- ISO8601LongPattern: "Y-m-d H:i:s",
- ISO8601ShortPattern: "Y-m-d",
- ShortDatePattern: "n/j/Y",
- LongDatePattern: "l, F d, Y",
- FullDateTimePattern: "l, F d, Y g:i:s A",
- MonthDayPattern: "F d",
- ShortTimePattern: "g:i A",
- LongTimePattern: "g:i:s A",
- SortableDateTimePattern: "Y-m-d\\TH:i:s",
- UniversalSortableDateTimePattern: "Y-m-d H:i:sO",
- YearMonthPattern: "F, Y"
- };
-});
\ No newline at end of file
+});
+
+// Parse and Format Library
+//http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
+/*
+ * Copyright (C) 2004 Baron Schwartz
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, version 2.1.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var code="Date.prototype."+funcName+" = function() {return ";var special=false;var ch="";for(var i=0;i 0) {";var regex="";var special=false;var ch="";for(var i=0;i 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b';
if (options.maxDate !== false) {
- maxDate = xd_datetime.strToDate(options.maxDate);
+ maxDate = _xdsoft_datetime.strToDate(options.maxDate);
maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
}
if (options.minDate !== false) {
- minDate = xd_datetime.strToDate(options.minDate);
+ minDate = _xdsoft_datetime.strToDate(options.minDate);
minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
}
- while (i < xd_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || xd_datetime.currentTime.getMonth() === start.getMonth()) {
+ while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
classes = [];
i += 1;
d = start.getDate();
y = start.getFullYear();
m = start.getMonth();
- w = xd_datetime.getWeekOfYear(start);
+ w = _xdsoft_datetime.getWeekOfYear(start);
classes.push(XDC_DATE);
@@ -1058,11 +1058,11 @@
classes.push(customDateSettings[1]);
}
- if (xd_datetime.currentTime.getMonth() !== m) {
+ if (_xdsoft_datetime.currentTime.getMonth() !== m) {
classes.push(XDC_OTHER_MONTH);
}
- if ((options.defaultSelect || datetimepicker.data('changed')) && xd_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
+ if ((options.defaultSelect || datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
classes.push(XDC_CURRENT);
}
@@ -1101,27 +1101,27 @@
calendar.html(table);
- month_picker.find('.' + XDC_LABEL + ' span').eq(0).text(getI18n(options.lang,'months')[xd_datetime.currentTime.getMonth()]);
- month_picker.find('.' + XDC_LABEL + ' span').eq(1).text(xd_datetime.currentTime.getFullYear());
+ month_picker.find('.' + XDC_LABEL + ' span').eq(0).text(getI18n(options.lang,'months')[_xdsoft_datetime.currentTime.getMonth()]);
+ month_picker.find('.' + XDC_LABEL + ' span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
// generate timebox
time = '';
h = '';
m = '';
line_time = function line_time(h, m) {
- var now = xd_datetime.now();
+ var now = _xdsoft_datetime.now();
now.setHours(h);
h = parseInt(now.getHours(), 10);
now.setMinutes(m);
m = parseInt(now.getMinutes(), 10);
- var optionDateTime = new Date(xd_datetime.currentTime);
+ var optionDateTime = new Date(_xdsoft_datetime.currentTime);
optionDateTime.setHours(h);
optionDateTime.setMinutes(m);
classes = [];
- if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && xd_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && xd_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
+ 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())) {
classes.push(XDC_DISABLED);
}
- if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && parseInt(xd_datetime.currentTime.getHours(), 10) === parseInt(h, 10) && (options.step > 59 || Math[options.roundTime](xd_datetime.currentTime.getMinutes() / options.step) * options.step === parseInt(m, 10))) {
+ if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && parseInt(_xdsoft_datetime.currentTime.getHours(), 10) === parseInt(h, 10) && (options.step > 59 || Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step === parseInt(m, 10))) {
if (options.defaultSelect || datetimepicker.data('changed')) {
classes.push(XDC_CURRENT);
} else if (options.initTime) {
@@ -1144,8 +1144,8 @@
}
} else {
for (i = 0; i < options.allowTimes.length; i += 1) {
- h = xd_datetime.strtotime(options.allowTimes[i]).getHours();
- m = xd_datetime.strtotime(options.allowTimes[i]).getMinutes();
+ h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
+ m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
line_time(h, m);
}
}
@@ -1156,13 +1156,13 @@
i = 0;
for (i = parseInt(options.yearStart, 10) + options.yearOffset; i <= parseInt(options.yearEnd, 10) + options.yearOffset; i += 1) {
- opt += '' + i + '
';
+ opt += '' + i + '
';
}
yearselect.children().eq(0)
.html(opt);
for (i = 0, opt = ''; i <= 11; i += 1) {
- opt += '' + getI18n(options.lang,'months')[i] + '
';
+ opt += '' + getI18n(options.lang,'months')[i] + '
';
}
monthselect.children().eq(0).html(opt);
$(datetimepicker)
@@ -1198,11 +1198,11 @@
xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
timerclick += 1;
var $this = $(this),
- currentTime = xd_datetime.currentTime;
+ currentTime = _xdsoft_datetime.currentTime;
if (currentTime === undefined || currentTime === null) {
- xd_datetime.currentTime = xd_datetime.now();
- currentTime = xd_datetime.currentTime;
+ _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
+ currentTime = _xdsoft_datetime.currentTime;
}
if ($this.hasClass(XDC_DISABLED)) {
@@ -1216,13 +1216,13 @@
datetimepicker.trigger(XDE_SELECT, [currentTime]);
- input.val(xd_datetime.str());
+ input.val(_xdsoft_datetime.str());
if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === 0 && !options.timepicker))) && !options.inline) {
datetimepicker.trigger(XDE_CLOSE);
}
if (options.onSelectDate && $.isFunction(options.onSelectDate)) {
- options.onSelectDate.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), xdevent);
+ options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
}
datetimepicker.data('changed', true);
@@ -1237,11 +1237,11 @@
.on(XDE_CLICK, 'div', function(xdevent) {
xdevent.stopPropagation();
var $this = $(this),
- currentTime = xd_datetime.currentTime;
+ currentTime = _xdsoft_datetime.currentTime;
if (currentTime === undefined || currentTime === null) {
- xd_datetime.currentTime = xd_datetime.now();
- currentTime = xd_datetime.currentTime;
+ _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
+ currentTime = _xdsoft_datetime.currentTime;
}
if ($this.hasClass(XDC_DISABLED)) {
@@ -1251,13 +1251,13 @@
currentTime.setMinutes($this.data('minute'));
datetimepicker.trigger(XDE_SELECT, [currentTime]);
- datetimepicker.data('input').val(xd_datetime.str());
+ datetimepicker.data('input').val(_xdsoft_datetime.str());
if (!options.inline) {
datetimepicker.trigger(XDE_CLOSE);
}
if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
- options.onSelectTime.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), xdevent);
+ options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
}
datetimepicker.data('changed', true);
datetimepicker.trigger(XDE_XCHANGE);
@@ -1271,9 +1271,9 @@
return true;
}
if (event.deltaY < 0) {
- xd_datetime.nextMonth();
+ _xdsoft_datetime.nextMonth();
} else {
- xd_datetime.prevMonth();
+ _xdsoft_datetime.prevMonth();
}
return false;
});
@@ -1296,7 +1296,7 @@
if (options.datepicker && !options.timepicker) {
datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
if (input.val) {
- input.val(xd_datetime.str());
+ input.val(_xdsoft_datetime.str());
}
datetimepicker.trigger(XDE_CHANGEDATETIME);
return false;
@@ -1307,14 +1307,14 @@
.on(XDE_CHANGEDATETIME, function(event) {
if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
var $input = datetimepicker.data('input');
- options.onChangeDateTime.call(datetimepicker, xd_datetime.currentTime, $input, event);
+ options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
delete options.value;
$input.trigger('change');
}
})
.on(XDE_GENERATE, function() {
if (options.onGenerate && $.isFunction(options.onGenerate)) {
- options.onGenerate.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
if (triggerAfterOpen) {
datetimepicker.trigger(XDE_AFTEROPEN);
@@ -1357,7 +1357,7 @@
.on(XDE_OPEN, function(event) {
var onShow = true;
if (options.onShow && $.isFunction(options.onShow)) {
- onShow = options.onShow.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), event);
+ onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
}
if (onShow !== false) {
datetimepicker.show();
@@ -1381,7 +1381,7 @@
.find('.' + XDC_SELECT)
.hide();
if (options.onClose && $.isFunction(options.onClose)) {
- onClose = options.onClose.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), event);
+ onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
}
if (onClose !== false && !options.opened && !options.inline) {
datetimepicker.hide();
@@ -1400,7 +1400,7 @@
timer = 0;
timer1 = 0;
- datetimepicker.data(XDC_DATETIME, xd_datetime);
+ datetimepicker.data(XDC_DATETIME, _xdsoft_datetime);
datetimepicker.setOptions(options);
function getCurrentValue() {
@@ -1409,22 +1409,22 @@
time;
if (options.startDate) {
- ct = xd_datetime.strToDate(options.startDate);
+ ct = _xdsoft_datetime.strToDate(options.startDate);
} else {
ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
if (ct) {
- ct = xd_datetime.strToDateTime(ct);
+ ct = _xdsoft_datetime.strToDateTime(ct);
} else if (options.defaultDate) {
- ct = xd_datetime.strToDate(options.defaultDate);
+ ct = _xdsoft_datetime.strToDate(options.defaultDate);
if (options.defaultTime) {
- time = xd_datetime.strtotime(options.defaultTime);
+ time = _xdsoft_datetime.strtotime(options.defaultTime);
ct.setHours(time.getHours());
ct.setMinutes(time.getMinutes());
}
}
}
- if (ct && xd_datetime.isValidDate(ct)) {
+ if (ct && _xdsoft_datetime.isValidDate(ct)) {
datetimepicker.data('changed', true);
} else {
ct = '';
@@ -1433,7 +1433,7 @@
return ct || 0;
}
- xd_datetime.setCurrentTime(getCurrentValue());
+ _xdsoft_datetime.setCurrentTime(getCurrentValue());
input
.data(XDC_DATETIMEPICKER, datetimepicker)
@@ -1448,7 +1448,7 @@
}
triggerAfterOpen = true;
- xd_datetime.setCurrentTime(getCurrentValue());
+ _xdsoft_datetime.setCurrentTime(getCurrentValue());
datetimepicker.trigger(XDE_OPEN);
}, 100);
diff --git a/javascripts/datetimepicker.base.js b/javascripts/datetimepicker.base.js
index 2ae6de8..3077348 100644
--- a/javascripts/datetimepicker.base.js
+++ b/javascripts/datetimepicker.base.js
@@ -421,7 +421,7 @@ $.fn.datetimepicker = function(opt) {
setPos,
timer = 0,
timer1 = 0,
- xd_datetime;
+ _xdsoft_datetime;
month_picker
.find('.' + XDC_MONTH + ' span')
@@ -443,8 +443,8 @@ $.fn.datetimepicker = function(opt) {
month_picker
.find('.' + XDC_SELECT)
.hide();
- if (xd_datetime.currentTime) {
- val = xd_datetime.currentTime[$(this).hasClass(XDC_MONTH) ? 'getMonth' : 'getFullYear']();
+ if (_xdsoft_datetime.currentTime) {
+ val = _xdsoft_datetime.currentTime[$(this).hasClass(XDC_MONTH) ? 'getMonth' : 'getFullYear']();
}
select[visible ? 'hide' : 'show']();
@@ -469,20 +469,20 @@ $.fn.datetimepicker = function(opt) {
event.preventDefault();
})
.on(XDE_MOUSEDOWN, '.' + XDC_OPTION, function(event) {
- var year = xd_datetime.currentTime.getFullYear();
- if (xd_datetime && xd_datetime.currentTime) {
- xd_datetime.currentTime[$(this).parent().parent().hasClass(XDC_MONTHSELECT) ? 'setMonth' : 'setFullYear']($(this).data('value'));
+ var year = _xdsoft_datetime.currentTime.getFullYear();
+ if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
+ _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass(XDC_MONTHSELECT) ? 'setMonth' : 'setFullYear']($(this).data('value'));
}
$(this).parent().parent().hide();
datetimepicker.trigger(XDE_XCHANGE);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
- options.onChangeMonth.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
- if (year !== xd_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
- options.onChangeYear.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
+ options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
});
@@ -532,7 +532,7 @@ $.fn.datetimepicker = function(opt) {
if (input && input.val) {
input.val(options.value);
}
- xd_datetime.setCurrentTime(options.value);
+ _xdsoft_datetime.setCurrentTime(options.value);
}
setDayOfWeekStart(options);
@@ -542,11 +542,11 @@ $.fn.datetimepicker = function(opt) {
}
if (options.minDate && /^-(.*)$/.test(options.minDate)) {
- options.minDate = xd_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
+ options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
}
if (options.maxDate && /^\+(.*)$/.test(options.maxDate)) {
- options.maxDate = xd_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
+ options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
}
month_picker
@@ -675,7 +675,7 @@ $.fn.datetimepicker = function(opt) {
$(this).val(null);
datetimepicker.data(XDC_DATETIME).empty();
} else if (!Date.parseDate($(this).val(), options.format)) {
- $(this).val((xd_datetime.now()).dateFormat(options.format));
+ $(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
datetimepicker.data(XDC_DATETIME).setCurrentTime($(this).val());
} else {
datetimepicker.data(XDC_DATETIME).setCurrentTime($(this).val());
@@ -790,11 +790,11 @@ $.fn.datetimepicker = function(opt) {
_this.currentTime.setMonth(month);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
- options.onChangeMonth.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
- options.onChangeYear.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
datetimepicker.trigger(XDE_XCHANGE);
@@ -815,7 +815,7 @@ $.fn.datetimepicker = function(opt) {
);
_this.currentTime.setMonth(month);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
- options.onChangeMonth.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
datetimepicker.trigger(XDE_XCHANGE);
return month;
@@ -840,7 +840,7 @@ $.fn.datetimepicker = function(opt) {
}
if (tmpDate && tmpDate[2]) {
timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
- currentTime = new Date((xd_datetime.now()).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
+ currentTime = new Date((_xdsoft_datetime.now()).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
} else {
currentTime = sDateTime ? Date.parseDate(sDateTime, options.format) : _this.now();
}
@@ -881,16 +881,16 @@ $.fn.datetimepicker = function(opt) {
_this.currentTime = this.now();
};
- xd_datetime = new XDSoft_datetime();
+ _xdsoft_datetime = new XDSoft_datetime();
month_picker
.find('.' + XDC_TODAY_BUTTON)
.on(XDE_MOUSEDOWN, function() {
datetimepicker.data('changed', true);
- xd_datetime.setCurrentTime(0);
+ _xdsoft_datetime.setCurrentTime(0);
datetimepicker.trigger(XDE_AFTEROPEN);
}).on(XDE_DBLCLICK, function() {
- input.val(xd_datetime.str());
+ input.val(_xdsoft_datetime.str());
datetimepicker.trigger(XDE_CLOSE);
});
month_picker
@@ -901,11 +901,11 @@ $.fn.datetimepicker = function(opt) {
stop = false;
(function arguments_callee1(v) {
- var month = xd_datetime.currentTime.getMonth();
+ var month = _xdsoft_datetime.currentTime.getMonth();
if ($this.hasClass(options.next)) {
- xd_datetime.nextMonth();
+ _xdsoft_datetime.nextMonth();
} else if ($this.hasClass(options.prev)) {
- xd_datetime.prevMonth();
+ _xdsoft_datetime.prevMonth();
}
if (options.monthChangeSpinner) {
if (!stop) {
@@ -958,10 +958,10 @@ $.fn.datetimepicker = function(opt) {
clearTimeout(xchangeTimer);
xchangeTimer = setTimeout(function() {
var table = '',
- start = new Date(xd_datetime.currentTime.getFullYear(), xd_datetime.currentTime.getMonth(), 1, 12, 0, 0),
+ start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
i = 0,
j,
- today = xd_datetime.now(),
+ today = _xdsoft_datetime.now(),
maxDate = false,
minDate = false,
d,
@@ -993,23 +993,23 @@ $.fn.datetimepicker = function(opt) {
table += '';
if (options.maxDate !== false) {
- maxDate = xd_datetime.strToDate(options.maxDate);
+ maxDate = _xdsoft_datetime.strToDate(options.maxDate);
maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
}
if (options.minDate !== false) {
- minDate = xd_datetime.strToDate(options.minDate);
+ minDate = _xdsoft_datetime.strToDate(options.minDate);
minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
}
- while (i < xd_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || xd_datetime.currentTime.getMonth() === start.getMonth()) {
+ while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
classes = [];
i += 1;
d = start.getDate();
y = start.getFullYear();
m = start.getMonth();
- w = xd_datetime.getWeekOfYear(start);
+ w = _xdsoft_datetime.getWeekOfYear(start);
classes.push(XDC_DATE);
@@ -1029,11 +1029,11 @@ $.fn.datetimepicker = function(opt) {
classes.push(customDateSettings[1]);
}
- if (xd_datetime.currentTime.getMonth() !== m) {
+ if (_xdsoft_datetime.currentTime.getMonth() !== m) {
classes.push(XDC_OTHER_MONTH);
}
- if ((options.defaultSelect || datetimepicker.data('changed')) && xd_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
+ if ((options.defaultSelect || datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
classes.push(XDC_CURRENT);
}
@@ -1072,27 +1072,27 @@ $.fn.datetimepicker = function(opt) {
calendar.html(table);
- month_picker.find('.' + XDC_LABEL + ' span').eq(0).text(getI18n(options.lang,'months')[xd_datetime.currentTime.getMonth()]);
- month_picker.find('.' + XDC_LABEL + ' span').eq(1).text(xd_datetime.currentTime.getFullYear());
+ month_picker.find('.' + XDC_LABEL + ' span').eq(0).text(getI18n(options.lang,'months')[_xdsoft_datetime.currentTime.getMonth()]);
+ month_picker.find('.' + XDC_LABEL + ' span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
// generate timebox
time = '';
h = '';
m = '';
line_time = function line_time(h, m) {
- var now = xd_datetime.now();
+ var now = _xdsoft_datetime.now();
now.setHours(h);
h = parseInt(now.getHours(), 10);
now.setMinutes(m);
m = parseInt(now.getMinutes(), 10);
- var optionDateTime = new Date(xd_datetime.currentTime);
+ var optionDateTime = new Date(_xdsoft_datetime.currentTime);
optionDateTime.setHours(h);
optionDateTime.setMinutes(m);
classes = [];
- if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && xd_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && xd_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
+ 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())) {
classes.push(XDC_DISABLED);
}
- if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && parseInt(xd_datetime.currentTime.getHours(), 10) === parseInt(h, 10) && (options.step > 59 || Math[options.roundTime](xd_datetime.currentTime.getMinutes() / options.step) * options.step === parseInt(m, 10))) {
+ if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && parseInt(_xdsoft_datetime.currentTime.getHours(), 10) === parseInt(h, 10) && (options.step > 59 || Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step === parseInt(m, 10))) {
if (options.defaultSelect || datetimepicker.data('changed')) {
classes.push(XDC_CURRENT);
} else if (options.initTime) {
@@ -1115,8 +1115,8 @@ $.fn.datetimepicker = function(opt) {
}
} else {
for (i = 0; i < options.allowTimes.length; i += 1) {
- h = xd_datetime.strtotime(options.allowTimes[i]).getHours();
- m = xd_datetime.strtotime(options.allowTimes[i]).getMinutes();
+ h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
+ m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
line_time(h, m);
}
}
@@ -1127,13 +1127,13 @@ $.fn.datetimepicker = function(opt) {
i = 0;
for (i = parseInt(options.yearStart, 10) + options.yearOffset; i <= parseInt(options.yearEnd, 10) + options.yearOffset; i += 1) {
- opt += '' + i + '
';
+ opt += '' + i + '
';
}
yearselect.children().eq(0)
.html(opt);
for (i = 0, opt = ''; i <= 11; i += 1) {
- opt += '' + getI18n(options.lang,'months')[i] + '
';
+ opt += '' + getI18n(options.lang,'months')[i] + '
';
}
monthselect.children().eq(0).html(opt);
$(datetimepicker)
@@ -1169,11 +1169,11 @@ $.fn.datetimepicker = function(opt) {
xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
timerclick += 1;
var $this = $(this),
- currentTime = xd_datetime.currentTime;
+ currentTime = _xdsoft_datetime.currentTime;
if (currentTime === undefined || currentTime === null) {
- xd_datetime.currentTime = xd_datetime.now();
- currentTime = xd_datetime.currentTime;
+ _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
+ currentTime = _xdsoft_datetime.currentTime;
}
if ($this.hasClass(XDC_DISABLED)) {
@@ -1187,13 +1187,13 @@ $.fn.datetimepicker = function(opt) {
datetimepicker.trigger(XDE_SELECT, [currentTime]);
- input.val(xd_datetime.str());
+ input.val(_xdsoft_datetime.str());
if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === 0 && !options.timepicker))) && !options.inline) {
datetimepicker.trigger(XDE_CLOSE);
}
if (options.onSelectDate && $.isFunction(options.onSelectDate)) {
- options.onSelectDate.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), xdevent);
+ options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
}
datetimepicker.data('changed', true);
@@ -1208,11 +1208,11 @@ $.fn.datetimepicker = function(opt) {
.on(XDE_CLICK, 'div', function(xdevent) {
xdevent.stopPropagation();
var $this = $(this),
- currentTime = xd_datetime.currentTime;
+ currentTime = _xdsoft_datetime.currentTime;
if (currentTime === undefined || currentTime === null) {
- xd_datetime.currentTime = xd_datetime.now();
- currentTime = xd_datetime.currentTime;
+ _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
+ currentTime = _xdsoft_datetime.currentTime;
}
if ($this.hasClass(XDC_DISABLED)) {
@@ -1222,13 +1222,13 @@ $.fn.datetimepicker = function(opt) {
currentTime.setMinutes($this.data('minute'));
datetimepicker.trigger(XDE_SELECT, [currentTime]);
- datetimepicker.data('input').val(xd_datetime.str());
+ datetimepicker.data('input').val(_xdsoft_datetime.str());
if (!options.inline) {
datetimepicker.trigger(XDE_CLOSE);
}
if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
- options.onSelectTime.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), xdevent);
+ options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
}
datetimepicker.data('changed', true);
datetimepicker.trigger(XDE_XCHANGE);
@@ -1242,9 +1242,9 @@ $.fn.datetimepicker = function(opt) {
return true;
}
if (event.deltaY < 0) {
- xd_datetime.nextMonth();
+ _xdsoft_datetime.nextMonth();
} else {
- xd_datetime.prevMonth();
+ _xdsoft_datetime.prevMonth();
}
return false;
});
@@ -1267,7 +1267,7 @@ $.fn.datetimepicker = function(opt) {
if (options.datepicker && !options.timepicker) {
datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
if (input.val) {
- input.val(xd_datetime.str());
+ input.val(_xdsoft_datetime.str());
}
datetimepicker.trigger(XDE_CHANGEDATETIME);
return false;
@@ -1278,14 +1278,14 @@ $.fn.datetimepicker = function(opt) {
.on(XDE_CHANGEDATETIME, function(event) {
if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
var $input = datetimepicker.data('input');
- options.onChangeDateTime.call(datetimepicker, xd_datetime.currentTime, $input, event);
+ options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
delete options.value;
$input.trigger('change');
}
})
.on(XDE_GENERATE, function() {
if (options.onGenerate && $.isFunction(options.onGenerate)) {
- options.onGenerate.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'));
+ options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
if (triggerAfterOpen) {
datetimepicker.trigger(XDE_AFTEROPEN);
@@ -1328,7 +1328,7 @@ $.fn.datetimepicker = function(opt) {
.on(XDE_OPEN, function(event) {
var onShow = true;
if (options.onShow && $.isFunction(options.onShow)) {
- onShow = options.onShow.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), event);
+ onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
}
if (onShow !== false) {
datetimepicker.show();
@@ -1352,7 +1352,7 @@ $.fn.datetimepicker = function(opt) {
.find('.' + XDC_SELECT)
.hide();
if (options.onClose && $.isFunction(options.onClose)) {
- onClose = options.onClose.call(datetimepicker, xd_datetime.currentTime, datetimepicker.data('input'), event);
+ onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
}
if (onClose !== false && !options.opened && !options.inline) {
datetimepicker.hide();
@@ -1371,7 +1371,7 @@ $.fn.datetimepicker = function(opt) {
timer = 0;
timer1 = 0;
- datetimepicker.data(XDC_DATETIME, xd_datetime);
+ datetimepicker.data(XDC_DATETIME, _xdsoft_datetime);
datetimepicker.setOptions(options);
function getCurrentValue() {
@@ -1380,22 +1380,22 @@ $.fn.datetimepicker = function(opt) {
time;
if (options.startDate) {
- ct = xd_datetime.strToDate(options.startDate);
+ ct = _xdsoft_datetime.strToDate(options.startDate);
} else {
ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
if (ct) {
- ct = xd_datetime.strToDateTime(ct);
+ ct = _xdsoft_datetime.strToDateTime(ct);
} else if (options.defaultDate) {
- ct = xd_datetime.strToDate(options.defaultDate);
+ ct = _xdsoft_datetime.strToDate(options.defaultDate);
if (options.defaultTime) {
- time = xd_datetime.strtotime(options.defaultTime);
+ time = _xdsoft_datetime.strtotime(options.defaultTime);
ct.setHours(time.getHours());
ct.setMinutes(time.getMinutes());
}
}
}
- if (ct && xd_datetime.isValidDate(ct)) {
+ if (ct && _xdsoft_datetime.isValidDate(ct)) {
datetimepicker.data('changed', true);
} else {
ct = '';
@@ -1404,7 +1404,7 @@ $.fn.datetimepicker = function(opt) {
return ct || 0;
}
- xd_datetime.setCurrentTime(getCurrentValue());
+ _xdsoft_datetime.setCurrentTime(getCurrentValue());
input
.data(XDC_DATETIMEPICKER, datetimepicker)
@@ -1419,7 +1419,7 @@ $.fn.datetimepicker = function(opt) {
}
triggerAfterOpen = true;
- xd_datetime.setCurrentTime(getCurrentValue());
+ _xdsoft_datetime.setCurrentTime(getCurrentValue());
datetimepicker.trigger(XDE_OPEN);
}, 100);
diff --git a/javascripts/jquery.datetimepicker.js b/javascripts/jquery.datetimepicker.js
index f1ffa82..9b7a776 100644
--- a/javascripts/jquery.datetimepicker.js
+++ b/javascripts/jquery.datetimepicker.js
@@ -434,5 +434,5 @@
}
};
//= datetimepicker.base.js
- //= parse.js
-});
\ No newline at end of file
+});
+//= parse.js
\ No newline at end of file
diff --git a/javascripts/parse.js b/javascripts/parse.js
index bfb6998..eeeb01f 100644
--- a/javascripts/parse.js
+++ b/javascripts/parse.js
@@ -1,3 +1,4 @@
+
// Parse and Format Library
//http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
/*
@@ -12,386 +13,4 @@
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
-Date.parseFunctions = {
- count: 0
-};
-Date.parseRegexes = [];
-Date.formatFunctions = {
- count: 0
-};
-Date.prototype.dateFormat = function(b) {
- if (b == "unixtime") {
- return parseInt(this.getTime() / 1000);
- }
- if (Date.formatFunctions[b] == null) {
- Date.createNewFormat(b);
- }
- var a = Date.formatFunctions[b];
- return this[a]();
-};
-Date.createNewFormat = function(format) {
- var funcName = "format" + Date.formatFunctions.count++;
- Date.formatFunctions[format] = funcName;
- var code = "Date.prototype." + funcName + " = function() {return ";
- var special = false;
- var ch = "";
- for (var i = 0; i < format.length; ++i) {
- ch = format.charAt(i);
- if (!special && ch == "\\") {
- special = true;
- } else {
- if (special) {
- special = false;
- code += "'" + String.escape(ch) + "' + ";
- } else {
- code += Date.getFormatCode(ch);
- }
- }
- }
- eval(code.substring(0, code.length - 3) + ";}");
-};
-Date.getFormatCode = function(a) {
- switch (a) {
- case "d":
- return "String.leftPad(this.getDate(), 2, '0') + ";
- case "D":
- return "Date.dayNames[this.getDay()].substring(0, 3) + ";
- case "j":
- return "this.getDate() + ";
- case "l":
- return "Date.dayNames[this.getDay()] + ";
- case "S":
- return "this.getSuffix() + ";
- case "w":
- return "this.getDay() + ";
- case "z":
- return "this.getDayOfYear() + ";
- case "W":
- return "this.getWeekOfYear() + ";
- case "F":
- return "Date.monthNames[this.getMonth()] + ";
- case "m":
- return "String.leftPad(this.getMonth() + 1, 2, '0') + ";
- case "M":
- return "Date.monthNames[this.getMonth()].substring(0, 3) + ";
- case "n":
- return "(this.getMonth() + 1) + ";
- case "t":
- return "this.getDaysInMonth() + ";
- case "L":
- return "(this.isLeapYear() ? 1 : 0) + ";
- case "Y":
- return "this.getFullYear() + ";
- case "y":
- return "('' + this.getFullYear()).substring(2, 4) + ";
- case "a":
- return "(this.getHours() < 12 ? 'am' : 'pm') + ";
- case "A":
- return "(this.getHours() < 12 ? 'AM' : 'PM') + ";
- case "g":
- return "((this.getHours() %12) ? this.getHours() % 12 : 12) + ";
- case "G":
- return "this.getHours() + ";
- case "h":
- return "String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";
- case "H":
- return "String.leftPad(this.getHours(), 2, '0') + ";
- case "i":
- return "String.leftPad(this.getMinutes(), 2, '0') + ";
- case "s":
- return "String.leftPad(this.getSeconds(), 2, '0') + ";
- case "O":
- return "this.getGMTOffset() + ";
- case "T":
- return "this.getTimezone() + ";
- case "Z":
- return "(this.getTimezoneOffset() * -60) + ";
- default:
- return "'" + String.escape(a) + "' + ";
- }
-};
-Date.parseDate = function(a, c) {
- if (c == "unixtime") {
- return new Date(!isNaN(parseInt(a)) ? parseInt(a) * 1000 : 0);
- }
- if (Date.parseFunctions[c] == null) {
- Date.createParser(c);
- }
- var b = Date.parseFunctions[c];
- return Date[b](a);
-};
-Date.createParser = function(format) {
- var funcName = "parse" + Date.parseFunctions.count++;
- var regexNum = Date.parseRegexes.length;
- var currentGroup = 1;
- Date.parseFunctions[format] = funcName;
- var code = "Date." + funcName + " = function(input) {\nvar y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, z = -1;\nvar d = new Date();\ny = d.getFullYear();\nm = d.getMonth();\nd = d.getDate();\nvar results = input.match(Date.parseRegexes[" + regexNum + "]);\nif (results && results.length > 0) {";
- var regex = "";
- var special = false;
- var ch = "";
- for (var i = 0; i < format.length; ++i) {
- ch = format.charAt(i);
- if (!special && ch == "\\") {
- special = true;
- } else {
- if (special) {
- special = false;
- regex += String.escape(ch);
- } else {
- obj = Date.formatCodeToRegex(ch, currentGroup);
- currentGroup += obj.g;
- regex += obj.s;
- if (obj.g && obj.c) {
- code += obj.c;
- }
- }
- }
- }
- code += "if (y > 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";
- code += "if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";
- Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$");
- eval(code);
-};
-Date.formatCodeToRegex = function(b, a) {
- switch (b) {
- case "D":
- return {
- g: 0,
- c: null,
- s: "(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"
- };
- case "j":
- case "d":
- return {
- g: 1,
- c: "d = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{1,2})"
- };
- case "l":
- return {
- g: 0,
- c: null,
- s: "(?:" + Date.dayNames.join("|") + ")"
- };
- case "S":
- return {
- g: 0,
- c: null,
- s: "(?:st|nd|rd|th)"
- };
- case "w":
- return {
- g: 0,
- c: null,
- s: "\\d"
- };
- case "z":
- return {
- g: 1,
- c: "z = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{1,3})"
- };
- case "W":
- return {
- g: 0,
- c: null,
- s: "(?:\\d{2})"
- };
- case "F":
- return {
- g: 1,
- c: "m = parseInt(Date.monthNumbers[results[" + a + "].substring(0, 3)], 10);\n",
- s: "(" + Date.monthNames.join("|") + ")"
- };
- case "M":
- return {
- g: 1,
- c: "m = parseInt(Date.monthNumbers[results[" + a + "]], 10);\n",
- s: "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"
- };
- case "n":
- case "m":
- return {
- g: 1,
- c: "m = parseInt(results[" + a + "], 10) - 1;\n",
- s: "(\\d{1,2})"
- };
- case "t":
- return {
- g: 0,
- c: null,
- s: "\\d{1,2}"
- };
- case "L":
- return {
- g: 0,
- c: null,
- s: "(?:1|0)"
- };
- case "Y":
- return {
- g: 1,
- c: "y = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{4})"
- };
- case "y":
- return {
- g: 1,
- c: "var ty = parseInt(results[" + a + "], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
- s: "(\\d{1,2})"
- };
- case "a":
- return {
- g: 1,
- c: "if (results[" + a + "] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",
- s: "(am|pm)"
- };
- case "A":
- return {
- g: 1,
- c: "if (results[" + a + "] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",
- s: "(AM|PM)"
- };
- case "g":
- case "G":
- case "h":
- case "H":
- return {
- g: 1,
- c: "h = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{1,2})"
- };
- case "i":
- return {
- g: 1,
- c: "i = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{2})"
- };
- case "s":
- return {
- g: 1,
- c: "s = parseInt(results[" + a + "], 10);\n",
- s: "(\\d{2})"
- };
- case "O":
- return {
- g: 0,
- c: null,
- s: "[+-]\\d{4}"
- };
- case "T":
- return {
- g: 0,
- c: null,
- s: "[A-Z]{3}"
- };
- case "Z":
- return {
- g: 0,
- c: null,
- s: "[+-]\\d{1,5}"
- };
- default:
- return {
- g: 0,
- c: null,
- s: String.escape(b)
- };
- }
-};
-Date.prototype.getTimezone = function() {
- return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/, "$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3");
-};
-Date.prototype.getGMTOffset = function() {
- return (this.getTimezoneOffset() > 0 ? "-" : "+") + String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset()) / 60), 2, "0") + String.leftPad(Math.abs(this.getTimezoneOffset()) % 60, 2, "0");
-};
-Date.prototype.getDayOfYear = function() {
- var a = 0;
- Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
- for (var b = 0; b < this.getMonth(); ++b) {
- a += Date.daysInMonth[b];
- }
- return a + this.getDate();
-};
-Date.prototype.getWeekOfYear = function() {
- var b = this.getDayOfYear() + (4 - this.getDay());
- var a = new Date(this.getFullYear(), 0, 1);
- var c = (7 - a.getDay() + 4);
- return String.leftPad(Math.ceil((b - c) / 7) + 1, 2, "0");
-};
-Date.prototype.isLeapYear = function() {
- var a = this.getFullYear();
- return ((a & 3) == 0 && (a % 100 || (a % 400 == 0 && a)));
-};
-Date.prototype.getFirstDayOfMonth = function() {
- var a = (this.getDay() - (this.getDate() - 1)) % 7;
- return (a < 0) ? (a + 7) : a;
-};
-Date.prototype.getLastDayOfMonth = function() {
- var a = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
- return (a < 0) ? (a + 7) : a;
-};
-Date.prototype.getDaysInMonth = function() {
- Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
- return Date.daysInMonth[this.getMonth()];
-};
-Date.prototype.getSuffix = function() {
- switch (this.getDate()) {
- case 1:
- case 21:
- case 31:
- return "st";
- case 2:
- case 22:
- return "nd";
- case 3:
- case 23:
- return "rd";
- default:
- return "th";
- }
-};
-String.escape = function(a) {
- return a.replace(/('|\\)/g, "\\$1");
-};
-String.leftPad = function(d, b, c) {
- var a = new String(d);
- if (c == null) {
- c = " ";
- }
- while (a.length < b) {
- a = c + a;
- }
- return a;
-};
-Date.daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
-Date.monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
-Date.dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
-Date.y2kYear = 50;
-Date.monthNumbers = {
- Jan: 0,
- Feb: 1,
- Mar: 2,
- Apr: 3,
- May: 4,
- Jun: 5,
- Jul: 6,
- Aug: 7,
- Sep: 8,
- Oct: 9,
- Nov: 10,
- Dec: 11
-};
-Date.patterns = {
- ISO8601LongPattern: "Y-m-d H:i:s",
- ISO8601ShortPattern: "Y-m-d",
- ShortDatePattern: "n/j/Y",
- LongDatePattern: "l, F d, Y",
- FullDateTimePattern: "l, F d, Y g:i:s A",
- MonthDayPattern: "F d",
- ShortTimePattern: "g:i A",
- LongTimePattern: "g:i:s A",
- SortableDateTimePattern: "Y-m-d\\TH:i:s",
- UniversalSortableDateTimePattern: "Y-m-d H:i:sO",
- YearMonthPattern: "F, Y"
-};
\ No newline at end of file
+Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var code="Date.prototype."+funcName+" = function() {return ";var special=false;var ch="";for(var i=0;i 0) {";var regex="";var special=false;var ch="";for(var i=0;i 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b