datatables.net-datetime 1.1.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/datatables.net-datetime.1.3.0.nupkg +0 -0
- package/dist/dataTables.dateTime.js +162 -67
- package/dist/dataTables.dateTime.min.js +6 -43
- package/dist/dataTables.dateTime.min.mjs +6 -0
- package/dist/dataTables.dateTime.mjs +1628 -0
- package/docs/api/valFormat().xml +52 -0
- package/docs/option/buttons.today.xml +1 -1
- package/examples/initialisation/datetime.xml +1 -1
- package/examples/initialisation/dayjs.xml +7 -5
- package/examples/initialisation/luxon.xml +1 -1
- package/js/dataTables.dateTime.d.ts +60 -46
- package/js/dataTables.dateTime.js +144 -87
- package/make.sh +2 -1
- package/nuget.nuspec +1 -1
- package/package.json +2 -1
- package/test/api/dateTime.val().js +1 -1
- package/test/api/dateTime.valFormat()-luxon.js +83 -0
- package/test/api/dateTime.valFormat().js +83 -0
|
Binary file
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
/*! DateTime picker for DataTables.net v1.
|
|
1
|
+
/*! DateTime picker for DataTables.net v1.3.0
|
|
2
2
|
*
|
|
3
3
|
* © SpryMedia Ltd, all rights reserved.
|
|
4
4
|
* License: MIT datatables.net/license/mit
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @summary DateTime picker for DataTables.net
|
|
9
|
-
* @version 1.1.2
|
|
10
|
-
* @file dataTables.dateTime.js
|
|
11
|
-
* @author SpryMedia Ltd
|
|
12
|
-
* @contact www.datatables.net/contact
|
|
13
|
-
*/
|
|
14
7
|
(function( factory ){
|
|
15
8
|
if ( typeof define === 'function' && define.amd ) {
|
|
16
9
|
// AMD
|
|
@@ -22,9 +15,17 @@
|
|
|
22
15
|
// CommonJS
|
|
23
16
|
module.exports = function (root, $) {
|
|
24
17
|
if ( ! root ) {
|
|
18
|
+
// CommonJS environments without a window global must pass a
|
|
19
|
+
// root. This will give an error otherwise
|
|
25
20
|
root = window;
|
|
26
21
|
}
|
|
27
22
|
|
|
23
|
+
if ( ! $ ) {
|
|
24
|
+
$ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
|
|
25
|
+
require('jquery') :
|
|
26
|
+
require('jquery')( root );
|
|
27
|
+
}
|
|
28
|
+
|
|
28
29
|
return factory( $, root, root.document );
|
|
29
30
|
};
|
|
30
31
|
}
|
|
@@ -35,6 +36,16 @@
|
|
|
35
36
|
}(function( $, window, document, undefined ) {
|
|
36
37
|
'use strict';
|
|
37
38
|
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @summary DateTime picker for DataTables.net
|
|
43
|
+
* @version 1.3.0
|
|
44
|
+
* @file dataTables.dateTime.js
|
|
45
|
+
* @author SpryMedia Ltd
|
|
46
|
+
* @contact www.datatables.net/contact
|
|
47
|
+
*/
|
|
48
|
+
|
|
38
49
|
// Supported formatting and parsing libraries:
|
|
39
50
|
// * Moment
|
|
40
51
|
// * Luxon
|
|
@@ -87,25 +98,16 @@ var DateTime = function ( input, opts ) {
|
|
|
87
98
|
this.c.maxDate = new Date(this.c.maxDate);
|
|
88
99
|
}
|
|
89
100
|
|
|
90
|
-
var timeBlock = function ( type ) {
|
|
91
|
-
return '<div class="'+classPrefix+'-timeblock">'+
|
|
92
|
-
'</div>';
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
var gap = function () {
|
|
96
|
-
return '<span>:</span>';
|
|
97
|
-
};
|
|
98
|
-
|
|
99
101
|
// DOM structure
|
|
100
102
|
var structure = $(
|
|
101
103
|
'<div class="'+classPrefix+'">'+
|
|
102
104
|
'<div class="'+classPrefix+'-date">'+
|
|
103
105
|
'<div class="'+classPrefix+'-title">'+
|
|
104
106
|
'<div class="'+classPrefix+'-iconLeft">'+
|
|
105
|
-
'<button type="button"
|
|
107
|
+
'<button type="button"></button>'+
|
|
106
108
|
'</div>'+
|
|
107
109
|
'<div class="'+classPrefix+'-iconRight">'+
|
|
108
|
-
'<button type="button"
|
|
110
|
+
'<button type="button"></button>'+
|
|
109
111
|
'</div>'+
|
|
110
112
|
'<div class="'+classPrefix+'-label">'+
|
|
111
113
|
'<span></span>'+
|
|
@@ -117,8 +119,8 @@ var DateTime = function ( input, opts ) {
|
|
|
117
119
|
'</div>'+
|
|
118
120
|
'</div>'+
|
|
119
121
|
'<div class="'+classPrefix+'-buttons">'+
|
|
120
|
-
'<a class="'+classPrefix+'-clear"
|
|
121
|
-
'<a class="'+classPrefix+'-today"
|
|
122
|
+
'<a class="'+classPrefix+'-clear"></a>'+
|
|
123
|
+
'<a class="'+classPrefix+'-today"></a>'+
|
|
122
124
|
'</div>'+
|
|
123
125
|
'<div class="'+classPrefix+'-calendar"></div>'+
|
|
124
126
|
'</div>'+
|
|
@@ -138,9 +140,11 @@ var DateTime = function ( input, opts ) {
|
|
|
138
140
|
calendar: structure.find( '.'+classPrefix+'-calendar' ),
|
|
139
141
|
time: structure.find( '.'+classPrefix+'-time' ),
|
|
140
142
|
error: structure.find( '.'+classPrefix+'-error' ),
|
|
141
|
-
buttons:
|
|
143
|
+
buttons: structure.find( '.'+classPrefix+'-buttons' ),
|
|
142
144
|
clear: structure.find( '.'+classPrefix+'-clear' ),
|
|
143
145
|
today: structure.find( '.'+classPrefix+'-today' ),
|
|
146
|
+
previous: structure.find( '.'+classPrefix+'-iconLeft' ),
|
|
147
|
+
next: structure.find( '.'+classPrefix+'-iconRight' ),
|
|
144
148
|
input: $(input)
|
|
145
149
|
};
|
|
146
150
|
|
|
@@ -268,28 +272,10 @@ $.extend( DateTime.prototype, {
|
|
|
268
272
|
this.s.d = null;
|
|
269
273
|
}
|
|
270
274
|
else if ( set === '--now' ) {
|
|
271
|
-
this.s.d = new Date();
|
|
275
|
+
this.s.d = this._dateToUtc(new Date());
|
|
272
276
|
}
|
|
273
277
|
else if ( typeof set === 'string' ) {
|
|
274
|
-
|
|
275
|
-
if(dateLib && dateLib == window.luxon) {
|
|
276
|
-
var luxDT = dateLib.DateTime.fromFormat(set, this.c.format)
|
|
277
|
-
this.s.d = luxDT.isValid ? luxDT.toJSDate() : null;
|
|
278
|
-
}
|
|
279
|
-
else if ( dateLib ) {
|
|
280
|
-
// Use moment, dayjs or luxon if possible (even for ISO8601 strings, since it
|
|
281
|
-
// will correctly handle 0000-00-00 and the like)
|
|
282
|
-
var m = dateLib.utc( set, this.c.format, this.c.locale, this.c.strict );
|
|
283
|
-
this.s.d = m.isValid() ? m.toDate() : null;
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
// Else must be using ISO8601 without a date library (constructor would
|
|
287
|
-
// have thrown an error otherwise)
|
|
288
|
-
var match = set.match(/(\d{4})\-(\d{2})\-(\d{2})/ );
|
|
289
|
-
this.s.d = match ?
|
|
290
|
-
new Date( Date.UTC(match[1], match[2]-1, match[3]) ) :
|
|
291
|
-
null;
|
|
292
|
-
}
|
|
278
|
+
this.s.d = this._convert(set, this.c.format, null);
|
|
293
279
|
}
|
|
294
280
|
|
|
295
281
|
if ( write || write === undefined ) {
|
|
@@ -319,6 +305,25 @@ $.extend( DateTime.prototype, {
|
|
|
319
305
|
return this;
|
|
320
306
|
},
|
|
321
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Similar to `val()` but uses a given date / time format
|
|
310
|
+
*
|
|
311
|
+
* @param format Format to get the data as (getter) or that is input (setter)
|
|
312
|
+
* @param val Value to write (if undefined, used as a getter)
|
|
313
|
+
* @returns
|
|
314
|
+
*/
|
|
315
|
+
valFormat: function (format, val) {
|
|
316
|
+
if (! val) {
|
|
317
|
+
return this._convert(this.val(), null, format);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Convert from the format given here to the instance's configured format
|
|
321
|
+
this.val(
|
|
322
|
+
this._convert(val, format, null)
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
return this;
|
|
326
|
+
},
|
|
322
327
|
|
|
323
328
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
324
329
|
* Constructor
|
|
@@ -586,6 +591,7 @@ $.extend( DateTime.prototype, {
|
|
|
586
591
|
'setSeconds';
|
|
587
592
|
|
|
588
593
|
d[set]( val );
|
|
594
|
+
that._setCalander();
|
|
589
595
|
that._setTime();
|
|
590
596
|
that._writeOutput( true );
|
|
591
597
|
onChange();
|
|
@@ -619,6 +625,7 @@ $.extend( DateTime.prototype, {
|
|
|
619
625
|
}
|
|
620
626
|
else {
|
|
621
627
|
that._setCalander();
|
|
628
|
+
that._setTime();
|
|
622
629
|
}
|
|
623
630
|
|
|
624
631
|
onChange();
|
|
@@ -648,11 +655,75 @@ $.extend( DateTime.prototype, {
|
|
|
648
655
|
_compareDates: function( a, b ) {
|
|
649
656
|
// Can't use toDateString as that converts to local time
|
|
650
657
|
// luxon uses different method names so need to be able to call them
|
|
651
|
-
return
|
|
652
|
-
? dateLib.DateTime.fromJSDate(a).toISODate() === dateLib.DateTime.fromJSDate(b).toISODate()
|
|
658
|
+
return this._isLuxon()
|
|
659
|
+
? dateLib.DateTime.fromJSDate(a).toUTC().toISODate() === dateLib.DateTime.fromJSDate(b).toUTC().toISODate()
|
|
653
660
|
: this._dateToUtcString(a) === this._dateToUtcString(b);
|
|
654
661
|
},
|
|
655
662
|
|
|
663
|
+
/**
|
|
664
|
+
* Convert from one format to another
|
|
665
|
+
*
|
|
666
|
+
* @param {string|Date} val Value
|
|
667
|
+
* @param {string|null} from Format to convert from. If null a `Date` must be given
|
|
668
|
+
* @param {string|null} to Format to convert to. If null a `Date` will be returned
|
|
669
|
+
* @returns {string|Date} Converted value
|
|
670
|
+
*/
|
|
671
|
+
_convert(val, from, to) {
|
|
672
|
+
if (! val) {
|
|
673
|
+
return val;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
if (! dateLib) {
|
|
677
|
+
// Note that in here from and to can either be null or YYYY-MM-DD
|
|
678
|
+
// They cannot be anything else
|
|
679
|
+
if ((! from && ! to) || (from && to)) {
|
|
680
|
+
// No conversion
|
|
681
|
+
return val;
|
|
682
|
+
}
|
|
683
|
+
else if (! from) {
|
|
684
|
+
// Date in, string back
|
|
685
|
+
return val.getUTCFullYear() +'-'+
|
|
686
|
+
this._pad(val.getUTCMonth() + 1) +'-'+
|
|
687
|
+
this._pad(val.getUTCDate());
|
|
688
|
+
}
|
|
689
|
+
else { // (! to)
|
|
690
|
+
// String in, date back
|
|
691
|
+
var match = val.match(/(\d{4})\-(\d{2})\-(\d{2})/ );
|
|
692
|
+
return match ?
|
|
693
|
+
new Date( Date.UTC(match[1], match[2]-1, match[3]) ) :
|
|
694
|
+
null;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
else if (this._isLuxon()) {
|
|
698
|
+
// Luxon
|
|
699
|
+
var dtLux = val instanceof Date
|
|
700
|
+
? dateLib.DateTime.fromJSDate(val).toUTC()
|
|
701
|
+
: dateLib.DateTime.fromFormat(val, from);
|
|
702
|
+
|
|
703
|
+
if (! dtLux.isValid) {
|
|
704
|
+
return null;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
return to
|
|
708
|
+
? dtLux.toFormat(to)
|
|
709
|
+
: this._dateToUtc(dtLux.toJSDate());
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
// Moment / DayJS
|
|
713
|
+
var dtMo = val instanceof Date
|
|
714
|
+
? dateLib.utc( val, undefined, this.c.locale, this.c.strict )
|
|
715
|
+
: dateLib.utc( val, from, this.c.locale, this.c.strict );
|
|
716
|
+
|
|
717
|
+
if (! dtMo.isValid()) {
|
|
718
|
+
return null;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
return to
|
|
722
|
+
? dtMo.format(to)
|
|
723
|
+
: dtMo.toDate();
|
|
724
|
+
}
|
|
725
|
+
},
|
|
726
|
+
|
|
656
727
|
/**
|
|
657
728
|
* When changing month, take account of the fact that some months don't have
|
|
658
729
|
* the same number of days. For example going from January to February you
|
|
@@ -714,8 +785,8 @@ $.extend( DateTime.prototype, {
|
|
|
714
785
|
*/
|
|
715
786
|
_dateToUtcString: function ( d ) {
|
|
716
787
|
// luxon uses different method names so need to be able to call them
|
|
717
|
-
return
|
|
718
|
-
? dateLib.DateTime.fromJSDate(d).toISODate()
|
|
788
|
+
return this._isLuxon()
|
|
789
|
+
? dateLib.DateTime.fromJSDate(d).toUTC().toISODate()
|
|
719
790
|
: d.getUTCFullYear()+'-'+
|
|
720
791
|
this._pad(d.getUTCMonth()+1)+'-'+
|
|
721
792
|
this._pad(d.getUTCDate());
|
|
@@ -974,6 +1045,17 @@ $.extend( DateTime.prototype, {
|
|
|
974
1045
|
return '<td class="'+this.c.classPrefix+'-week">' + weekNum + '</td>';
|
|
975
1046
|
},
|
|
976
1047
|
|
|
1048
|
+
/**
|
|
1049
|
+
* Determine if Luxon is being used
|
|
1050
|
+
*
|
|
1051
|
+
* @returns Flag for Luxon
|
|
1052
|
+
*/
|
|
1053
|
+
_isLuxon: function () {
|
|
1054
|
+
return dateLib && dateLib.DateTime && dateLib.Duration && dateLib.Settings
|
|
1055
|
+
? true
|
|
1056
|
+
: false;
|
|
1057
|
+
},
|
|
1058
|
+
|
|
977
1059
|
/**
|
|
978
1060
|
* Check if the instance has a date object value - it might be null.
|
|
979
1061
|
* If is doesn't set one to now.
|
|
@@ -983,6 +1065,13 @@ $.extend( DateTime.prototype, {
|
|
|
983
1065
|
_needValue: function () {
|
|
984
1066
|
if ( ! this.s.d ) {
|
|
985
1067
|
this.s.d = this._dateToUtc( new Date() );
|
|
1068
|
+
|
|
1069
|
+
if (! this.s.parts.time) {
|
|
1070
|
+
this.s.d.setUTCHours(0);
|
|
1071
|
+
this.s.d.setUTCMinutes(0);
|
|
1072
|
+
this.s.d.setSeconds(0);
|
|
1073
|
+
this.s.d.setMilliseconds(0);
|
|
1074
|
+
}
|
|
986
1075
|
}
|
|
987
1076
|
|
|
988
1077
|
return this.s.d;
|
|
@@ -1077,7 +1166,7 @@ $.extend( DateTime.prototype, {
|
|
|
1077
1166
|
'selected' :
|
|
1078
1167
|
'';
|
|
1079
1168
|
|
|
1080
|
-
if (allowed && $.inArray(value, allowed) === -1) {
|
|
1169
|
+
if (typeof value === 'number' && allowed && $.inArray(value, allowed) === -1) {
|
|
1081
1170
|
selected += ' disabled';
|
|
1082
1171
|
}
|
|
1083
1172
|
|
|
@@ -1137,9 +1226,11 @@ $.extend( DateTime.prototype, {
|
|
|
1137
1226
|
// Slight hack to allow for the different number of columns
|
|
1138
1227
|
a += '</tbody></thead><table class="'+className+' '+className+'-nospace"><tbody>';
|
|
1139
1228
|
|
|
1140
|
-
var start = range !== null
|
|
1141
|
-
range
|
|
1142
|
-
|
|
1229
|
+
var start = range !== null
|
|
1230
|
+
? range
|
|
1231
|
+
: val === -1
|
|
1232
|
+
? 0
|
|
1233
|
+
: Math.floor( val / 10 )*10;
|
|
1143
1234
|
|
|
1144
1235
|
a += '<tr>';
|
|
1145
1236
|
for (j=start+1 ; j<start+10 ; j++ ) {
|
|
@@ -1183,6 +1274,18 @@ $.extend( DateTime.prototype, {
|
|
|
1183
1274
|
|
|
1184
1275
|
this._options( 'month', this._range( 0, 11 ), i18n.months );
|
|
1185
1276
|
this._options( 'year', this._range( i, j ) );
|
|
1277
|
+
|
|
1278
|
+
// Set the language strings in case any have changed
|
|
1279
|
+
this.dom.today.text(i18n.today).text(i18n.today);
|
|
1280
|
+
this.dom.clear.text(i18n.clear).text(i18n.clear);
|
|
1281
|
+
this.dom.previous
|
|
1282
|
+
.attr('title', i18n.previous)
|
|
1283
|
+
.children('button')
|
|
1284
|
+
.text(i18n.previous);
|
|
1285
|
+
this.dom.next
|
|
1286
|
+
.attr('title', i18n.next)
|
|
1287
|
+
.children('button')
|
|
1288
|
+
.text(i18n.next);
|
|
1186
1289
|
},
|
|
1187
1290
|
|
|
1188
1291
|
/**
|
|
@@ -1319,15 +1422,15 @@ $.extend( DateTime.prototype, {
|
|
|
1319
1422
|
|
|
1320
1423
|
// luxon uses different method names so need to be able to call them. This happens a few time later in this method too
|
|
1321
1424
|
var luxDT = null
|
|
1322
|
-
if (
|
|
1323
|
-
luxDT = dateLib.DateTime.fromJSDate(d);
|
|
1425
|
+
if (this._isLuxon()) {
|
|
1426
|
+
luxDT = dateLib.DateTime.fromJSDate(d).toUTC();
|
|
1324
1427
|
}
|
|
1325
1428
|
|
|
1326
1429
|
var hours = luxDT != null
|
|
1327
1430
|
? luxDT.hour
|
|
1328
1431
|
: d
|
|
1329
1432
|
? d.getUTCHours()
|
|
1330
|
-
:
|
|
1433
|
+
: -1;
|
|
1331
1434
|
|
|
1332
1435
|
var allowed = function ( prop ) { // Backwards compt with `Increment` option
|
|
1333
1436
|
return that.c[prop+'Available'] ?
|
|
@@ -1343,7 +1446,8 @@ $.extend( DateTime.prototype, {
|
|
|
1343
1446
|
? luxDT.minute
|
|
1344
1447
|
: d
|
|
1345
1448
|
? d.getUTCMinutes()
|
|
1346
|
-
:
|
|
1449
|
+
: -1,
|
|
1450
|
+
allowed('minutes'),
|
|
1347
1451
|
this.s.minutesRange
|
|
1348
1452
|
);
|
|
1349
1453
|
this._optionsTime(
|
|
@@ -1353,7 +1457,7 @@ $.extend( DateTime.prototype, {
|
|
|
1353
1457
|
? luxDT.second
|
|
1354
1458
|
: d
|
|
1355
1459
|
? d.getSeconds()
|
|
1356
|
-
:
|
|
1460
|
+
: -1,
|
|
1357
1461
|
allowed('seconds'),
|
|
1358
1462
|
this.s.secondsRange
|
|
1359
1463
|
);
|
|
@@ -1428,17 +1532,8 @@ $.extend( DateTime.prototype, {
|
|
|
1428
1532
|
var date = this.s.d;
|
|
1429
1533
|
var out = '';
|
|
1430
1534
|
|
|
1431
|
-
// Use moment, dayjs or luxon if possible - otherwise it must be ISO8601 (or the
|
|
1432
|
-
// constructor would have thrown an error)
|
|
1433
|
-
// luxon uses different method names so need to be able to call them.
|
|
1434
1535
|
if (date) {
|
|
1435
|
-
out =
|
|
1436
|
-
? dateLib.DateTime.fromJSDate(this.s.d).toFormat(this.c.format)
|
|
1437
|
-
: dateLib ?
|
|
1438
|
-
dateLib.utc( date, undefined, this.c.locale, this.c.strict ).format( this.c.format ) :
|
|
1439
|
-
date.getUTCFullYear() +'-'+
|
|
1440
|
-
this._pad(date.getUTCMonth() + 1) +'-'+
|
|
1441
|
-
this._pad(date.getUTCDate());
|
|
1536
|
+
out = this._convert(date, null, this.c.format);
|
|
1442
1537
|
}
|
|
1443
1538
|
|
|
1444
1539
|
this.dom.input
|
|
@@ -1535,7 +1630,7 @@ DateTime.defaults = {
|
|
|
1535
1630
|
yearRange: 25
|
|
1536
1631
|
};
|
|
1537
1632
|
|
|
1538
|
-
DateTime.version = '1.
|
|
1633
|
+
DateTime.version = '1.3.0';
|
|
1539
1634
|
|
|
1540
1635
|
// Global export - if no conflicts
|
|
1541
1636
|
if (! window.DateTime) {
|
|
@@ -1559,6 +1654,6 @@ if ($.fn.dataTable) {
|
|
|
1559
1654
|
}
|
|
1560
1655
|
}
|
|
1561
1656
|
|
|
1562
|
-
return DateTime;
|
|
1563
1657
|
|
|
1658
|
+
return DateTime;
|
|
1564
1659
|
}));
|
|
@@ -1,43 +1,6 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(d,f,l){d instanceof String&&(d=String(d));for(var m=d.length,g=0;g<m;g++){var q=d[g];if(f.call(l,q,g,d))return{i:g,v:q}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;
|
|
8
|
-
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(d,f,l){if(d==Array.prototype||d==Object.prototype)return d;d[f]=l.value;return d};$jscomp.getGlobal=function(d){d=["object"==typeof globalThis&&globalThis,d,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var f=0;f<d.length;++f){var l=d[f];if(l&&l.Math==Math)return l}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
|
|
9
|
-
$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(d,f){var l=$jscomp.propertyToPolyfillSymbol[f];if(null==l)return d[f];l=d[l];return void 0!==l?l:d[f]};
|
|
10
|
-
$jscomp.polyfill=function(d,f,l,m){f&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(d,f,l,m):$jscomp.polyfillUnisolated(d,f,l,m))};$jscomp.polyfillUnisolated=function(d,f,l,m){l=$jscomp.global;d=d.split(".");for(m=0;m<d.length-1;m++){var g=d[m];if(!(g in l))return;l=l[g]}d=d[d.length-1];m=l[d];f=f(m);f!=m&&null!=f&&$jscomp.defineProperty(l,d,{configurable:!0,writable:!0,value:f})};
|
|
11
|
-
$jscomp.polyfillIsolated=function(d,f,l,m){var g=d.split(".");d=1===g.length;m=g[0];m=!d&&m in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var q=0;q<g.length-1;q++){var a=g[q];if(!(a in m))return;m=m[a]}g=g[g.length-1];l=$jscomp.IS_SYMBOL_NATIVE&&"es6"===l?m[g]:null;f=f(l);null!=f&&(d?$jscomp.defineProperty($jscomp.polyfills,g,{configurable:!0,writable:!0,value:f}):f!==l&&($jscomp.propertyToPolyfillSymbol[g]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(g):$jscomp.POLYFILL_PREFIX+g,g=
|
|
12
|
-
$jscomp.propertyToPolyfillSymbol[g],$jscomp.defineProperty(m,g,{configurable:!0,writable:!0,value:f})))};$jscomp.polyfill("Array.prototype.find",function(d){return d?d:function(f,l){return $jscomp.findInternal(this,f,l).v}},"es6","es3");
|
|
13
|
-
(function(d){"function"===typeof define&&define.amd?define(["jquery"],function(f){return d(f,window,document)}):"object"===typeof exports?module.exports=function(f,l){f||(f=window);return d(l,f,f.document)}:d(jQuery,window,document)})(function(d,f,l,m){var g,q=function(a,b){"undefined"===typeof g&&(g=f.moment?f.moment:f.dayjs?f.dayjs:f.luxon?f.luxon:null);this.c=d.extend(!0,{},q.defaults,b);b=this.c.classPrefix;var c=this.c.i18n;if(!g&&"YYYY-MM-DD"!==this.c.format)throw"DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";
|
|
14
|
-
"string"===typeof this.c.minDate&&(this.c.minDate=new Date(this.c.minDate));"string"===typeof this.c.maxDate&&(this.c.maxDate=new Date(this.c.maxDate));c=d('<div class="'+b+'"><div class="'+b+'-date"><div class="'+b+'-title"><div class="'+b+'-iconLeft"><button type="button" title="'+c.previous+'">'+c.previous+'</button></div><div class="'+b+'-iconRight"><button type="button" title="'+c.next+'">'+c.next+'</button></div><div class="'+b+'-label"><span></span><select class="'+b+'-month"></select></div><div class="'+
|
|
15
|
-
b+'-label"><span></span><select class="'+b+'-year"></select></div></div><div class="'+b+'-buttons"><a class="'+b+'-clear">'+c.clear+'</a><a class="'+b+'-today">'+c.today+'</a></div><div class="'+b+'-calendar"></div></div><div class="'+b+'-time"><div class="'+b+'-hours"></div><div class="'+b+'-minutes"></div><div class="'+b+'-seconds"></div></div><div class="'+b+'-error"></div></div>');this.dom={container:c,date:c.find("."+b+"-date"),title:c.find("."+b+"-title"),calendar:c.find("."+b+"-calendar"),
|
|
16
|
-
time:c.find("."+b+"-time"),error:c.find("."+b+"-error"),buttons:c.find("."+b+"-buttons"),clear:c.find("."+b+"-clear"),today:c.find("."+b+"-today"),input:d(a)};this.s={d:null,display:null,minutesRange:null,secondsRange:null,namespace:"dateime-"+q._instance++,parts:{date:null!==this.c.format.match(/[YMD]|L(?!T)|l/),time:null!==this.c.format.match(/[Hhm]|LT|LTS/),seconds:-1!==this.c.format.indexOf("s"),hours12:null!==this.c.format.match(/[haA]/)}};this.dom.container.append(this.dom.date).append(this.dom.time).append(this.dom.error);
|
|
17
|
-
this.dom.date.append(this.dom.title).append(this.dom.buttons).append(this.dom.calendar);this._constructor()};d.extend(q.prototype,{destroy:function(){this._hide(!0);this.dom.container.off().empty();this.dom.input.removeAttr("autocomplete").off(".datetime")},errorMsg:function(a){var b=this.dom.error;a?b.html(a):b.empty();return this},hide:function(){this._hide();return this},max:function(a){this.c.maxDate="string"===typeof a?new Date(a):a;this._optionsTitle();this._setCalander();return this},min:function(a){this.c.minDate=
|
|
18
|
-
"string"===typeof a?new Date(a):a;this._optionsTitle();this._setCalander();return this},owns:function(a){return 0<d(a).parents().filter(this.dom.container).length},val:function(a,b){if(a===m)return this.s.d;if(a instanceof Date)this.s.d=this._dateToUtc(a);else if(null===a||""===a)this.s.d=null;else if("--now"===a)this.s.d=new Date;else if("string"===typeof a)if(g&&g==f.luxon){var c=g.DateTime.fromFormat(a,this.c.format);this.s.d=c.isValid?c.toJSDate():null}else g?(c=g.utc(a,this.c.format,this.c.locale,
|
|
19
|
-
this.c.strict),this.s.d=c.isValid()?c.toDate():null):(c=a.match(/(\d{4})\-(\d{2})\-(\d{2})/),this.s.d=c?new Date(Date.UTC(c[1],c[2]-1,c[3])):null);if(b||b===m)this.s.d?this._writeOutput():this.dom.input.val(a);this.s.display=this.s.d?new Date(this.s.d.toString()):new Date;this.s.display.setUTCDate(1);this._setTitle();this._setCalander();this._setTime();return this},_constructor:function(){var a=this,b=this.c.classPrefix,c=this.dom.input.val(),k=function(){var e=a.dom.input.val();e!==c&&(a.c.onChange.call(a,
|
|
20
|
-
e,a.s.d,a.dom.input),c=e)};this.s.parts.date||this.dom.date.css("display","none");this.s.parts.time||this.dom.time.css("display","none");this.s.parts.seconds||(this.dom.time.children("div."+b+"-seconds").remove(),this.dom.time.children("span").eq(1).remove());this.c.buttons.clear||this.dom.clear.css("display","none");this.c.buttons.today||this.dom.today.css("display","none");this._optionsTitle();d(l).on("i18n.dt",function(e,h){h.oLanguage.datetime&&(d.extend(!0,a.c.i18n,h.oLanguage.datetime),a._optionsTitle())});
|
|
21
|
-
"hidden"===this.dom.input.attr("type")&&(this.dom.container.addClass("inline"),this.c.attachTo="input",this.val(this.dom.input.val(),!1),this._show());c&&this.val(c,!1);this.dom.input.attr("autocomplete","off").on("focus.datetime click.datetime",function(){a.dom.container.is(":visible")||a.dom.input.is(":disabled")||(a.val(a.dom.input.val(),!1),a._show())}).on("keyup.datetime",function(){a.dom.container.is(":visible")&&a.val(a.dom.input.val(),!1)});this.dom.container.on("change","select",function(){var e=
|
|
22
|
-
d(this),h=e.val();e.hasClass(b+"-month")?(a._correctMonth(a.s.display,h),a._setTitle(),a._setCalander()):e.hasClass(b+"-year")?(a.s.display.setUTCFullYear(h),a._setTitle(),a._setCalander()):e.hasClass(b+"-hours")||e.hasClass(b+"-ampm")?(a.s.parts.hours12?(e=1*d(a.dom.container).find("."+b+"-hours").val(),h="pm"===d(a.dom.container).find("."+b+"-ampm").val(),a.s.d.setUTCHours(12!==e||h?h&&12!==e?e+12:e:0)):a.s.d.setUTCHours(h),a._setTime(),a._writeOutput(!0),k()):e.hasClass(b+"-minutes")?(a.s.d.setUTCMinutes(h),
|
|
23
|
-
a._setTime(),a._writeOutput(!0),k()):e.hasClass(b+"-seconds")&&(a.s.d.setSeconds(h),a._setTime(),a._writeOutput(!0),k());a.dom.input.focus();a._position()}).on("click",function(e){var h=a.s.d;h=e.target.nodeName.toLowerCase();var r="span"===h?e.target.parentNode:e.target;h=r.nodeName.toLowerCase();if("select"!==h)if(e.stopPropagation(),"a"===h&&(e.preventDefault(),d(r).hasClass(b+"-clear")?(a.s.d=null,a.dom.input.val(""),a._writeOutput(),a._setCalander(),a._setTime(),k()):d(r).hasClass(b+"-today")&&
|
|
24
|
-
(a.s.display=new Date,a._setTitle(),a._setCalander())),"button"===h){var p=d(r);e=p.parent();if(e.hasClass("disabled")&&!e.hasClass("range"))p.blur();else if(e.hasClass(b+"-iconLeft"))a.s.display.setUTCMonth(a.s.display.getUTCMonth()-1),a._setTitle(),a._setCalander(),a.dom.input.focus();else if(e.hasClass(b+"-iconRight"))a._correctMonth(a.s.display,a.s.display.getUTCMonth()+1),a._setTitle(),a._setCalander(),a.dom.input.focus();else{if(p.parents("."+b+"-time").length){r=p.data("value");p=p.data("unit");
|
|
25
|
-
h=a._needValue();if("minutes"===p){if(e.hasClass("disabled")&&e.hasClass("range")){a.s.minutesRange=r;a._setTime();return}a.s.minutesRange=null}if("seconds"===p){if(e.hasClass("disabled")&&e.hasClass("range")){a.s.secondsRange=r;a._setTime();return}a.s.secondsRange=null}if("am"===r)if(12<=h.getUTCHours())r=h.getUTCHours()-12;else return;else if("pm"===r)if(12>h.getUTCHours())r=h.getUTCHours()+12;else return;h["hours"===p?"setUTCHours":"minutes"===p?"setUTCMinutes":"setSeconds"](r);a._setTime();a._writeOutput(!0)}else h=
|
|
26
|
-
a._needValue(),h.setUTCDate(1),h.setUTCFullYear(p.data("year")),h.setUTCMonth(p.data("month")),h.setUTCDate(p.data("day")),a._writeOutput(!0),a.s.parts.time?a._setCalander():setTimeout(function(){a._hide()},10);k()}}else a.dom.input.focus()})},_compareDates:function(a,b){return g&&g==f.luxon?g.DateTime.fromJSDate(a).toISODate()===g.DateTime.fromJSDate(b).toISODate():this._dateToUtcString(a)===this._dateToUtcString(b)},_correctMonth:function(a,b){var c=this._daysInMonth(a.getUTCFullYear(),b),k=a.getUTCDate()>
|
|
27
|
-
c;a.setUTCMonth(b);k&&(a.setUTCDate(c),a.setUTCMonth(b))},_daysInMonth:function(a,b){return[31,0!==a%4||0===a%100&&0!==a%400?28:29,31,30,31,30,31,31,30,31,30,31][b]},_dateToUtc:function(a){return new Date(Date.UTC(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds()))},_dateToUtcString:function(a){return g&&g==f.luxon?g.DateTime.fromJSDate(a).toISODate():a.getUTCFullYear()+"-"+this._pad(a.getUTCMonth()+1)+"-"+this._pad(a.getUTCDate())},_hide:function(a){if(a||"hidden"!==
|
|
28
|
-
this.dom.input.attr("type"))a=this.s.namespace,this.dom.container.detach(),d(f).off("."+a),d(l).off("keydown."+a),d("div.dataTables_scrollBody").off("scroll."+a),d("div.DTE_Body_Content").off("scroll."+a),d("body").off("click."+a),d(this.dom.input[0].offsetParent).off("."+a)},_hours24To12:function(a){return 0===a?12:12<a?a-12:a},_htmlDay:function(a){if(a.empty)return'<td class="empty"></td>';var b=["selectable"],c=this.c.classPrefix;a.disabled&&b.push("disabled");a.today&&b.push("now");a.selected&&
|
|
29
|
-
b.push("selected");return'<td data-day="'+a.day+'" class="'+b.join(" ")+'"><button class="'+c+"-button "+c+'-day" type="button" data-year="'+a.year+'" data-month="'+a.month+'" data-day="'+a.day+'"><span>'+a.day+"</span></button></td>"},_htmlMonth:function(a,b){var c=this._dateToUtc(new Date),k=this._daysInMonth(a,b),e=(new Date(Date.UTC(a,b,1))).getUTCDay(),h=[],r=[];0<this.c.firstDay&&(e-=this.c.firstDay,0>e&&(e+=7));for(var p=k+e,u=p;7<u;)u-=7;p+=7-u;var w=this.c.minDate;u=this.c.maxDate;w&&(w.setUTCHours(0),
|
|
30
|
-
w.setUTCMinutes(0),w.setSeconds(0));u&&(u.setUTCHours(23),u.setUTCMinutes(59),u.setSeconds(59));for(var n=0,t=0;n<p;n++){var x=new Date(Date.UTC(a,b,1+(n-e))),A=this.s.d?this._compareDates(x,this.s.d):!1,v=this._compareDates(x,c),B=n<e||n>=k+e,z=w&&x<w||u&&x>u,y=this.c.disableDays;Array.isArray(y)&&-1!==d.inArray(x.getUTCDay(),y)?z=!0:"function"===typeof y&&!0===y(x)&&(z=!0);r.push(this._htmlDay({day:1+(n-e),month:b,year:a,selected:A,today:v,disabled:z,empty:B}));7===++t&&(this.c.showWeekNumber&&
|
|
31
|
-
r.unshift(this._htmlWeekOfYear(n-e,b,a)),h.push("<tr>"+r.join("")+"</tr>"),r=[],t=0)}c=this.c.classPrefix;k=c+"-table";this.c.showWeekNumber&&(k+=" weekNumber");w&&(w=w>=new Date(Date.UTC(a,b,1,0,0,0)),this.dom.title.find("div."+c+"-iconLeft").css("display",w?"none":"block"));u&&(a=u<new Date(Date.UTC(a,b+1,1,0,0,0)),this.dom.title.find("div."+c+"-iconRight").css("display",a?"none":"block"));return'<table class="'+k+'"><thead>'+this._htmlMonthHead()+"</thead><tbody>"+h.join("")+"</tbody></table>"},
|
|
32
|
-
_htmlMonthHead:function(){var a=[],b=this.c.firstDay,c=this.c.i18n,k=function(h){for(h+=b;7<=h;)h-=7;return c.weekdays[h]};this.c.showWeekNumber&&a.push("<th></th>");for(var e=0;7>e;e++)a.push("<th>"+k(e)+"</th>");return a.join("")},_htmlWeekOfYear:function(a,b,c){a=new Date(c,b,a,0,0,0,0);a.setDate(a.getDate()+4-(a.getDay()||7));return'<td class="'+this.c.classPrefix+'-week">'+Math.ceil(((a-new Date(c,0,1))/864E5+1)/7)+"</td>"},_needValue:function(){this.s.d||(this.s.d=this._dateToUtc(new Date));
|
|
33
|
-
return this.s.d},_options:function(a,b,c){c||(c=b);a=this.dom.container.find("select."+this.c.classPrefix+"-"+a);a.empty();for(var k=0,e=b.length;k<e;k++)a.append('<option value="'+b[k]+'">'+c[k]+"</option>")},_optionSet:function(a,b){var c=this.dom.container.find("select."+this.c.classPrefix+"-"+a);a=c.parent().children("span");c.val(b);b=c.find("option:selected");a.html(0!==b.length?b.text():this.c.i18n.unknown)},_optionsTime:function(a,b,c,k,e){var h=this.c.classPrefix,r=this.dom.container.find("div."+
|
|
34
|
-
h+"-"+a),p=12===b?function(v){return v}:this._pad;h=this.c.classPrefix;var u=h+"-table",w=this.c.i18n;if(r.length){var n="";var t=10;var x=function(v,B,z){12===b&&"number"===typeof v&&(12<=c&&(v+=12),12==v?v=0:24==v&&(v=12));var y=c===v||"am"===v&&12>c||"pm"===v&&12<=c?"selected":"";k&&-1===d.inArray(v,k)&&(y+=" disabled");z&&(y+=" "+z);return'<td class="selectable '+y+'"><button class="'+h+"-button "+h+'-day" type="button" data-unit="'+a+'" data-value="'+v+'"><span>'+B+"</span></button></td>"};if(12===
|
|
35
|
-
b){n+="<tr>";for(e=1;6>=e;e++)n+=x(e,p(e));n+=x("am",w.amPm[0]);n+="</tr><tr>";for(e=7;12>=e;e++)n+=x(e,p(e));n+=x("pm",w.amPm[1]);n+="</tr>";t=7}else{if(24===b){var A=0;for(t=0;4>t;t++){n+="<tr>";for(e=0;6>e;e++)n+=x(A,p(A)),A++;n+="</tr>"}}else{n+="<tr>";for(t=0;60>t;t+=10)n+=x(t,p(t),"range");e=null!==e?e:10*Math.floor(c/10);n=n+'</tr></tbody></thead><table class="'+(u+" "+u+'-nospace"><tbody><tr>');for(t=e+1;t<e+10;t++)n+=x(t,p(t));n+="</tr>"}t=6}r.empty().append('<table class="'+u+'"><thead><tr><th colspan="'+
|
|
36
|
-
t+'">'+w[a]+"</th></tr></thead><tbody>"+n+"</tbody></table>")}},_optionsTitle:function(){var a=this.c.i18n,b=this.c.minDate,c=this.c.maxDate;b=b?b.getFullYear():null;c=c?c.getFullYear():null;b=null!==b?b:(new Date).getFullYear()-this.c.yearRange;c=null!==c?c:(new Date).getFullYear()+this.c.yearRange;this._options("month",this._range(0,11),a.months);this._options("year",this._range(b,c))},_pad:function(a){return 10>a?"0"+a:a},_position:function(){var a="input"===this.c.attachTo?this.dom.input.position():
|
|
37
|
-
this.dom.input.offset(),b=this.dom.container,c=this.dom.input.outerHeight();if(b.hasClass("inline"))b.insertAfter(this.dom.input);else{this.s.parts.date&&this.s.parts.time&&550<d(f).width()?b.addClass("horizontal"):b.removeClass("horizontal");"input"===this.c.attachTo?b.css({top:a.top+c,left:a.left}).insertAfter(this.dom.input):b.css({top:a.top+c,left:a.left}).appendTo("body");var k=b.outerHeight(),e=b.outerWidth(),h=d(f).scrollTop();a.top+c+k-h>d(f).height()&&(c=a.top-k,b.css("top",0>c?0:c));e+a.left>
|
|
38
|
-
d(f).width()&&(a=d(f).width()-e,"input"===this.c.attachTo&&(a-=d(b).offsetParent().offset().left),b.css("left",0>a?0:a))}},_range:function(a,b,c){var k=[];for(c||(c=1);a<=b;a+=c)k.push(a);return k},_setCalander:function(){this.s.display&&this.dom.calendar.empty().append(this._htmlMonth(this.s.display.getUTCFullYear(),this.s.display.getUTCMonth()))},_setTitle:function(){this._optionSet("month",this.s.display.getUTCMonth());this._optionSet("year",this.s.display.getUTCFullYear())},_setTime:function(){var a=
|
|
39
|
-
this,b=this.s.d,c=null;g&&g==f.luxon&&(c=g.DateTime.fromJSDate(b));var k=null!=c?c.hour:b?b.getUTCHours():0,e=function(h){return a.c[h+"Available"]?a.c[h+"Available"]:a._range(0,59,a.c[h+"Increment"])};this._optionsTime("hours",this.s.parts.hours12?12:24,k,this.c.hoursAvailable);this._optionsTime("minutes",60,null!=c?c.minute:b?b.getUTCMinutes():0,e("minutes"),this.s.minutesRange);this._optionsTime("seconds",60,null!=c?c.second:b?b.getSeconds():0,e("seconds"),this.s.secondsRange)},_show:function(){var a=
|
|
40
|
-
this,b=this.s.namespace;this._position();d(f).on("scroll."+b+" resize."+b,function(){a._position()});d("div.DTE_Body_Content").on("scroll."+b,function(){a._position()});d("div.dataTables_scrollBody").on("scroll."+b,function(){a._position()});var c=this.dom.input[0].offsetParent;if(c!==l.body)d(c).on("scroll."+b,function(){a._position()});d(l).on("keydown."+b,function(k){9!==k.keyCode&&27!==k.keyCode&&13!==k.keyCode||a._hide()});setTimeout(function(){d("body").on("click."+b,function(k){d(k.target).parents().filter(a.dom.container).length||
|
|
41
|
-
k.target===a.dom.input[0]||a._hide()})},10)},_writeOutput:function(a){var b=this.s.d,c="";b&&(c=g&&g==f.luxon?g.DateTime.fromJSDate(this.s.d).toFormat(this.c.format):g?g.utc(b,m,this.c.locale,this.c.strict).format(this.c.format):b.getUTCFullYear()+"-"+this._pad(b.getUTCMonth()+1)+"-"+this._pad(b.getUTCDate()));this.dom.input.val(c).trigger("change",{write:b});"hidden"===this.dom.input.attr("type")&&this.val(c,!1);a&&this.dom.input.focus()}});q.use=function(a){g=a};q._instance=0;q.defaults={attachTo:"body",
|
|
42
|
-
buttons:{clear:!1,today:!1},classPrefix:"dt-datetime",disableDays:null,firstDay:1,format:"YYYY-MM-DD",hoursAvailable:null,i18n:{clear:"Clear",previous:"Previous",next:"Next",months:"January February March April May June July August September October November December".split(" "),weekdays:"Sun Mon Tue Wed Thu Fri Sat".split(" "),amPm:["am","pm"],hours:"Hour",minutes:"Minute",seconds:"Second",unknown:"-",today:"Today"},maxDate:null,minDate:null,minutesAvailable:null,minutesIncrement:1,strict:!0,locale:"en",
|
|
43
|
-
onChange:function(){},secondsAvailable:null,secondsIncrement:1,showWeekNumber:!1,yearRange:25};q.version="1.1.2";f.DateTime||(f.DateTime=q);d.fn.dtDateTime=function(a){return this.each(function(){new q(this,a)})};d.fn.dataTable&&(d.fn.dataTable.DateTime=q,d.fn.DataTable.DateTime=q,d.fn.dataTable.Editor&&(d.fn.dataTable.Editor.DateTime=q));return q});
|
|
1
|
+
/*! DateTime picker for DataTables.net v1.3.0
|
|
2
|
+
*
|
|
3
|
+
* © SpryMedia Ltd, all rights reserved.
|
|
4
|
+
* License: MIT datatables.net/license/mit
|
|
5
|
+
*/
|
|
6
|
+
!function(s){"function"==typeof define&&define.amd?define(["jquery"],function(t){return s(t,window,document)}):"object"==typeof exports?module.exports=function(t,e){return t=t||window,e=e||("undefined"!=typeof window?require("jquery"):require("jquery")(t)),s(e,t,t.document)}:s(jQuery,window,document)}(function(g,o,i,n){"use strict";function a(t,e){if(void 0===r&&(r=o.moment||o.dayjs||o.luxon||null),this.c=g.extend(!0,{},a.defaults,e),e=this.c.classPrefix,this.c.i18n,!r&&"YYYY-MM-DD"!==this.c.format)throw"DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";"string"==typeof this.c.minDate&&(this.c.minDate=new Date(this.c.minDate)),"string"==typeof this.c.maxDate&&(this.c.maxDate=new Date(this.c.maxDate));var s=g('<div class="'+e+'"><div class="'+e+'-date"><div class="'+e+'-title"><div class="'+e+'-iconLeft"><button type="button"></button></div><div class="'+e+'-iconRight"><button type="button"></button></div><div class="'+e+'-label"><span></span><select class="'+e+'-month"></select></div><div class="'+e+'-label"><span></span><select class="'+e+'-year"></select></div></div><div class="'+e+'-buttons"><a class="'+e+'-clear"></a><a class="'+e+'-today"></a></div><div class="'+e+'-calendar"></div></div><div class="'+e+'-time"><div class="'+e+'-hours"></div><div class="'+e+'-minutes"></div><div class="'+e+'-seconds"></div></div><div class="'+e+'-error"></div></div>');this.dom={container:s,date:s.find("."+e+"-date"),title:s.find("."+e+"-title"),calendar:s.find("."+e+"-calendar"),time:s.find("."+e+"-time"),error:s.find("."+e+"-error"),buttons:s.find("."+e+"-buttons"),clear:s.find("."+e+"-clear"),today:s.find("."+e+"-today"),previous:s.find("."+e+"-iconLeft"),next:s.find("."+e+"-iconRight"),input:g(t)},this.s={d:null,display:null,minutesRange:null,secondsRange:null,namespace:"dateime-"+a._instance++,parts:{date:null!==this.c.format.match(/[YMD]|L(?!T)|l/),time:null!==this.c.format.match(/[Hhm]|LT|LTS/),seconds:-1!==this.c.format.indexOf("s"),hours12:null!==this.c.format.match(/[haA]/)}},this.dom.container.append(this.dom.date).append(this.dom.time).append(this.dom.error),this.dom.date.append(this.dom.title).append(this.dom.buttons).append(this.dom.calendar),this._constructor()}var r;return g.extend(a.prototype,{destroy:function(){this._hide(!0),this.dom.container.off().empty(),this.dom.input.removeAttr("autocomplete").off(".datetime")},errorMsg:function(t){var e=this.dom.error;return t?e.html(t):e.empty(),this},hide:function(){return this._hide(),this},max:function(t){return this.c.maxDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},min:function(t){return this.c.minDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},owns:function(t){return 0<g(t).parents().filter(this.dom.container).length},val:function(t,e){return t===n?this.s.d:(t instanceof Date?this.s.d=this._dateToUtc(t):null===t||""===t?this.s.d=null:"--now"===t?this.s.d=this._dateToUtc(new Date):"string"==typeof t&&(this.s.d=this._convert(t,this.c.format,null)),!e&&e!==n||(this.s.d?this._writeOutput():this.dom.input.val(t)),this.s.display=this.s.d?new Date(this.s.d.toString()):new Date,this.s.display.setUTCDate(1),this._setTitle(),this._setCalander(),this._setTime(),this)},valFormat:function(t,e){return e?(this.val(this._convert(e,t,null)),this):this._convert(this.val(),null,t)},_constructor:function(){function a(){var t=o.dom.input.val();t!==e&&(o.c.onChange.call(o,t,o.s.d,o.dom.input),e=t)}var o=this,r=this.c.classPrefix,e=this.dom.input.val();this.s.parts.date||this.dom.date.css("display","none"),this.s.parts.time||this.dom.time.css("display","none"),this.s.parts.seconds||(this.dom.time.children("div."+r+"-seconds").remove(),this.dom.time.children("span").eq(1).remove()),this.c.buttons.clear||this.dom.clear.css("display","none"),this.c.buttons.today||this.dom.today.css("display","none"),this._optionsTitle(),g(i).on("i18n.dt",function(t,e){e.oLanguage.datetime&&(g.extend(!0,o.c.i18n,e.oLanguage.datetime),o._optionsTitle())}),"hidden"===this.dom.input.attr("type")&&(this.dom.container.addClass("inline"),this.c.attachTo="input",this.val(this.dom.input.val(),!1),this._show()),e&&this.val(e,!1),this.dom.input.attr("autocomplete","off").on("focus.datetime click.datetime",function(){o.dom.container.is(":visible")||o.dom.input.is(":disabled")||(o.val(o.dom.input.val(),!1),o._show())}).on("keyup.datetime",function(){o.dom.container.is(":visible")&&o.val(o.dom.input.val(),!1)}),this.dom.container.on("change","select",function(){var t,e,s=g(this),i=s.val();s.hasClass(r+"-month")?(o._correctMonth(o.s.display,i),o._setTitle(),o._setCalander()):s.hasClass(r+"-year")?(o.s.display.setUTCFullYear(i),o._setTitle(),o._setCalander()):s.hasClass(r+"-hours")||s.hasClass(r+"-ampm")?(o.s.parts.hours12?(t=+g(o.dom.container).find("."+r+"-hours").val(),e="pm"===g(o.dom.container).find("."+r+"-ampm").val(),o.s.d.setUTCHours(12!=t||e?e&&12!=t?12+t:t:0)):o.s.d.setUTCHours(i),o._setTime(),o._writeOutput(!0),a()):s.hasClass(r+"-minutes")?(o.s.d.setUTCMinutes(i),o._setTime(),o._writeOutput(!0),a()):s.hasClass(r+"-seconds")&&(o.s.d.setSeconds(i),o._setTime(),o._writeOutput(!0),a()),o.dom.input.focus(),o._position()}).on("click",function(t){var e=o.s.d,s="span"===t.target.nodeName.toLowerCase()?t.target.parentNode:t.target,i=s.nodeName.toLowerCase();if("select"!==i)if(t.stopPropagation(),"a"===i&&(t.preventDefault(),g(s).hasClass(r+"-clear")?(o.s.d=null,o.dom.input.val(""),o._writeOutput(),o._setCalander(),o._setTime(),a()):g(s).hasClass(r+"-today")&&(o.s.display=new Date,o._setTitle(),o._setCalander())),"button"===i){t=g(s),i=t.parent();if(i.hasClass("disabled")&&!i.hasClass("range"))t.blur();else if(i.hasClass(r+"-iconLeft"))o.s.display.setUTCMonth(o.s.display.getUTCMonth()-1),o._setTitle(),o._setCalander(),o.dom.input.focus();else if(i.hasClass(r+"-iconRight"))o._correctMonth(o.s.display,o.s.display.getUTCMonth()+1),o._setTitle(),o._setCalander(),o.dom.input.focus();else{if(t.parents("."+r+"-time").length){var s=t.data("value"),n=t.data("unit"),e=o._needValue();if("minutes"===n){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.minutesRange=s,void o._setTime();o.s.minutesRange=null}if("seconds"===n){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.secondsRange=s,void o._setTime();o.s.secondsRange=null}if("am"===s){if(!(12<=e.getUTCHours()))return;s=e.getUTCHours()-12}else if("pm"===s){if(!(e.getUTCHours()<12))return;s=e.getUTCHours()+12}e["hours"===n?"setUTCHours":"minutes"===n?"setUTCMinutes":"setSeconds"](s),o._setCalander(),o._setTime(),o._writeOutput(!0)}else(e=o._needValue()).setUTCDate(1),e.setUTCFullYear(t.data("year")),e.setUTCMonth(t.data("month")),e.setUTCDate(t.data("day")),o._writeOutput(!0),o.s.parts.time?(o._setCalander(),o._setTime()):setTimeout(function(){o._hide()},10);a()}}else o.dom.input.focus()})},_compareDates:function(t,e){return this._isLuxon()?r.DateTime.fromJSDate(t).toUTC().toISODate()===r.DateTime.fromJSDate(e).toUTC().toISODate():this._dateToUtcString(t)===this._dateToUtcString(e)},_convert(t,e,s){var i;return t&&(r?this._isLuxon()?(i=t instanceof Date?r.DateTime.fromJSDate(t).toUTC():r.DateTime.fromFormat(t,e)).isValid?s?i.toFormat(s):this._dateToUtc(i.toJSDate()):null:(i=t instanceof Date?r.utc(t,n,this.c.locale,this.c.strict):r.utc(t,e,this.c.locale,this.c.strict)).isValid()?s?i.format(s):i.toDate():null:!e&&!s||e&&s?t:e?(i=t.match(/(\d{4})\-(\d{2})\-(\d{2})/))?new Date(Date.UTC(i[1],i[2]-1,i[3])):null:t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate()))},_correctMonth:function(t,e){var s=this._daysInMonth(t.getUTCFullYear(),e),i=t.getUTCDate()>s;t.setUTCMonth(e),i&&(t.setUTCDate(s),t.setUTCMonth(e))},_daysInMonth:function(t,e){return[31,t%4==0&&(t%100!=0||t%400==0)?29:28,31,30,31,30,31,31,30,31,30,31][e]},_dateToUtc:function(t){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()))},_dateToUtcString:function(t){return this._isLuxon()?r.DateTime.fromJSDate(t).toUTC().toISODate():t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate())},_hide:function(t){!t&&"hidden"===this.dom.input.attr("type")||(t=this.s.namespace,this.dom.container.detach(),g(o).off("."+t),g(i).off("keydown."+t),g("div.dataTables_scrollBody").off("scroll."+t),g("div.DTE_Body_Content").off("scroll."+t),g("body").off("click."+t),g(this.dom.input[0].offsetParent).off("."+t))},_hours24To12:function(t){return 0===t?12:12<t?t-12:t},_htmlDay:function(t){var e,s;return t.empty?'<td class="empty"></td>':(e=["selectable"],s=this.c.classPrefix,t.disabled&&e.push("disabled"),t.today&&e.push("now"),t.selected&&e.push("selected"),'<td data-day="'+t.day+'" class="'+e.join(" ")+'"><button class="'+s+"-button "+s+'-day" type="button" data-year="'+t.year+'" data-month="'+t.month+'" data-day="'+t.day+'"><span>'+t.day+"</span></button></td>")},_htmlMonth:function(t,e){for(var s=this._dateToUtc(new Date),i=this._daysInMonth(t,e),n=new Date(Date.UTC(t,e,1)).getUTCDay(),a=[],o=[],r=(0<this.c.firstDay&&(n-=this.c.firstDay)<0&&(n+=7),i+n),d=r;7<d;)d-=7;r+=7-d;var l=this.c.minDate,h=this.c.maxDate;l&&(l.setUTCHours(0),l.setUTCMinutes(0),l.setSeconds(0)),h&&(h.setUTCHours(23),h.setUTCMinutes(59),h.setSeconds(59));for(var c=0,u=0;c<r;c++){var m=new Date(Date.UTC(t,e,c-n+1)),f=!!this.s.d&&this._compareDates(m,this.s.d),p=this._compareDates(m,s),y=c<n||i+n<=c,T=l&&m<l||h&&h<m,_=this.c.disableDays,f={day:c-n+1,month:e,year:t,selected:f,today:p,disabled:T=Array.isArray(_)&&-1!==g.inArray(m.getUTCDay(),_)||"function"==typeof _&&!0===_(m)?!0:T,empty:y};o.push(this._htmlDay(f)),7==++u&&(this.c.showWeekNumber&&o.unshift(this._htmlWeekOfYear(c-n,e,t)),a.push("<tr>"+o.join("")+"</tr>"),o=[],u=0)}var v,D=this.c.classPrefix,C=D+"-table";return this.c.showWeekNumber&&(C+=" weekNumber"),l&&(v=l>=new Date(Date.UTC(t,e,1,0,0,0)),this.dom.title.find("div."+D+"-iconLeft").css("display",v?"none":"block")),h&&(v=h<new Date(Date.UTC(t,e+1,1,0,0,0)),this.dom.title.find("div."+D+"-iconRight").css("display",v?"none":"block")),'<table class="'+C+'"><thead>'+this._htmlMonthHead()+"</thead><tbody>"+a.join("")+"</tbody></table>"},_htmlMonthHead:function(){var t=[],e=this.c.firstDay,s=this.c.i18n;this.c.showWeekNumber&&t.push("<th></th>");for(var i=0;i<7;i++)t.push("<th>"+function(t){for(t+=e;7<=t;)t-=7;return s.weekdays[t]}(i)+"</th>");return t.join("")},_htmlWeekOfYear:function(t,e,s){e=new Date(s,e,t,0,0,0,0),e.setDate(e.getDate()+4-(e.getDay()||7)),t=new Date(s,0,1),s=Math.ceil(((e-t)/864e5+1)/7);return'<td class="'+this.c.classPrefix+'-week">'+s+"</td>"},_isLuxon:function(){return!!(r&&r.DateTime&&r.Duration&&r.Settings)},_needValue:function(){return this.s.d||(this.s.d=this._dateToUtc(new Date),this.s.parts.time)||(this.s.d.setUTCHours(0),this.s.d.setUTCMinutes(0),this.s.d.setSeconds(0),this.s.d.setMilliseconds(0)),this.s.d},_options:function(t,e,s){s=s||e;var i=this.dom.container.find("select."+this.c.classPrefix+"-"+t);i.empty();for(var n=0,a=e.length;n<a;n++)i.append('<option value="'+e[n]+'">'+s[n]+"</option>")},_optionSet:function(t,e){var t=this.dom.container.find("select."+this.c.classPrefix+"-"+t),s=t.parent().children("span"),e=(t.val(e),t.find("option:selected"));s.html(0!==e.length?e.text():this.c.i18n.unknown)},_optionsTime:function(n,a,o,r,t){var e,d=this.c.classPrefix,s=this.dom.container.find("div."+d+"-"+n),i=12===a?function(t){return t}:this._pad,l=(d=this.c.classPrefix)+"-table",h=this.c.i18n;if(s.length){var c="",u=10,m=function(t,e,s){12===a&&"number"==typeof t&&(12<=o&&(t+=12),12==t?t=0:24==t&&(t=12));var i=o===t||"am"===t&&o<12||"pm"===t&&12<=o?"selected":"";return"number"==typeof t&&r&&-1===g.inArray(t,r)&&(i+=" disabled"),s&&(i+=" "+s),'<td class="selectable '+i+'"><button class="'+d+"-button "+d+'-day" type="button" data-unit="'+n+'" data-value="'+t+'"><span>'+e+"</span></button></td>"};if(12===a){for(c+="<tr>",e=1;e<=6;e++)c+=m(e,i(e));for(c=(c+=m("am",h.amPm[0]))+"</tr>"+"<tr>",e=7;e<=12;e++)c+=m(e,i(e));c=c+m("pm",h.amPm[1])+"</tr>",u=7}else{if(24===a)for(var f=0,p=0;p<4;p++){for(c+="<tr>",e=0;e<6;e++)c+=m(f,i(f)),f++;c+="</tr>"}else{for(c+="<tr>",p=0;p<60;p+=10)c+=m(p,i(p),"range");var c=c+"</tr>"+('</tbody></thead><table class="'+l+" "+l+'-nospace"><tbody>'),y=null!==t?t:-1===o?0:10*Math.floor(o/10);for(c+="<tr>",p=y+1;p<y+10;p++)c+=m(p,i(p));c+="</tr>"}u=6}s.empty().append('<table class="'+l+'"><thead><tr><th colspan="'+u+'">'+h[n]+"</th></tr></thead><tbody>"+c+"</tbody></table>")}},_optionsTitle:function(){var t=this.c.i18n,e=this.c.minDate,s=this.c.maxDate,e=e?e.getFullYear():null,s=s?s.getFullYear():null,e=null!==e?e:(new Date).getFullYear()-this.c.yearRange,s=null!==s?s:(new Date).getFullYear()+this.c.yearRange;this._options("month",this._range(0,11),t.months),this._options("year",this._range(e,s)),this.dom.today.text(t.today).text(t.today),this.dom.clear.text(t.clear).text(t.clear),this.dom.previous.attr("title",t.previous).children("button").text(t.previous),this.dom.next.attr("title",t.next).children("button").text(t.next)},_pad:function(t){return t<10?"0"+t:t},_position:function(){var t,e,s,i="input"===this.c.attachTo?this.dom.input.position():this.dom.input.offset(),n=this.dom.container,a=this.dom.input.outerHeight();n.hasClass("inline")?n.insertAfter(this.dom.input):(this.s.parts.date&&this.s.parts.time&&550<g(o).width()?n.addClass("horizontal"):n.removeClass("horizontal"),"input"===this.c.attachTo?n.css({top:i.top+a,left:i.left}).insertAfter(this.dom.input):n.css({top:i.top+a,left:i.left}).appendTo("body"),t=n.outerHeight(),e=n.outerWidth(),s=g(o).scrollTop(),i.top+a+t-s>g(o).height()&&(a=i.top-t,n.css("top",a<0?0:a)),e+i.left>g(o).width()&&(s=g(o).width()-e,"input"===this.c.attachTo&&(s-=g(n).offsetParent().offset().left),n.css("left",s<0?0:s)))},_range:function(t,e,s){var i=[];s=s||1;for(var n=t;n<=e;n+=s)i.push(n);return i},_setCalander:function(){this.s.display&&this.dom.calendar.empty().append(this._htmlMonth(this.s.display.getUTCFullYear(),this.s.display.getUTCMonth()))},_setTitle:function(){this._optionSet("month",this.s.display.getUTCMonth()),this._optionSet("year",this.s.display.getUTCFullYear())},_setTime:function(){function t(t){return e.c[t+"Available"]||e._range(0,59,e.c[t+"Increment"])}var e=this,s=this.s.d,i=null,n=null!=(i=this._isLuxon()?r.DateTime.fromJSDate(s).toUTC():i)?i.hour:s?s.getUTCHours():-1;this._optionsTime("hours",this.s.parts.hours12?12:24,n,this.c.hoursAvailable),this._optionsTime("minutes",60,null!=i?i.minute:s?s.getUTCMinutes():-1,t("minutes"),this.s.minutesRange),this._optionsTime("seconds",60,null!=i?i.second:s?s.getSeconds():-1,t("seconds"),this.s.secondsRange)},_show:function(){var e=this,t=this.s.namespace,s=(this._position(),g(o).on("scroll."+t+" resize."+t,function(){e._position()}),g("div.DTE_Body_Content").on("scroll."+t,function(){e._position()}),g("div.dataTables_scrollBody").on("scroll."+t,function(){e._position()}),this.dom.input[0].offsetParent);s!==i.body&&g(s).on("scroll."+t,function(){e._position()}),g(i).on("keydown."+t,function(t){9!==t.keyCode&&27!==t.keyCode&&13!==t.keyCode||e._hide()}),setTimeout(function(){g("body").on("click."+t,function(t){g(t.target).parents().filter(e.dom.container).length||t.target===e.dom.input[0]||e._hide()})},10)},_writeOutput:function(t){var e=this.s.d,s="";e&&(s=this._convert(e,null,this.c.format)),this.dom.input.val(s).trigger("change",{write:e}),"hidden"===this.dom.input.attr("type")&&this.val(s,!1),t&&this.dom.input.focus()}}),a.use=function(t){r=t},a._instance=0,a.defaults={attachTo:"body",buttons:{clear:!1,today:!1},classPrefix:"dt-datetime",disableDays:null,firstDay:1,format:"YYYY-MM-DD",hoursAvailable:null,i18n:{clear:"Clear",previous:"Previous",next:"Next",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],amPm:["am","pm"],hours:"Hour",minutes:"Minute",seconds:"Second",unknown:"-",today:"Today"},maxDate:null,minDate:null,minutesAvailable:null,minutesIncrement:1,strict:!0,locale:"en",onChange:function(){},secondsAvailable:null,secondsIncrement:1,showWeekNumber:!1,yearRange:25},a.version="1.3.0",o.DateTime||(o.DateTime=a),g.fn.dtDateTime=function(t){return this.each(function(){new a(this,t)})},g.fn.dataTable&&(g.fn.dataTable.DateTime=a,g.fn.DataTable.DateTime=a,g.fn.dataTable.Editor)&&(g.fn.dataTable.Editor.DateTime=a),a});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*! DateTime picker for DataTables.net v1.3.0
|
|
2
|
+
*
|
|
3
|
+
* © SpryMedia Ltd, all rights reserved.
|
|
4
|
+
* License: MIT datatables.net/license/mit
|
|
5
|
+
*/
|
|
6
|
+
import $ from"jquery";var dateLib,DateTime=function(t,e){void 0===dateLib&&(dateLib=window.moment||window.dayjs||window.luxon||null),this.c=$.extend(!0,{},DateTime.defaults,e);e=this.c.classPrefix;this.c.i18n;if(!dateLib&&"YYYY-MM-DD"!==this.c.format)throw"DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";"string"==typeof this.c.minDate&&(this.c.minDate=new Date(this.c.minDate)),"string"==typeof this.c.maxDate&&(this.c.maxDate=new Date(this.c.maxDate));var s=$('<div class="'+e+'"><div class="'+e+'-date"><div class="'+e+'-title"><div class="'+e+'-iconLeft"><button type="button"></button></div><div class="'+e+'-iconRight"><button type="button"></button></div><div class="'+e+'-label"><span></span><select class="'+e+'-month"></select></div><div class="'+e+'-label"><span></span><select class="'+e+'-year"></select></div></div><div class="'+e+'-buttons"><a class="'+e+'-clear"></a><a class="'+e+'-today"></a></div><div class="'+e+'-calendar"></div></div><div class="'+e+'-time"><div class="'+e+'-hours"></div><div class="'+e+'-minutes"></div><div class="'+e+'-seconds"></div></div><div class="'+e+'-error"></div></div>');this.dom={container:s,date:s.find("."+e+"-date"),title:s.find("."+e+"-title"),calendar:s.find("."+e+"-calendar"),time:s.find("."+e+"-time"),error:s.find("."+e+"-error"),buttons:s.find("."+e+"-buttons"),clear:s.find("."+e+"-clear"),today:s.find("."+e+"-today"),previous:s.find("."+e+"-iconLeft"),next:s.find("."+e+"-iconRight"),input:$(t)},this.s={d:null,display:null,minutesRange:null,secondsRange:null,namespace:"dateime-"+DateTime._instance++,parts:{date:null!==this.c.format.match(/[YMD]|L(?!T)|l/),time:null!==this.c.format.match(/[Hhm]|LT|LTS/),seconds:-1!==this.c.format.indexOf("s"),hours12:null!==this.c.format.match(/[haA]/)}},this.dom.container.append(this.dom.date).append(this.dom.time).append(this.dom.error),this.dom.date.append(this.dom.title).append(this.dom.buttons).append(this.dom.calendar),this._constructor()};$.extend(DateTime.prototype,{destroy:function(){this._hide(!0),this.dom.container.off().empty(),this.dom.input.removeAttr("autocomplete").off(".datetime")},errorMsg:function(t){var e=this.dom.error;return t?e.html(t):e.empty(),this},hide:function(){return this._hide(),this},max:function(t){return this.c.maxDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},min:function(t){return this.c.minDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},owns:function(t){return 0<$(t).parents().filter(this.dom.container).length},val:function(t,e){return void 0===t?this.s.d:(t instanceof Date?this.s.d=this._dateToUtc(t):null===t||""===t?this.s.d=null:"--now"===t?this.s.d=this._dateToUtc(new Date):"string"==typeof t&&(this.s.d=this._convert(t,this.c.format,null)),!e&&void 0!==e||(this.s.d?this._writeOutput():this.dom.input.val(t)),this.s.display=this.s.d?new Date(this.s.d.toString()):new Date,this.s.display.setUTCDate(1),this._setTitle(),this._setCalander(),this._setTime(),this)},valFormat:function(t,e){return e?(this.val(this._convert(e,t,null)),this):this._convert(this.val(),null,t)},_constructor:function(){function n(){var t=o.dom.input.val();t!==e&&(o.c.onChange.call(o,t,o.s.d,o.dom.input),e=t)}var o=this,d=this.c.classPrefix,e=this.dom.input.val();this.s.parts.date||this.dom.date.css("display","none"),this.s.parts.time||this.dom.time.css("display","none"),this.s.parts.seconds||(this.dom.time.children("div."+d+"-seconds").remove(),this.dom.time.children("span").eq(1).remove()),this.c.buttons.clear||this.dom.clear.css("display","none"),this.c.buttons.today||this.dom.today.css("display","none"),this._optionsTitle(),$(document).on("i18n.dt",function(t,e){e.oLanguage.datetime&&($.extend(!0,o.c.i18n,e.oLanguage.datetime),o._optionsTitle())}),"hidden"===this.dom.input.attr("type")&&(this.dom.container.addClass("inline"),this.c.attachTo="input",this.val(this.dom.input.val(),!1),this._show()),e&&this.val(e,!1),this.dom.input.attr("autocomplete","off").on("focus.datetime click.datetime",function(){o.dom.container.is(":visible")||o.dom.input.is(":disabled")||(o.val(o.dom.input.val(),!1),o._show())}).on("keyup.datetime",function(){o.dom.container.is(":visible")&&o.val(o.dom.input.val(),!1)}),this.dom.container.on("change","select",function(){var t,e,s=$(this),i=s.val();s.hasClass(d+"-month")?(o._correctMonth(o.s.display,i),o._setTitle(),o._setCalander()):s.hasClass(d+"-year")?(o.s.display.setUTCFullYear(i),o._setTitle(),o._setCalander()):s.hasClass(d+"-hours")||s.hasClass(d+"-ampm")?(o.s.parts.hours12?(t=+$(o.dom.container).find("."+d+"-hours").val(),e="pm"===$(o.dom.container).find("."+d+"-ampm").val(),o.s.d.setUTCHours(12!=t||e?e&&12!=t?12+t:t:0)):o.s.d.setUTCHours(i),o._setTime(),o._writeOutput(!0),n()):s.hasClass(d+"-minutes")?(o.s.d.setUTCMinutes(i),o._setTime(),o._writeOutput(!0),n()):s.hasClass(d+"-seconds")&&(o.s.d.setSeconds(i),o._setTime(),o._writeOutput(!0),n()),o.dom.input.focus(),o._position()}).on("click",function(t){var e=o.s.d,s="span"===t.target.nodeName.toLowerCase()?t.target.parentNode:t.target,i=s.nodeName.toLowerCase();if("select"!==i)if(t.stopPropagation(),"a"===i&&(t.preventDefault(),$(s).hasClass(d+"-clear")?(o.s.d=null,o.dom.input.val(""),o._writeOutput(),o._setCalander(),o._setTime(),n()):$(s).hasClass(d+"-today")&&(o.s.display=new Date,o._setTitle(),o._setCalander())),"button"===i){t=$(s),i=t.parent();if(i.hasClass("disabled")&&!i.hasClass("range"))t.blur();else if(i.hasClass(d+"-iconLeft"))o.s.display.setUTCMonth(o.s.display.getUTCMonth()-1),o._setTitle(),o._setCalander(),o.dom.input.focus();else if(i.hasClass(d+"-iconRight"))o._correctMonth(o.s.display,o.s.display.getUTCMonth()+1),o._setTitle(),o._setCalander(),o.dom.input.focus();else{if(t.parents("."+d+"-time").length){var s=t.data("value"),a=t.data("unit"),e=o._needValue();if("minutes"===a){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.minutesRange=s,void o._setTime();o.s.minutesRange=null}if("seconds"===a){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.secondsRange=s,void o._setTime();o.s.secondsRange=null}if("am"===s){if(!(12<=e.getUTCHours()))return;s=e.getUTCHours()-12}else if("pm"===s){if(!(e.getUTCHours()<12))return;s=e.getUTCHours()+12}e["hours"===a?"setUTCHours":"minutes"===a?"setUTCMinutes":"setSeconds"](s),o._setCalander(),o._setTime(),o._writeOutput(!0)}else(e=o._needValue()).setUTCDate(1),e.setUTCFullYear(t.data("year")),e.setUTCMonth(t.data("month")),e.setUTCDate(t.data("day")),o._writeOutput(!0),o.s.parts.time?(o._setCalander(),o._setTime()):setTimeout(function(){o._hide()},10);n()}}else o.dom.input.focus()})},_compareDates:function(t,e){return this._isLuxon()?dateLib.DateTime.fromJSDate(t).toUTC().toISODate()===dateLib.DateTime.fromJSDate(e).toUTC().toISODate():this._dateToUtcString(t)===this._dateToUtcString(e)},_convert(t,e,s){var i;return t&&(dateLib?this._isLuxon()?(i=t instanceof Date?dateLib.DateTime.fromJSDate(t).toUTC():dateLib.DateTime.fromFormat(t,e)).isValid?s?i.toFormat(s):this._dateToUtc(i.toJSDate()):null:(i=t instanceof Date?dateLib.utc(t,void 0,this.c.locale,this.c.strict):dateLib.utc(t,e,this.c.locale,this.c.strict)).isValid()?s?i.format(s):i.toDate():null:!e&&!s||e&&s?t:e?(i=t.match(/(\d{4})\-(\d{2})\-(\d{2})/))?new Date(Date.UTC(i[1],i[2]-1,i[3])):null:t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate()))},_correctMonth:function(t,e){var s=this._daysInMonth(t.getUTCFullYear(),e),i=t.getUTCDate()>s;t.setUTCMonth(e),i&&(t.setUTCDate(s),t.setUTCMonth(e))},_daysInMonth:function(t,e){return[31,t%4==0&&(t%100!=0||t%400==0)?29:28,31,30,31,30,31,31,30,31,30,31][e]},_dateToUtc:function(t){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()))},_dateToUtcString:function(t){return this._isLuxon()?dateLib.DateTime.fromJSDate(t).toUTC().toISODate():t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate())},_hide:function(t){!t&&"hidden"===this.dom.input.attr("type")||(t=this.s.namespace,this.dom.container.detach(),$(window).off("."+t),$(document).off("keydown."+t),$("div.dataTables_scrollBody").off("scroll."+t),$("div.DTE_Body_Content").off("scroll."+t),$("body").off("click."+t),$(this.dom.input[0].offsetParent).off("."+t))},_hours24To12:function(t){return 0===t?12:12<t?t-12:t},_htmlDay:function(t){var e,s;return t.empty?'<td class="empty"></td>':(e=["selectable"],s=this.c.classPrefix,t.disabled&&e.push("disabled"),t.today&&e.push("now"),t.selected&&e.push("selected"),'<td data-day="'+t.day+'" class="'+e.join(" ")+'"><button class="'+s+"-button "+s+'-day" type="button" data-year="'+t.year+'" data-month="'+t.month+'" data-day="'+t.day+'"><span>'+t.day+"</span></button></td>")},_htmlMonth:function(t,e){for(var s=this._dateToUtc(new Date),i=this._daysInMonth(t,e),a=new Date(Date.UTC(t,e,1)).getUTCDay(),n=[],o=[],d=(0<this.c.firstDay&&(a-=this.c.firstDay)<0&&(a+=7),i+a),r=d;7<r;)r-=7;d+=7-r;var l=this.c.minDate,h=this.c.maxDate;l&&(l.setUTCHours(0),l.setUTCMinutes(0),l.setSeconds(0)),h&&(h.setUTCHours(23),h.setUTCMinutes(59),h.setSeconds(59));for(var c=0,u=0;c<d;c++){var m=new Date(Date.UTC(t,e,c-a+1)),f=!!this.s.d&&this._compareDates(m,this.s.d),p=this._compareDates(m,s),T=c<a||i+a<=c,y=l&&m<l||h&&h<m,_=this.c.disableDays,f={day:c-a+1,month:e,year:t,selected:f,today:p,disabled:y=Array.isArray(_)&&-1!==$.inArray(m.getUTCDay(),_)||"function"==typeof _&&!0===_(m)?!0:y,empty:T};o.push(this._htmlDay(f)),7==++u&&(this.c.showWeekNumber&&o.unshift(this._htmlWeekOfYear(c-a,e,t)),n.push("<tr>"+o.join("")+"</tr>"),o=[],u=0)}var v,D=this.c.classPrefix,b=D+"-table";return this.c.showWeekNumber&&(b+=" weekNumber"),l&&(v=l>=new Date(Date.UTC(t,e,1,0,0,0)),this.dom.title.find("div."+D+"-iconLeft").css("display",v?"none":"block")),h&&(v=h<new Date(Date.UTC(t,e+1,1,0,0,0)),this.dom.title.find("div."+D+"-iconRight").css("display",v?"none":"block")),'<table class="'+b+'"><thead>'+this._htmlMonthHead()+"</thead><tbody>"+n.join("")+"</tbody></table>"},_htmlMonthHead:function(){var t=[],e=this.c.firstDay,s=this.c.i18n;this.c.showWeekNumber&&t.push("<th></th>");for(var i=0;i<7;i++)t.push("<th>"+function(t){for(t+=e;7<=t;)t-=7;return s.weekdays[t]}(i)+"</th>");return t.join("")},_htmlWeekOfYear:function(t,e,s){e=new Date(s,e,t,0,0,0,0),e.setDate(e.getDate()+4-(e.getDay()||7)),t=new Date(s,0,1),s=Math.ceil(((e-t)/864e5+1)/7);return'<td class="'+this.c.classPrefix+'-week">'+s+"</td>"},_isLuxon:function(){return!!(dateLib&&dateLib.DateTime&&dateLib.Duration&&dateLib.Settings)},_needValue:function(){return this.s.d||(this.s.d=this._dateToUtc(new Date),this.s.parts.time)||(this.s.d.setUTCHours(0),this.s.d.setUTCMinutes(0),this.s.d.setSeconds(0),this.s.d.setMilliseconds(0)),this.s.d},_options:function(t,e,s){s=s||e;var i=this.dom.container.find("select."+this.c.classPrefix+"-"+t);i.empty();for(var a=0,n=e.length;a<n;a++)i.append('<option value="'+e[a]+'">'+s[a]+"</option>")},_optionSet:function(t,e){var t=this.dom.container.find("select."+this.c.classPrefix+"-"+t),s=t.parent().children("span"),e=(t.val(e),t.find("option:selected"));s.html(0!==e.length?e.text():this.c.i18n.unknown)},_optionsTime:function(a,n,o,d,t){var e,r=this.c.classPrefix,s=this.dom.container.find("div."+r+"-"+a),i=12===n?function(t){return t}:this._pad,l=(r=this.c.classPrefix)+"-table",h=this.c.i18n;if(s.length){function c(t,e,s){12===n&&"number"==typeof t&&(12<=o&&(t+=12),12==t?t=0:24==t&&(t=12));var i=o===t||"am"===t&&o<12||"pm"===t&&12<=o?"selected":"";return"number"==typeof t&&d&&-1===$.inArray(t,d)&&(i+=" disabled"),s&&(i+=" "+s),'<td class="selectable '+i+'"><button class="'+r+"-button "+r+'-day" type="button" data-unit="'+a+'" data-value="'+t+'"><span>'+e+"</span></button></td>"}var u="",m=10;if(12===n){for(u+="<tr>",e=1;e<=6;e++)u+=c(e,i(e));for(u=(u+=c("am",h.amPm[0]))+"</tr>"+"<tr>",e=7;e<=12;e++)u+=c(e,i(e));u=u+c("pm",h.amPm[1])+"</tr>",m=7}else{if(24===n)for(var f=0,p=0;p<4;p++){for(u+="<tr>",e=0;e<6;e++)u+=c(f,i(f)),f++;u+="</tr>"}else{for(u+="<tr>",p=0;p<60;p+=10)u+=c(p,i(p),"range");var u=u+"</tr>"+('</tbody></thead><table class="'+l+" "+l+'-nospace"><tbody>'),T=null!==t?t:-1===o?0:10*Math.floor(o/10);for(u+="<tr>",p=T+1;p<T+10;p++)u+=c(p,i(p));u+="</tr>"}m=6}s.empty().append('<table class="'+l+'"><thead><tr><th colspan="'+m+'">'+h[a]+"</th></tr></thead><tbody>"+u+"</tbody></table>")}},_optionsTitle:function(){var t=this.c.i18n,e=this.c.minDate,s=this.c.maxDate,e=e?e.getFullYear():null,s=s?s.getFullYear():null,e=null!==e?e:(new Date).getFullYear()-this.c.yearRange,s=null!==s?s:(new Date).getFullYear()+this.c.yearRange;this._options("month",this._range(0,11),t.months),this._options("year",this._range(e,s)),this.dom.today.text(t.today).text(t.today),this.dom.clear.text(t.clear).text(t.clear),this.dom.previous.attr("title",t.previous).children("button").text(t.previous),this.dom.next.attr("title",t.next).children("button").text(t.next)},_pad:function(t){return t<10?"0"+t:t},_position:function(){var t,e,s,i="input"===this.c.attachTo?this.dom.input.position():this.dom.input.offset(),a=this.dom.container,n=this.dom.input.outerHeight();a.hasClass("inline")?a.insertAfter(this.dom.input):(this.s.parts.date&&this.s.parts.time&&550<$(window).width()?a.addClass("horizontal"):a.removeClass("horizontal"),"input"===this.c.attachTo?a.css({top:i.top+n,left:i.left}).insertAfter(this.dom.input):a.css({top:i.top+n,left:i.left}).appendTo("body"),t=a.outerHeight(),e=a.outerWidth(),s=$(window).scrollTop(),i.top+n+t-s>$(window).height()&&(n=i.top-t,a.css("top",n<0?0:n)),e+i.left>$(window).width()&&(s=$(window).width()-e,"input"===this.c.attachTo&&(s-=$(a).offsetParent().offset().left),a.css("left",s<0?0:s)))},_range:function(t,e,s){var i=[];s=s||1;for(var a=t;a<=e;a+=s)i.push(a);return i},_setCalander:function(){this.s.display&&this.dom.calendar.empty().append(this._htmlMonth(this.s.display.getUTCFullYear(),this.s.display.getUTCMonth()))},_setTitle:function(){this._optionSet("month",this.s.display.getUTCMonth()),this._optionSet("year",this.s.display.getUTCFullYear())},_setTime:function(){function t(t){return e.c[t+"Available"]||e._range(0,59,e.c[t+"Increment"])}var e=this,s=this.s.d,i=null,a=null!=(i=this._isLuxon()?dateLib.DateTime.fromJSDate(s).toUTC():i)?i.hour:s?s.getUTCHours():-1;this._optionsTime("hours",this.s.parts.hours12?12:24,a,this.c.hoursAvailable),this._optionsTime("minutes",60,null!=i?i.minute:s?s.getUTCMinutes():-1,t("minutes"),this.s.minutesRange),this._optionsTime("seconds",60,null!=i?i.second:s?s.getSeconds():-1,t("seconds"),this.s.secondsRange)},_show:function(){var e=this,t=this.s.namespace,s=(this._position(),$(window).on("scroll."+t+" resize."+t,function(){e._position()}),$("div.DTE_Body_Content").on("scroll."+t,function(){e._position()}),$("div.dataTables_scrollBody").on("scroll."+t,function(){e._position()}),this.dom.input[0].offsetParent);s!==document.body&&$(s).on("scroll."+t,function(){e._position()}),$(document).on("keydown."+t,function(t){9!==t.keyCode&&27!==t.keyCode&&13!==t.keyCode||e._hide()}),setTimeout(function(){$("body").on("click."+t,function(t){$(t.target).parents().filter(e.dom.container).length||t.target===e.dom.input[0]||e._hide()})},10)},_writeOutput:function(t){var e=this.s.d,s="";e&&(s=this._convert(e,null,this.c.format)),this.dom.input.val(s).trigger("change",{write:e}),"hidden"===this.dom.input.attr("type")&&this.val(s,!1),t&&this.dom.input.focus()}}),DateTime.use=function(t){dateLib=t},DateTime._instance=0,DateTime.defaults={attachTo:"body",buttons:{clear:!1,today:!1},classPrefix:"dt-datetime",disableDays:null,firstDay:1,format:"YYYY-MM-DD",hoursAvailable:null,i18n:{clear:"Clear",previous:"Previous",next:"Next",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],amPm:["am","pm"],hours:"Hour",minutes:"Minute",seconds:"Second",unknown:"-",today:"Today"},maxDate:null,minDate:null,minutesAvailable:null,minutesIncrement:1,strict:!0,locale:"en",onChange:function(){},secondsAvailable:null,secondsIncrement:1,showWeekNumber:!1,yearRange:25},DateTime.version="1.3.0",window.DateTime||(window.DateTime=DateTime),$.fn.dtDateTime=function(t){return this.each(function(){new DateTime(this,t)})},$.fn.dataTable&&($.fn.dataTable.DateTime=DateTime,$.fn.DataTable.DateTime=DateTime,$.fn.dataTable.Editor)&&($.fn.dataTable.Editor.DateTime=DateTime);export default DateTime;
|