datatables.net-datetime 1.5.0 → 1.5.2

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.
Files changed (54) hide show
  1. package/datatables.net-datetime.1.5.0.nupkg +0 -0
  2. package/dist/dataTables.dateTime.js +381 -375
  3. package/dist/dataTables.dateTime.min.js +2 -2
  4. package/dist/dataTables.dateTime.min.mjs +2 -2
  5. package/dist/dataTables.dateTime.mjs +380 -374
  6. package/docs/api/DateTime.use().xml +0 -2
  7. package/docs/api/destroy().xml +0 -2
  8. package/docs/api/display().xml +1 -1
  9. package/docs/api/errorMsg().xml +2 -6
  10. package/docs/api/hide().xml +0 -4
  11. package/docs/api/max().xml +1 -3
  12. package/docs/api/min().xml +1 -3
  13. package/docs/api/owns().xml +2 -4
  14. package/docs/api/val().xml +2 -6
  15. package/docs/api/valFormat().xml +2 -6
  16. package/docs/option/buttons.clear.xml +0 -2
  17. package/docs/option/buttons.today.xml +0 -2
  18. package/docs/option/buttons.xml +0 -2
  19. package/docs/option/disableDays.xml +3 -3
  20. package/docs/option/format.xml +1 -3
  21. package/docs/option/hoursAvailable.xml +2 -2
  22. package/docs/option/i18n.amPm.xml +1 -1
  23. package/docs/option/i18n.clear.xml +1 -3
  24. package/docs/option/i18n.hours.xml +1 -1
  25. package/docs/option/i18n.minutes.xml +1 -1
  26. package/docs/option/i18n.months.xml +15 -2
  27. package/docs/option/i18n.next.xml +2 -2
  28. package/docs/option/i18n.previous.xml +2 -2
  29. package/docs/option/i18n.seconds.xml +1 -1
  30. package/docs/option/i18n.today.xml +1 -3
  31. package/docs/option/i18n.unknown.xml +1 -1
  32. package/docs/option/i18n.weekdays.xml +1 -1
  33. package/docs/option/i18n.xml +3 -5
  34. package/docs/option/locale.xml +0 -2
  35. package/docs/option/maxDate.xml +0 -4
  36. package/docs/option/minDate.xml +0 -4
  37. package/docs/option/minutesAvailable.xml +2 -2
  38. package/docs/option/onChange.xml +0 -2
  39. package/docs/option/secondsAvailable.xml +2 -2
  40. package/docs/option/showWeekNumber.xml +2 -2
  41. package/docs/option/yearRange.xml +2 -2
  42. package/examples/initialisation/datetime.xml +2 -2
  43. package/examples/initialisation/moment.xml +2 -2
  44. package/examples/integration/form.xml +20 -2
  45. package/js/dataTables.dateTime.js +380 -374
  46. package/nuget.nuspec +1 -1
  47. package/package.json +1 -1
  48. package/test/api/dateTime.display().js +47 -0
  49. package/test/options/dateTime.buttons.js +71 -0
  50. package/test/options/dateTime.hoursAvailable.js +38 -0
  51. package/test/options/dateTime.locale.js +31 -0
  52. package/test/options/dateTime.minutesAvailable.js +46 -0
  53. package/test/options/dateTime.secondsAvailable.js +46 -0
  54. package/datatables.net-datetime.1.4.0.nupkg +0 -0
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.5.0</version>
5
+ <version>1.5.2</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,6 +1,6 @@
1
1
  {
2
2
  "name": "datatables.net-datetime",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "DateTime picker for DataTables.net",
5
5
  "main": "dist/dataTables.dateTime.js",
6
6
  "module": "dist/dataTables.dateTime.mjs",
@@ -0,0 +1,47 @@
1
+ describe('dateTime - api - display()', function () {
2
+ dt.libs({
3
+ js: ['jquery', 'datatables', 'moment', 'datetime'],
4
+ css: ['datatables', 'datetime']
5
+ });
6
+
7
+ let el;
8
+
9
+ describe('Check the defaults', function () {
10
+ dt.html('input');
11
+ it('Ensure its a function', function () {
12
+ el = new DateTime(document.getElementById('test'));
13
+ expect(typeof el.display).toBe('function');
14
+ });
15
+ it('Getter returns an object with todays date', function () {
16
+ const d = new Date();
17
+
18
+ $('#test').click();
19
+ expect(el.display()).toEqual({ year: d.getFullYear(), month: d.getMonth() + 1 });
20
+ });
21
+ it('Setter returns an API instance', function () {
22
+ expect(el.display(2046, 10) instanceof DateTime).toBe(true);
23
+ });
24
+ });
25
+
26
+ describe('Functional tests', function () {
27
+ dt.html('input');
28
+ it('Setter with past date', function () {
29
+ var el = new DateTime('#test');
30
+ $('#test').click();
31
+ el.display(2002, 4);
32
+
33
+ setTimeout(function () {
34
+ expect(el.display()).toEqual({ year: 2002, month: 4 });
35
+ }, 500);
36
+ });
37
+ it('Setter with past date', function () {
38
+ var el = new DateTime('#test');
39
+ $('#test').click();
40
+ el.display(2046, 10);
41
+
42
+ setTimeout(function () {
43
+ expect(el.display()).toEqual({ year: 2046, month: 10 });
44
+ }, 500);
45
+ });
46
+ });
47
+ });
@@ -0,0 +1,71 @@
1
+ describe('dateTime - options - buttons', function () {
2
+ dt.libs({
3
+ js: ['jquery', 'datatables', 'moment', 'datetime'],
4
+ css: ['datatables', 'datetime']
5
+ });
6
+
7
+ let el;
8
+ const d = new Date();
9
+
10
+ function pad(num) {
11
+ return num < 10 ? '0' + num : num;
12
+ }
13
+
14
+ // TK COLIN make this a generic function somewhere as repeated
15
+ function format(d) {
16
+ return d.getUTCFullYear() + '-' + pad(1 + d.getUTCMonth()) + '-' + pad(d.getUTCDate());
17
+ }
18
+
19
+ describe('Functional tests', function () {
20
+ dt.html('input');
21
+ it('No buttons present by default', function () {
22
+ el = new DateTime('#test');
23
+ $('#test').click();
24
+ expect($('.dt-datetime-clear').is(':visible')).toBe(false);
25
+ expect($('.dt-datetime-today').is(':visible')).toBe(false);
26
+ });
27
+
28
+ dt.html('input');
29
+ it('Both buttons present', function () {
30
+ el = new DateTime('#test', { buttons: { today: true, clear: true } });
31
+ $('#test').click();
32
+ expect($('.dt-datetime-clear').is(':visible')).toBe(true);
33
+ expect($('.dt-datetime-today').is(':visible')).toBe(true);
34
+ });
35
+
36
+ dt.html('input');
37
+ it('Just today', function () {
38
+ el = new DateTime('#test', { buttons: { today: true } });
39
+ $('#test').click();
40
+ expect($('.dt-datetime-clear').is(':visible')).toBe(false);
41
+ expect($('.dt-datetime-today').is(':visible')).toBe(true);
42
+ });
43
+ it('... and confirm behaviour of today', function () {
44
+ // change the date
45
+ el.display(2021, 4);
46
+ expect(el.display()).toEqual({ year: 2021, month: 4 });
47
+
48
+ $('.dt-datetime-today').click();
49
+
50
+ // TK COLIN disabled for now
51
+ // expect(el.display()).toEqual({ year: d.getFullYear(), month: d.getMonth() + 1 });
52
+ });
53
+
54
+ dt.html('input');
55
+ it('Just clear', function () {
56
+ el = new DateTime('#test', { buttons: { clear: true } });
57
+ $('#test').click();
58
+ expect($('.dt-datetime-clear').is(':visible')).toBe(true);
59
+ expect($('.dt-datetime-today').is(':visible')).toBe(false);
60
+ });
61
+ it('... and confirm behaviour of today', function () {
62
+ $('td.now button').click();
63
+ expect(format(el.val())).toEqual(format(d));
64
+
65
+ $('#test').click();
66
+ $('.dt-datetime-clear').click();
67
+
68
+ // expect(el.val()).toEqual(null);
69
+ });
70
+ });
71
+ });
@@ -0,0 +1,38 @@
1
+ describe('dateTime - options - hoursAvailable', function () {
2
+ dt.libs({
3
+ js: ['jquery', 'datatables', 'moment', 'datetime'],
4
+ css: ['datatables', 'datetime']
5
+ });
6
+
7
+ let el;
8
+
9
+ describe('Functional tests', function () {
10
+ dt.html('input');
11
+ it('Date & time', function () {
12
+ el = new DateTime('#test', {
13
+ format: 'D MMM YYYY HH:mm',
14
+ hoursAvailable: [1, 15, 23]
15
+ });
16
+ $('#test').click();
17
+
18
+ expect($('.dt-datetime-hours .dt-datetime-table td').not('.disabled').length).toBe(3);
19
+ expect($('.dt-datetime-hours .dt-datetime-table td').not('.disabled').eq(0).text()).toBe('01');
20
+ expect($('.dt-datetime-hours .dt-datetime-table td').not('.disabled').eq(1).text()).toBe('15');
21
+ expect($('.dt-datetime-hours .dt-datetime-table td').not('.disabled').eq(2).text()).toBe('23');
22
+ });
23
+
24
+ dt.html('input');
25
+ it('Just time', function () {
26
+ el = new DateTime('#test', {
27
+ format: ' HH:mm',
28
+ hoursAvailable: [0, 15, 23]
29
+ });
30
+ $('#test').click();
31
+
32
+ expect($('.dt-datetime-hours .dt-datetime-table td').not('.disabled').length).toBe(3);
33
+ expect($('.dt-datetime-hours .dt-datetime-table td').not('.disabled').eq(0).text()).toBe('00');
34
+ expect($('.dt-datetime-hours .dt-datetime-table td').not('.disabled').eq(1).text()).toBe('15');
35
+ expect($('.dt-datetime-hours .dt-datetime-table td').not('.disabled').eq(2).text()).toBe('23');
36
+ });
37
+ });
38
+ });
@@ -0,0 +1,31 @@
1
+ describe('dateTime - options - locale', function () {
2
+ dt.libs({
3
+ js: ['jquery', 'datatables', 'moment', 'datetime'],
4
+ css: ['datatables', 'datetime']
5
+ });
6
+
7
+ let el;
8
+ const d = new Date();
9
+
10
+ function pad(num) {
11
+ return num < 10 ? '0' + num : num;
12
+ }
13
+
14
+ // TK COLIN make this a generic function somewhere as repeated
15
+ function format(d) {
16
+ return d.getUTCFullYear() + '-' + pad(1 + d.getUTCMonth()) + '-' + pad(d.getUTCDate());
17
+ }
18
+
19
+ // TK COLIN not entirely sure what this does, but skipping for now as other priorities
20
+ describe('Functional tests', function () {
21
+ dt.html('input');
22
+ it('No buttons present by default', function () {
23
+ el = new DateTime('#test', { locale: 'fr' });
24
+
25
+ $('#test').click();
26
+ $('td.now button').click();
27
+
28
+ expect(format(el.val())).toEqual(format(d));
29
+ });
30
+ });
31
+ });
@@ -0,0 +1,46 @@
1
+ describe('dateTime - options - minutesAvailable', function () {
2
+ dt.libs({
3
+ js: ['jquery', 'datatables', 'moment', 'datetime'],
4
+ css: ['datatables', 'datetime']
5
+ });
6
+
7
+ let el;
8
+
9
+ describe('Functional tests', function () {
10
+ dt.html('input');
11
+ it('Date & time', function () {
12
+ el = new DateTime('#test', {
13
+ format: 'D MMM YYYY HH:mm:ss',
14
+ minutesAvailable: [1, 2, 3]
15
+ });
16
+
17
+ $('#test').click();
18
+
19
+ expect($('.dt-datetime-minutes .dt-datetime-table td').not('.disabled').length).toBe(3);
20
+ expect($('.dt-datetime-minutes .dt-datetime-table td').not('.disabled').eq(0).text()).toBe('01');
21
+ expect($('.dt-datetime-minutes .dt-datetime-table td').not('.disabled').eq(1).text()).toBe('02');
22
+ expect($('.dt-datetime-minutes .dt-datetime-table td').not('.disabled').eq(2).text()).toBe('03');
23
+ });
24
+
25
+ dt.html('input');
26
+ it('Just time with scattered values', function () {
27
+ el = new DateTime('#test', {
28
+ format: ' HH:mm',
29
+ minutesAvailable: [1, 15, 18]
30
+ });
31
+
32
+ $('#test').click();
33
+
34
+ // first block
35
+ expect($('.dt-datetime-minutes .dt-datetime-table td').not('.disabled').length).toBe(1);
36
+ expect($('.dt-datetime-minutes .dt-datetime-table td').not('.disabled').eq(0).text()).toBe('01');
37
+
38
+ // second block
39
+ $('.dt-datetime-minutes tbody tr:eq(0) td:eq(1) button').click()
40
+
41
+ expect($('.dt-datetime-minutes .dt-datetime-table td').not('.disabled').length).toBe(2);
42
+ expect($('.dt-datetime-minutes .dt-datetime-table td').not('.disabled').eq(0).text()).toBe('15');
43
+ expect($('.dt-datetime-minutes .dt-datetime-table td').not('.disabled').eq(1).text()).toBe('18');
44
+ });
45
+ });
46
+ });
@@ -0,0 +1,46 @@
1
+ describe('dateTime - options - secondsAvailable', function () {
2
+ dt.libs({
3
+ js: ['jquery', 'datatables', 'moment', 'datetime'],
4
+ css: ['datatables', 'datetime']
5
+ });
6
+
7
+ let el;
8
+
9
+ describe('Functional tests', function () {
10
+ dt.html('input');
11
+ it('Date & time', function () {
12
+ el = new DateTime('#test', {
13
+ format: 'D MMM YYYY HH:mm:ss',
14
+ secondsAvailable: [1, 2, 3]
15
+ });
16
+
17
+ $('#test').click();
18
+
19
+ expect($('.dt-datetime-seconds .dt-datetime-table td').not('.disabled').length).toBe(3);
20
+ expect($('.dt-datetime-seconds .dt-datetime-table td').not('.disabled').eq(0).text()).toBe('01');
21
+ expect($('.dt-datetime-seconds .dt-datetime-table td').not('.disabled').eq(1).text()).toBe('02');
22
+ expect($('.dt-datetime-seconds .dt-datetime-table td').not('.disabled').eq(2).text()).toBe('03');
23
+ });
24
+
25
+ dt.html('input');
26
+ it('Just time with scattered values', function () {
27
+ el = new DateTime('#test', {
28
+ format: 'mm:ss',
29
+ secondsAvailable: [1, 15, 18]
30
+ });
31
+
32
+ $('#test').click();
33
+
34
+ // first block
35
+ expect($('.dt-datetime-seconds .dt-datetime-table td').not('.disabled').length).toBe(1);
36
+ expect($('.dt-datetime-seconds .dt-datetime-table td').not('.disabled').eq(0).text()).toBe('01');
37
+
38
+ // second block
39
+ $('.dt-datetime-seconds tbody tr:eq(0) td:eq(1) button').click()
40
+
41
+ expect($('.dt-datetime-seconds .dt-datetime-table td').not('.disabled').length).toBe(2);
42
+ expect($('.dt-datetime-seconds .dt-datetime-table td').not('.disabled').eq(0).text()).toBe('15');
43
+ expect($('.dt-datetime-seconds .dt-datetime-table td').not('.disabled').eq(1).text()).toBe('18');
44
+ });
45
+ });
46
+ });
Binary file