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.
@@ -0,0 +1,52 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <dt-api library="DateTime">
3
+ <name>valFormat()</name>
4
+ <summary>Get / set a formatted value for the instance.</summary>
5
+ <since>1.3.0</since>
6
+
7
+ <type type="function">
8
+ <signature>valFormat(format)</signature>
9
+ <description>Get the value of the DateTime instance.</description>
10
+ <parameter type="string" name="format">
11
+ The format that you want the date/time value in.
12
+ </parameter>
13
+ <returns type="string">The formatted value.</returns>
14
+ </type>
15
+ <type type="function">
16
+ <signature>valFormat(format, set)</signature>
17
+ <description>Set the value of the DateTime instance.</description>
18
+ <parameter type="string" name="format">
19
+ The format that the date / time value string is currently in.
20
+ </parameter>
21
+ <parameter type="string" name="set">
22
+ The value to be set, in the format given by the first parameter.
23
+ </parameter>
24
+ <returns type="DateTime">Self for chaining.</returns>
25
+ </type>
26
+
27
+ <description>
28
+ This method can be used to get or set the value for the DateTime instance, in a specific format. For example, it can be used to set a value given in a format that is not ISO8601, or you could read back a value in some other format (i.e. a localised human readable format).
29
+
30
+ The formatting options available will depend upon the date / time library being used (e.g. Moment.js or Luxon).
31
+ </description>
32
+
33
+ <example title="Get a value from the input with a specific format"><![CDATA[
34
+
35
+ let el = document.getElementById('example');
36
+ let dt = new DateTime(el);
37
+
38
+ el.addEventListener('change', function () {
39
+ console.log('Selected value is: ', dt.valFormat('MM-DD-YYYY'));
40
+ } );
41
+
42
+ ]]></example>
43
+
44
+ <example title="Set a value into the input from a formatted string"><![CDATA[
45
+
46
+ let dt = new DateTime(document.getElementById('example'));
47
+
48
+ dt.valFormat('MM-DD-YY', '03-02-23");
49
+
50
+ ]]></example>
51
+
52
+ </dt-api>
@@ -9,7 +9,7 @@
9
9
  </default>
10
10
 
11
11
  <description>
12
- When enabled, this option will cause DateTime to show a button (text set by `dt-init i18n.today`) which the end user can activate to shift the calendar view to show today's date.
12
+ When enabled, this option will cause DateTime to show a button (text set by `de-init i18n.today`) which the end user can activate to shift the calendar view to show today's date.
13
13
 
14
14
  Note that the value of the field does not change when activating this button.
15
15
  </description>
@@ -7,7 +7,7 @@
7
7
  <![CDATA[
8
8
 
9
9
  $(document).ready(function() {
10
- new DateTime(document.getElementById('test'), {
10
+ window.d = new DateTime(document.getElementById('test'), {
11
11
  format: 'D MMM YYYY HH:mm'
12
12
  });
13
13
  });
@@ -2,15 +2,17 @@
2
2
  <dt-example table-type="html" table-class="display nowrap" order="9">
3
3
 
4
4
  <css lib="datetime"/>
5
- <js lib="//cdnjs.cloudflare.com/ajax/libs/dayjs/1.8.17/dayjs.min.js"/>
6
- <js lib="//cdnjs.cloudflare.com/ajax/libs/dayjs/1.8.17/plugin/utc.js"/>
5
+ <js lib="//cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.5/dayjs.min.js"/>
6
+ <js lib="//cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.5/plugin/utc.js"/>
7
+ <js lib="//cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.5/plugin/customParseFormat.min.js"/>
7
8
  <js lib="jquery datetime">
8
9
  <![CDATA[
9
10
 
10
11
  dayjs.extend(dayjs_plugin_utc);
12
+ dayjs.extend(dayjs_plugin_customParseFormat);
11
13
 
12
14
  $(document).ready(function() {
13
- new DateTime(document.getElementById('test'), {
15
+ window.allan = new DateTime(document.getElementById('test'), {
14
16
  format: 'D/M/YYYY'
15
17
  });
16
18
  });
@@ -23,12 +25,12 @@ $(document).ready(function() {
23
25
 
24
26
  This example shows the date / time input with [DayJS](https://github.com/iamkun/dayjs) used to provide the date / time formatting.
25
27
 
26
- Please note that you also need the DayJS `UTC` plugin.
28
+ Please note that you also need the DayJS `UTC` and `customParseFormat` plug-ins.
27
29
 
28
30
  ]]></info>
29
31
 
30
32
  <custom-table>
31
- <input id="test" type="text" value="17/1/2020" />
33
+ <input id="test" type="text" value="17/1/2022" />
32
34
  </custom-table>
33
35
 
34
36
  </dt-example>
@@ -7,7 +7,7 @@
7
7
  <![CDATA[
8
8
 
9
9
  $(document).ready(function() {
10
- new DateTime(document.getElementById('test'), {
10
+ window.allan = new DateTime(document.getElementById('test'), {
11
11
  format: 'd/M/yyyy, HH:mm'
12
12
  });
13
13
  });
@@ -1,53 +1,67 @@
1
+ // Type definitions for DataTables DateTime
2
+ //
3
+ // Project: https://datatables.net/extensions/datetime
4
+ // Definitions by:
5
+ // SpryMedia
1
6
 
2
- declare module 'datatables.net-datetime' {
3
- interface IDateTimeOptions {
4
- classPrefix?: string;
5
- disableDays?: number[] | null;
6
- firstDay?: number;
7
- format?: string;
8
- hoursAvailable?: number[] | null;
9
- i18n?: {
10
- previous?: string;
11
- next?: string;
12
- months?: string[];
13
- weekdays?: string[];
14
- amPm?: string[];
15
- hours?: string;
16
- minutes?: string;
17
- seconds?: string;
18
- unknown?: string;
19
- };
20
- maxDate?: Date | null;
21
- minDate?: Date | null;
22
- minutesAvailable?: number[] | null;
23
- strict?: boolean;
24
- locale?: string;
25
- onChange?: (value: string, date: Date, el: HTMLElement) => void;
26
- secondsAvailable?: number[] | null;
27
- showWeekNumber?: boolean;
28
- yearRange?: number;
29
- }
7
+ /// <reference types="jquery" />
30
8
 
31
- class DateTime {
32
- static use(moment: any); // Moment library
9
+ interface IDateTimeOptions {
10
+ classPrefix?: string;
11
+ disableDays?: number[] | null;
12
+ firstDay?: number;
13
+ format?: string;
14
+ hoursAvailable?: number[] | null;
15
+ i18n?: {
16
+ previous?: string;
17
+ next?: string;
18
+ months?: string[];
19
+ weekdays?: string[];
20
+ amPm?: string[];
21
+ hours?: string;
22
+ minutes?: string;
23
+ seconds?: string;
24
+ unknown?: string;
25
+ };
26
+ maxDate?: Date | null;
27
+ minDate?: Date | null;
28
+ minutesAvailable?: number[] | null;
29
+ strict?: boolean;
30
+ locale?: string;
31
+ onChange?: (value: string, date: Date, el: HTMLElement) => void;
32
+ secondsAvailable?: number[] | null;
33
+ showWeekNumber?: boolean;
34
+ yearRange?: number;
35
+ }
33
36
 
34
- constructor(el: HTMLElement, opts?: IDateTimeOptions);
35
-
36
- destroy(): void;
37
- errorMsg(): this;
38
- errorMsg(message: string): this;
39
- hide(): this;
40
- max(max: Date): this;
41
- main(min: Date): this;
42
- owns(el: HTMLElement): boolean;
43
- val(): Date;
44
- val(set: string | Date): this;
45
- }
37
+ export class DateTime {
38
+ static use(moment: any); // Moment library
46
39
 
47
- export = DateTime;
40
+ constructor(el: HTMLElement, opts?: IDateTimeOptions);
41
+
42
+ destroy(): void;
43
+ errorMsg(): this;
44
+ errorMsg(message: string): this;
45
+ hide(): this;
46
+ max(max: Date): this;
47
+ main(min: Date): this;
48
+ owns(el: HTMLElement): boolean;
49
+ val(): Date;
50
+ val(set: string | Date): this;
51
+ valFormat(format: string): string;
52
+ valFormat(format: string, val: string): this;
53
+ }
48
54
 
49
- // jQuery interface additions
50
- interface JQuery {
51
- dtDateTime(opts?: IDateTimeOptions): JQuery;
55
+ export default DateTime;
56
+
57
+ // jQuery interface additions
58
+ interface JQuery {
59
+ dtDateTime(opts?: IDateTimeOptions): JQuery;
60
+ }
61
+
62
+ // Also attached to DataTables object
63
+ declare module 'datatables.net-datetime' {
64
+ interface ApiStatic {
65
+ DataTime: DateTime;
52
66
  }
53
67
  }
@@ -1,4 +1,4 @@
1
- /*! DateTime picker for DataTables.net v1.1.2
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
@@ -6,34 +6,11 @@
6
6
 
7
7
  /**
8
8
  * @summary DateTime picker for DataTables.net
9
- * @version 1.1.2
9
+ * @version 1.3.0
10
10
  * @file dataTables.dateTime.js
11
11
  * @author SpryMedia Ltd
12
12
  * @contact www.datatables.net/contact
13
13
  */
14
- (function( factory ){
15
- if ( typeof define === 'function' && define.amd ) {
16
- // AMD
17
- define( ['jquery'], function ( $ ) {
18
- return factory( $, window, document );
19
- } );
20
- }
21
- else if ( typeof exports === 'object' ) {
22
- // CommonJS
23
- module.exports = function (root, $) {
24
- if ( ! root ) {
25
- root = window;
26
- }
27
-
28
- return factory( $, root, root.document );
29
- };
30
- }
31
- else {
32
- // Browser
33
- factory( jQuery, window, document );
34
- }
35
- }(function( $, window, document, undefined ) {
36
- 'use strict';
37
14
 
38
15
  // Supported formatting and parsing libraries:
39
16
  // * Moment
@@ -87,25 +64,16 @@ var DateTime = function ( input, opts ) {
87
64
  this.c.maxDate = new Date(this.c.maxDate);
88
65
  }
89
66
 
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
67
  // DOM structure
100
68
  var structure = $(
101
69
  '<div class="'+classPrefix+'">'+
102
70
  '<div class="'+classPrefix+'-date">'+
103
71
  '<div class="'+classPrefix+'-title">'+
104
72
  '<div class="'+classPrefix+'-iconLeft">'+
105
- '<button type="button" title="'+i18n.previous+'">'+i18n.previous+'</button>'+
73
+ '<button type="button"></button>'+
106
74
  '</div>'+
107
75
  '<div class="'+classPrefix+'-iconRight">'+
108
- '<button type="button" title="'+i18n.next+'">'+i18n.next+'</button>'+
76
+ '<button type="button"></button>'+
109
77
  '</div>'+
110
78
  '<div class="'+classPrefix+'-label">'+
111
79
  '<span></span>'+
@@ -117,8 +85,8 @@ var DateTime = function ( input, opts ) {
117
85
  '</div>'+
118
86
  '</div>'+
119
87
  '<div class="'+classPrefix+'-buttons">'+
120
- '<a class="'+classPrefix+'-clear">'+i18n.clear+'</a>'+
121
- '<a class="'+classPrefix+'-today">'+i18n.today+'</a>'+
88
+ '<a class="'+classPrefix+'-clear"></a>'+
89
+ '<a class="'+classPrefix+'-today"></a>'+
122
90
  '</div>'+
123
91
  '<div class="'+classPrefix+'-calendar"></div>'+
124
92
  '</div>'+
@@ -138,9 +106,11 @@ var DateTime = function ( input, opts ) {
138
106
  calendar: structure.find( '.'+classPrefix+'-calendar' ),
139
107
  time: structure.find( '.'+classPrefix+'-time' ),
140
108
  error: structure.find( '.'+classPrefix+'-error' ),
141
- buttons: structure.find( '.'+classPrefix+'-buttons' ),
109
+ buttons: structure.find( '.'+classPrefix+'-buttons' ),
142
110
  clear: structure.find( '.'+classPrefix+'-clear' ),
143
111
  today: structure.find( '.'+classPrefix+'-today' ),
112
+ previous: structure.find( '.'+classPrefix+'-iconLeft' ),
113
+ next: structure.find( '.'+classPrefix+'-iconRight' ),
144
114
  input: $(input)
145
115
  };
146
116
 
@@ -268,28 +238,10 @@ $.extend( DateTime.prototype, {
268
238
  this.s.d = null;
269
239
  }
270
240
  else if ( set === '--now' ) {
271
- this.s.d = new Date();
241
+ this.s.d = this._dateToUtc(new Date());
272
242
  }
273
243
  else if ( typeof set === 'string' ) {
274
- // luxon uses different method names so need to be able to call them
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
- }
244
+ this.s.d = this._convert(set, this.c.format, null);
293
245
  }
294
246
 
295
247
  if ( write || write === undefined ) {
@@ -319,6 +271,25 @@ $.extend( DateTime.prototype, {
319
271
  return this;
320
272
  },
321
273
 
274
+ /**
275
+ * Similar to `val()` but uses a given date / time format
276
+ *
277
+ * @param format Format to get the data as (getter) or that is input (setter)
278
+ * @param val Value to write (if undefined, used as a getter)
279
+ * @returns
280
+ */
281
+ valFormat: function (format, val) {
282
+ if (! val) {
283
+ return this._convert(this.val(), null, format);
284
+ }
285
+
286
+ // Convert from the format given here to the instance's configured format
287
+ this.val(
288
+ this._convert(val, format, null)
289
+ );
290
+
291
+ return this;
292
+ },
322
293
 
323
294
  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
324
295
  * Constructor
@@ -586,6 +557,7 @@ $.extend( DateTime.prototype, {
586
557
  'setSeconds';
587
558
 
588
559
  d[set]( val );
560
+ that._setCalander();
589
561
  that._setTime();
590
562
  that._writeOutput( true );
591
563
  onChange();
@@ -619,6 +591,7 @@ $.extend( DateTime.prototype, {
619
591
  }
620
592
  else {
621
593
  that._setCalander();
594
+ that._setTime();
622
595
  }
623
596
 
624
597
  onChange();
@@ -648,11 +621,75 @@ $.extend( DateTime.prototype, {
648
621
  _compareDates: function( a, b ) {
649
622
  // Can't use toDateString as that converts to local time
650
623
  // luxon uses different method names so need to be able to call them
651
- return dateLib && dateLib == window.luxon
652
- ? dateLib.DateTime.fromJSDate(a).toISODate() === dateLib.DateTime.fromJSDate(b).toISODate()
624
+ return this._isLuxon()
625
+ ? dateLib.DateTime.fromJSDate(a).toUTC().toISODate() === dateLib.DateTime.fromJSDate(b).toUTC().toISODate()
653
626
  : this._dateToUtcString(a) === this._dateToUtcString(b);
654
627
  },
655
628
 
629
+ /**
630
+ * Convert from one format to another
631
+ *
632
+ * @param {string|Date} val Value
633
+ * @param {string|null} from Format to convert from. If null a `Date` must be given
634
+ * @param {string|null} to Format to convert to. If null a `Date` will be returned
635
+ * @returns {string|Date} Converted value
636
+ */
637
+ _convert(val, from, to) {
638
+ if (! val) {
639
+ return val;
640
+ }
641
+
642
+ if (! dateLib) {
643
+ // Note that in here from and to can either be null or YYYY-MM-DD
644
+ // They cannot be anything else
645
+ if ((! from && ! to) || (from && to)) {
646
+ // No conversion
647
+ return val;
648
+ }
649
+ else if (! from) {
650
+ // Date in, string back
651
+ return val.getUTCFullYear() +'-'+
652
+ this._pad(val.getUTCMonth() + 1) +'-'+
653
+ this._pad(val.getUTCDate());
654
+ }
655
+ else { // (! to)
656
+ // String in, date back
657
+ var match = val.match(/(\d{4})\-(\d{2})\-(\d{2})/ );
658
+ return match ?
659
+ new Date( Date.UTC(match[1], match[2]-1, match[3]) ) :
660
+ null;
661
+ }
662
+ }
663
+ else if (this._isLuxon()) {
664
+ // Luxon
665
+ var dtLux = val instanceof Date
666
+ ? dateLib.DateTime.fromJSDate(val).toUTC()
667
+ : dateLib.DateTime.fromFormat(val, from);
668
+
669
+ if (! dtLux.isValid) {
670
+ return null;
671
+ }
672
+
673
+ return to
674
+ ? dtLux.toFormat(to)
675
+ : this._dateToUtc(dtLux.toJSDate());
676
+ }
677
+ else {
678
+ // Moment / DayJS
679
+ var dtMo = val instanceof Date
680
+ ? dateLib.utc( val, undefined, this.c.locale, this.c.strict )
681
+ : dateLib.utc( val, from, this.c.locale, this.c.strict );
682
+
683
+ if (! dtMo.isValid()) {
684
+ return null;
685
+ }
686
+
687
+ return to
688
+ ? dtMo.format(to)
689
+ : dtMo.toDate();
690
+ }
691
+ },
692
+
656
693
  /**
657
694
  * When changing month, take account of the fact that some months don't have
658
695
  * the same number of days. For example going from January to February you
@@ -714,8 +751,8 @@ $.extend( DateTime.prototype, {
714
751
  */
715
752
  _dateToUtcString: function ( d ) {
716
753
  // luxon uses different method names so need to be able to call them
717
- return dateLib && dateLib == window.luxon
718
- ? dateLib.DateTime.fromJSDate(d).toISODate()
754
+ return this._isLuxon()
755
+ ? dateLib.DateTime.fromJSDate(d).toUTC().toISODate()
719
756
  : d.getUTCFullYear()+'-'+
720
757
  this._pad(d.getUTCMonth()+1)+'-'+
721
758
  this._pad(d.getUTCDate());
@@ -974,6 +1011,17 @@ $.extend( DateTime.prototype, {
974
1011
  return '<td class="'+this.c.classPrefix+'-week">' + weekNum + '</td>';
975
1012
  },
976
1013
 
1014
+ /**
1015
+ * Determine if Luxon is being used
1016
+ *
1017
+ * @returns Flag for Luxon
1018
+ */
1019
+ _isLuxon: function () {
1020
+ return dateLib && dateLib.DateTime && dateLib.Duration && dateLib.Settings
1021
+ ? true
1022
+ : false;
1023
+ },
1024
+
977
1025
  /**
978
1026
  * Check if the instance has a date object value - it might be null.
979
1027
  * If is doesn't set one to now.
@@ -983,6 +1031,13 @@ $.extend( DateTime.prototype, {
983
1031
  _needValue: function () {
984
1032
  if ( ! this.s.d ) {
985
1033
  this.s.d = this._dateToUtc( new Date() );
1034
+
1035
+ if (! this.s.parts.time) {
1036
+ this.s.d.setUTCHours(0);
1037
+ this.s.d.setUTCMinutes(0);
1038
+ this.s.d.setSeconds(0);
1039
+ this.s.d.setMilliseconds(0);
1040
+ }
986
1041
  }
987
1042
 
988
1043
  return this.s.d;
@@ -1077,7 +1132,7 @@ $.extend( DateTime.prototype, {
1077
1132
  'selected' :
1078
1133
  '';
1079
1134
 
1080
- if (allowed && $.inArray(value, allowed) === -1) {
1135
+ if (typeof value === 'number' && allowed && $.inArray(value, allowed) === -1) {
1081
1136
  selected += ' disabled';
1082
1137
  }
1083
1138
 
@@ -1137,9 +1192,11 @@ $.extend( DateTime.prototype, {
1137
1192
  // Slight hack to allow for the different number of columns
1138
1193
  a += '</tbody></thead><table class="'+className+' '+className+'-nospace"><tbody>';
1139
1194
 
1140
- var start = range !== null ?
1141
- range :
1142
- Math.floor( val / 10 )*10;
1195
+ var start = range !== null
1196
+ ? range
1197
+ : val === -1
1198
+ ? 0
1199
+ : Math.floor( val / 10 )*10;
1143
1200
 
1144
1201
  a += '<tr>';
1145
1202
  for (j=start+1 ; j<start+10 ; j++ ) {
@@ -1183,6 +1240,18 @@ $.extend( DateTime.prototype, {
1183
1240
 
1184
1241
  this._options( 'month', this._range( 0, 11 ), i18n.months );
1185
1242
  this._options( 'year', this._range( i, j ) );
1243
+
1244
+ // Set the language strings in case any have changed
1245
+ this.dom.today.text(i18n.today).text(i18n.today);
1246
+ this.dom.clear.text(i18n.clear).text(i18n.clear);
1247
+ this.dom.previous
1248
+ .attr('title', i18n.previous)
1249
+ .children('button')
1250
+ .text(i18n.previous);
1251
+ this.dom.next
1252
+ .attr('title', i18n.next)
1253
+ .children('button')
1254
+ .text(i18n.next);
1186
1255
  },
1187
1256
 
1188
1257
  /**
@@ -1319,15 +1388,15 @@ $.extend( DateTime.prototype, {
1319
1388
 
1320
1389
  // luxon uses different method names so need to be able to call them. This happens a few time later in this method too
1321
1390
  var luxDT = null
1322
- if (dateLib && dateLib == window.luxon) {
1323
- luxDT = dateLib.DateTime.fromJSDate(d);
1391
+ if (this._isLuxon()) {
1392
+ luxDT = dateLib.DateTime.fromJSDate(d).toUTC();
1324
1393
  }
1325
1394
 
1326
1395
  var hours = luxDT != null
1327
1396
  ? luxDT.hour
1328
1397
  : d
1329
1398
  ? d.getUTCHours()
1330
- : 0;
1399
+ : -1;
1331
1400
 
1332
1401
  var allowed = function ( prop ) { // Backwards compt with `Increment` option
1333
1402
  return that.c[prop+'Available'] ?
@@ -1343,7 +1412,8 @@ $.extend( DateTime.prototype, {
1343
1412
  ? luxDT.minute
1344
1413
  : d
1345
1414
  ? d.getUTCMinutes()
1346
- : 0, allowed('minutes'),
1415
+ : -1,
1416
+ allowed('minutes'),
1347
1417
  this.s.minutesRange
1348
1418
  );
1349
1419
  this._optionsTime(
@@ -1353,7 +1423,7 @@ $.extend( DateTime.prototype, {
1353
1423
  ? luxDT.second
1354
1424
  : d
1355
1425
  ? d.getSeconds()
1356
- : 0,
1426
+ : -1,
1357
1427
  allowed('seconds'),
1358
1428
  this.s.secondsRange
1359
1429
  );
@@ -1428,17 +1498,8 @@ $.extend( DateTime.prototype, {
1428
1498
  var date = this.s.d;
1429
1499
  var out = '';
1430
1500
 
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
1501
  if (date) {
1435
- out = dateLib && dateLib == window.luxon
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());
1502
+ out = this._convert(date, null, this.c.format);
1442
1503
  }
1443
1504
 
1444
1505
  this.dom.input
@@ -1535,7 +1596,7 @@ DateTime.defaults = {
1535
1596
  yearRange: 25
1536
1597
  };
1537
1598
 
1538
- DateTime.version = '1.1.2';
1599
+ DateTime.version = '1.3.0';
1539
1600
 
1540
1601
  // Global export - if no conflicts
1541
1602
  if (! window.DateTime) {
@@ -1558,7 +1619,3 @@ if ($.fn.dataTable) {
1558
1619
  $.fn.dataTable.Editor.DateTime = DateTime;
1559
1620
  }
1560
1621
  }
1561
-
1562
- return DateTime;
1563
-
1564
- }));
package/make.sh CHANGED
@@ -29,7 +29,7 @@ fi
29
29
 
30
30
  ./node_modules/gulp/bin/gulp.js
31
31
 
32
- js_compress dist/dataTables.dateTime.js
32
+ js_wrap dist/dataTables.dateTime.js "jquery"
33
33
  css_compress dist/dataTables.dateTime.css
34
34
 
35
35
  if [ ! -d $OUT_DIR ]; then
@@ -39,6 +39,7 @@ if [ ! -d $OUT_DIR ]; then
39
39
  fi
40
40
 
41
41
  rsync -r dist/*.js $OUT_DIR/js
42
+ rsync -r dist/*.mjs $OUT_DIR/js
42
43
  rsync -r dist/*.css $OUT_DIR/css
43
44
 
44
45
  # Copy and build examples
package/nuget.nuspec CHANGED
@@ -2,7 +2,7 @@
2
2
  <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3
3
  <metadata>
4
4
  <id>datatables.net-datetime</id>
5
- <version>1.1.2</version>
5
+ <version>1.3.0</version>
6
6
  <description>DataTables date / time picker</description>
7
7
  <authors>SpryMedia Ltd</authors>
8
8
  <projectUrl>http://datatables.net</projectUrl>
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "datatables.net-datetime",
3
- "version": "1.1.2",
3
+ "version": "1.3.0",
4
4
  "description": "DateTime picker for DataTables.net",
5
5
  "main": "dist/dataTables.dateTime.js",
6
+ "module": "dist/dataTables.dateTime.mjs",
6
7
  "style": "dist/dataTables.dateTime.css",
7
8
  "types": "js/dataTables.dateTime.d.ts",
8
9
  "scripts": {
@@ -21,7 +21,7 @@ describe('dateTime - api - val()', function () {
21
21
  dt.html('input');
22
22
  it('Ensure its a function', function () {
23
23
  el = new DateTime(document.getElementById('test'));
24
- expect(typeof el.min).toBe('function');
24
+ expect(typeof el.val).toBe('function');
25
25
  });
26
26
  it('Getter returns null if no date set', function () {
27
27
  expect(el.val()).toBe(null);