date-and-time 0.14.2 → 2.0.1

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 (133) hide show
  1. package/EXTEND.md +29 -11
  2. package/LOCALE.md +19 -34
  3. package/PLUGINS.md +222 -113
  4. package/README.md +203 -171
  5. package/date-and-time.js +171 -147
  6. package/date-and-time.min.js +14 -14
  7. package/esm/date-and-time.es.js +466 -0
  8. package/esm/date-and-time.es.min.js +17 -0
  9. package/esm/date-and-time.mjs +466 -0
  10. package/esm/locale/ar.es.js +39 -0
  11. package/esm/locale/ar.mjs +39 -0
  12. package/esm/locale/az.es.js +44 -0
  13. package/esm/locale/az.mjs +44 -0
  14. package/esm/locale/bn.es.js +50 -0
  15. package/esm/locale/bn.mjs +50 -0
  16. package/esm/locale/cs.es.js +22 -0
  17. package/esm/locale/cs.mjs +22 -0
  18. package/esm/locale/de.es.js +23 -0
  19. package/esm/locale/de.mjs +23 -0
  20. package/esm/locale/dk.es.js +22 -0
  21. package/esm/locale/dk.mjs +22 -0
  22. package/esm/locale/el.es.js +44 -0
  23. package/esm/locale/el.mjs +44 -0
  24. package/esm/locale/en.es.js +13 -0
  25. package/esm/locale/en.mjs +13 -0
  26. package/esm/locale/es.es.js +42 -0
  27. package/esm/locale/es.mjs +42 -0
  28. package/esm/locale/fa.es.js +39 -0
  29. package/esm/locale/fa.mjs +39 -0
  30. package/esm/locale/fr.es.js +23 -0
  31. package/esm/locale/fr.mjs +23 -0
  32. package/esm/locale/hi.es.js +50 -0
  33. package/esm/locale/hi.mjs +50 -0
  34. package/esm/locale/hu.es.js +23 -0
  35. package/esm/locale/hu.mjs +23 -0
  36. package/esm/locale/id.es.js +46 -0
  37. package/esm/locale/id.mjs +46 -0
  38. package/esm/locale/it.es.js +23 -0
  39. package/esm/locale/it.mjs +23 -0
  40. package/esm/locale/ja.es.js +31 -0
  41. package/esm/locale/ja.mjs +31 -0
  42. package/esm/locale/jv.es.js +46 -0
  43. package/esm/locale/jv.mjs +46 -0
  44. package/esm/locale/ko.es.js +23 -0
  45. package/esm/locale/ko.mjs +23 -0
  46. package/esm/locale/my.es.js +38 -0
  47. package/esm/locale/my.mjs +38 -0
  48. package/esm/locale/nl.es.js +37 -0
  49. package/esm/locale/nl.mjs +37 -0
  50. package/esm/locale/pa-in.es.js +62 -0
  51. package/esm/locale/pa-in.mjs +62 -0
  52. package/esm/locale/pl.es.js +37 -0
  53. package/esm/locale/pl.mjs +37 -0
  54. package/esm/locale/pt.es.js +44 -0
  55. package/esm/locale/pt.mjs +44 -0
  56. package/esm/locale/ro.es.js +22 -0
  57. package/esm/locale/ro.mjs +22 -0
  58. package/esm/locale/ru.es.js +44 -0
  59. package/esm/locale/ru.mjs +44 -0
  60. package/esm/locale/rw.es.js +22 -0
  61. package/esm/locale/rw.mjs +22 -0
  62. package/esm/locale/sr.es.js +22 -0
  63. package/esm/locale/sr.mjs +22 -0
  64. package/esm/locale/th.es.js +23 -0
  65. package/esm/locale/th.mjs +23 -0
  66. package/esm/locale/tr.es.js +22 -0
  67. package/esm/locale/tr.mjs +22 -0
  68. package/esm/locale/uk.es.js +57 -0
  69. package/esm/locale/uk.mjs +57 -0
  70. package/esm/locale/uz.es.js +22 -0
  71. package/esm/locale/uz.mjs +22 -0
  72. package/esm/locale/vi.es.js +23 -0
  73. package/esm/locale/vi.mjs +23 -0
  74. package/esm/locale/zh-cn.es.js +48 -0
  75. package/esm/locale/zh-cn.mjs +48 -0
  76. package/esm/locale/zh-tw.es.js +46 -0
  77. package/esm/locale/zh-tw.mjs +46 -0
  78. package/esm/plugin/day-of-week.es.js +19 -0
  79. package/esm/plugin/day-of-week.mjs +19 -0
  80. package/esm/plugin/meridiem.es.js +47 -0
  81. package/esm/plugin/meridiem.mjs +47 -0
  82. package/esm/plugin/microsecond.es.js +31 -0
  83. package/esm/plugin/microsecond.mjs +31 -0
  84. package/esm/plugin/ordinal.es.js +34 -0
  85. package/esm/plugin/ordinal.mjs +34 -0
  86. package/esm/plugin/timespan.es.js +75 -0
  87. package/esm/plugin/timespan.mjs +75 -0
  88. package/esm/plugin/timezone.es.js +73 -0
  89. package/esm/plugin/timezone.mjs +73 -0
  90. package/esm/plugin/two-digit-year.es.js +21 -0
  91. package/esm/plugin/two-digit-year.mjs +21 -0
  92. package/locale/ar.js +14 -19
  93. package/locale/az.js +14 -19
  94. package/locale/bn.js +14 -19
  95. package/locale/cs.js +14 -19
  96. package/locale/de.js +15 -20
  97. package/locale/dk.js +15 -20
  98. package/locale/el.js +21 -24
  99. package/locale/en.js +17 -19
  100. package/locale/es.js +14 -19
  101. package/locale/fa.js +14 -19
  102. package/locale/fr.js +14 -19
  103. package/locale/hi.js +14 -19
  104. package/locale/hu.js +14 -19
  105. package/locale/id.js +14 -19
  106. package/locale/it.js +14 -19
  107. package/locale/ja.js +14 -19
  108. package/locale/jv.js +14 -19
  109. package/locale/ko.js +14 -19
  110. package/locale/my.js +14 -19
  111. package/locale/nl.js +20 -23
  112. package/locale/pa-in.js +14 -19
  113. package/locale/pl.js +20 -23
  114. package/locale/pt.js +14 -19
  115. package/locale/ro.js +15 -20
  116. package/locale/ru.js +14 -19
  117. package/locale/rw.js +30 -0
  118. package/locale/sr.js +14 -19
  119. package/locale/th.js +14 -19
  120. package/locale/tr.js +14 -19
  121. package/locale/uk.js +23 -26
  122. package/locale/uz.js +14 -19
  123. package/locale/vi.js +14 -19
  124. package/locale/zh-cn.js +14 -19
  125. package/locale/zh-tw.js +14 -19
  126. package/package.json +26 -11
  127. package/plugin/day-of-week.js +13 -14
  128. package/plugin/meridiem.js +32 -24
  129. package/plugin/microsecond.js +14 -15
  130. package/plugin/ordinal.js +13 -14
  131. package/plugin/timespan.js +13 -14
  132. package/plugin/timezone.js +81 -0
  133. package/plugin/two-digit-year.js +13 -19
package/locale/zh-cn.js CHANGED
@@ -1,12 +1,16 @@
1
- /**
2
- * @preserve date-and-time.js locale configuration
3
- * @preserve Chinese (zh-cn)
4
- * @preserve It is using moment.js locale configuration as a reference.
5
- */
6
- (function (global) {
7
- 'use strict';
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale["zh-cn"] = factory()));
5
+ })(this, (function () { 'use strict';
8
6
 
9
- var exec = function (date) {
7
+ /**
8
+ * @preserve date-and-time.js locale configuration
9
+ * @preserve Chinese (zh-cn)
10
+ * @preserve It is using moment.js locale configuration as a reference.
11
+ */
12
+
13
+ var zh_cn = function (date) {
10
14
  var code = 'zh-cn';
11
15
 
12
16
  date.locale(code, {
@@ -47,15 +51,6 @@
47
51
  return code;
48
52
  };
49
53
 
50
- if (typeof module === 'object' && typeof module.exports === 'object') {
51
- (module.paths || []).push('./');
52
- module.exports = exec;
53
- // This line will be removed in the next version.
54
- exec(require('date-and-time'));
55
- } else if (typeof define === 'function' && define.amd) {
56
- define(['date-and-time'], exec);
57
- } else {
58
- exec(global.date);
59
- }
54
+ return zh_cn;
60
55
 
61
- }(this));
56
+ }));
package/locale/zh-tw.js CHANGED
@@ -1,12 +1,16 @@
1
- /**
2
- * @preserve date-and-time.js locale configuration
3
- * @preserve Chinese (zh-tw)
4
- * @preserve It is using moment.js locale configuration as a reference.
5
- */
6
- (function (global) {
7
- 'use strict';
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale["zh-tw"] = factory()));
5
+ })(this, (function () { 'use strict';
8
6
 
9
- var exec = function (date) {
7
+ /**
8
+ * @preserve date-and-time.js locale configuration
9
+ * @preserve Chinese (zh-tw)
10
+ * @preserve It is using moment.js locale configuration as a reference.
11
+ */
12
+
13
+ var zh_tw = function (date) {
10
14
  var code = 'zh-tw';
11
15
 
12
16
  date.locale(code, {
@@ -45,15 +49,6 @@
45
49
  return code;
46
50
  };
47
51
 
48
- if (typeof module === 'object' && typeof module.exports === 'object') {
49
- (module.paths || []).push('./');
50
- module.exports = exec;
51
- // This line will be removed in the next version.
52
- exec(require('date-and-time'));
53
- } else if (typeof define === 'function' && define.amd) {
54
- define(['date-and-time'], exec);
55
- } else {
56
- exec(global.date);
57
- }
52
+ return zh_tw;
58
53
 
59
- }(this));
54
+ }));
package/package.json CHANGED
@@ -1,11 +1,30 @@
1
1
  {
2
2
  "name": "date-and-time",
3
- "version": "0.14.2",
3
+ "version": "2.0.1",
4
4
  "description": "A Minimalist DateTime utility for Node.js and the browser",
5
5
  "main": "date-and-time.js",
6
+ "module": "esm/date-and-time.es.js",
7
+ "unpkg": "date-and-time.min.js",
8
+ "exports": {
9
+ ".": {
10
+ "browser": "./esm/date-and-time.es.js",
11
+ "import": "./esm/date-and-time.mjs",
12
+ "require": "./date-and-time.js"
13
+ },
14
+ "./locale/*": {
15
+ "browser": "./esm/locale/*.es.js",
16
+ "import": "./esm/locale/*.mjs",
17
+ "require": "./locale/*.js"
18
+ },
19
+ "./plugin/*": {
20
+ "browser": "./esm/plugin/*.es.js",
21
+ "import": "./esm/plugin/*.mjs",
22
+ "require": "./plugin/*.js"
23
+ }
24
+ },
6
25
  "scripts": {
7
- "test": "./test.sh",
8
- "compile": "./compile.sh date-and-time.js date-and-time.min.js"
26
+ "build": "rollup --config rollup.config.js",
27
+ "test": "./test.sh"
9
28
  },
10
29
  "repository": {
11
30
  "type": "git",
@@ -25,14 +44,10 @@
25
44
  },
26
45
  "homepage": "https://github.com/knowledgecode/date-and-time",
27
46
  "devDependencies": {
28
- "babel-preset-env": "^1.7.0",
29
- "babelify": "^7.3.0",
30
- "browserify": "^16.5.2",
47
+ "@ampproject/rollup-plugin-closure-compiler": "^0.27.0",
31
48
  "expect.js": "^0.3.1",
32
- "mocha": "^7.2.0",
33
- "mocha-headless-chrome": "^3.1.0"
34
- },
35
- "browser": {
36
- "date-and-time": "./date-and-time.js"
49
+ "mocha": "^9.1.2",
50
+ "mocha-headless-chrome": "^3.1.0",
51
+ "rollup": "^2.58.0"
37
52
  }
38
53
  }
@@ -1,7 +1,15 @@
1
- (function (global) {
2
- 'use strict';
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin["day-of-week"] = factory()));
5
+ })(this, (function () { 'use strict';
3
6
 
4
- var exec = function (date) {
7
+ /**
8
+ * @preserve date-and-time.js plugin
9
+ * @preserve day-of-week
10
+ */
11
+
12
+ var plugin = function (date) {
5
13
  var name = 'day-of-week';
6
14
 
7
15
  date.plugin(name, {
@@ -14,15 +22,6 @@
14
22
  return name;
15
23
  };
16
24
 
17
- if (typeof module === 'object' && typeof module.exports === 'object') {
18
- (module.paths || []).push('./');
19
- module.exports = exec;
20
- // This line will be removed in the next version.
21
- exec(require('date-and-time'));
22
- } else if (typeof define === 'function' && define.amd) {
23
- define(['date-and-time'], exec);
24
- } else {
25
- exec(global.date);
26
- }
25
+ return plugin;
27
26
 
28
- }(this));
27
+ }));
@@ -1,31 +1,48 @@
1
- (function (global) {
2
- 'use strict';
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin.meridiem = factory()));
5
+ })(this, (function () { 'use strict';
3
6
 
4
- var exec = function (date) {
7
+ /**
8
+ * @preserve date-and-time.js plugin
9
+ * @preserve meridiem
10
+ */
11
+
12
+ var plugin = function (date) {
5
13
  var name = 'meridiem';
6
14
 
7
15
  date.plugin(name, {
8
16
  res: {
9
- A: ['AM', 'PM', 'A.M.', 'P.M.', 'am', 'pm', 'a.m.', 'p.m.']
17
+ AA: ['A.M.', 'P.M.'],
18
+ a: ['am', 'pm'],
19
+ aa: ['a.m.', 'p.m.']
10
20
  },
11
21
  formatter: {
12
22
  AA: function (d) {
13
- // A.M. / P.M.
14
- return this.res.A[d.getHours() > 11 | 0 + 2];
23
+ return this.res.AA[d.getHours() > 11 | 0];
15
24
  },
16
25
  a: function (d) {
17
- // am / pm
18
- return this.res.A[d.getHours() > 11 | 0 + 4];
26
+ return this.res.a[d.getHours() > 11 | 0];
19
27
  },
20
28
  aa: function (d) {
21
- // a.m. / p.m.
22
- return this.res.A[d.getHours() > 11 | 0 + 6];
29
+ return this.res.aa[d.getHours() > 11 | 0];
23
30
  }
24
31
  },
25
32
  parser: {
26
- A: function (str) {
27
- var result = this.find(this.res.A, str);
28
- result.value %= 2;
33
+ AA: function (str) {
34
+ var result = this.find(this.res.AA, str);
35
+ result.token = 'A';
36
+ return result;
37
+ },
38
+ a: function (str) {
39
+ var result = this.find(this.res.a, str);
40
+ result.token = 'A';
41
+ return result;
42
+ },
43
+ aa: function (str) {
44
+ var result = this.find(this.res.aa, str);
45
+ result.token = 'A';
29
46
  return result;
30
47
  }
31
48
  }
@@ -33,15 +50,6 @@
33
50
  return name;
34
51
  };
35
52
 
36
- if (typeof module === 'object' && typeof module.exports === 'object') {
37
- (module.paths || []).push('./');
38
- module.exports = exec;
39
- // This line will be removed in the next version.
40
- exec(require('date-and-time'));
41
- } else if (typeof define === 'function' && define.amd) {
42
- define(['date-and-time'], exec);
43
- } else {
44
- exec(global.date);
45
- }
53
+ return plugin;
46
54
 
47
- }(this));
55
+ }));
@@ -1,10 +1,18 @@
1
- (function (global) {
2
- 'use strict';
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin.microsecond = factory()));
5
+ })(this, (function () { 'use strict';
3
6
 
4
- var exec = function (date) {
7
+ /**
8
+ * @preserve date-and-time.js plugin
9
+ * @preserve microsecond
10
+ */
11
+
12
+ var plugin = function (date) {
5
13
  var name = 'microsecond';
6
14
 
7
- date.plugin('microsecond', {
15
+ date.plugin(name, {
8
16
  parser: {
9
17
  SSSSSS: function (str) {
10
18
  var result = this.exec(/^\d{1,6}/, str);
@@ -26,15 +34,6 @@
26
34
  return name;
27
35
  };
28
36
 
29
- if (typeof module === 'object' && typeof module.exports === 'object') {
30
- (module.paths || []).push('./');
31
- module.exports = exec;
32
- // This line will be removed in the next version.
33
- exec(require('date-and-time'));
34
- } else if (typeof define === 'function' && define.amd) {
35
- define(['date-and-time'], exec);
36
- } else {
37
- exec(global.date);
38
- }
37
+ return plugin;
39
38
 
40
- }(this));
39
+ }));
package/plugin/ordinal.js CHANGED
@@ -1,7 +1,15 @@
1
- (function (global) {
2
- 'use strict';
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin.ordinal = factory()));
5
+ })(this, (function () { 'use strict';
3
6
 
4
- var exec = function (date) {
7
+ /**
8
+ * @preserve date-and-time.js plugin
9
+ * @preserve ordinal
10
+ */
11
+
12
+ var plugin = function (date) {
5
13
  var name = 'ordinal';
6
14
 
7
15
  date.plugin(name, {
@@ -29,15 +37,6 @@
29
37
  return name;
30
38
  };
31
39
 
32
- if (typeof module === 'object' && typeof module.exports === 'object') {
33
- (module.paths || []).push('./');
34
- module.exports = exec;
35
- // This line will be removed in the next version.
36
- exec(require('date-and-time'));
37
- } else if (typeof define === 'function' && define.amd) {
38
- define(['date-and-time'], exec);
39
- } else {
40
- exec(global.date);
41
- }
40
+ return plugin;
42
41
 
43
- }(this));
42
+ }));
@@ -1,7 +1,15 @@
1
- (function (global) {
2
- 'use strict';
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin.timespan = factory()));
5
+ })(this, (function () { 'use strict';
3
6
 
4
- var exec = function (date) {
7
+ /**
8
+ * @preserve date-and-time.js plugin
9
+ * @preserve timespan
10
+ */
11
+
12
+ var plugin = function (date) {
5
13
  var timeSpan = function (date1, date2) {
6
14
  var milliseconds = function (dt, time) {
7
15
  dt.S = time;
@@ -70,15 +78,6 @@
70
78
  return name;
71
79
  };
72
80
 
73
- if (typeof module === 'object' && typeof module.exports === 'object') {
74
- (module.paths || []).push('./');
75
- module.exports = exec;
76
- // This line will be removed in the next version.
77
- exec(require('date-and-time'));
78
- } else if (typeof define === 'function' && define.amd) {
79
- define(['date-and-time'], exec);
80
- } else {
81
- exec(global.date);
82
- }
81
+ return plugin;
83
82
 
84
- }(this));
83
+ }));
@@ -0,0 +1,81 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin.timezone = factory()));
5
+ })(this, (function () { 'use strict';
6
+
7
+ /**
8
+ * @preserve date-and-time.js plugin
9
+ * @preserve timezone
10
+ */
11
+
12
+ var plugin = function (date, localized_date) {
13
+ var options = {
14
+ year: 'numeric', month: 'numeric', day: 'numeric',
15
+ hour: 'numeric', minute: 'numeric', second: 'numeric'
16
+ };
17
+ var pattern = date.compile('M/D/Y, h:mm:ss A');
18
+ var formatTZ = function (dateObj, arg, timeZone) {
19
+ options.timeZone = 'UTC';
20
+ var utcObj = date.parse(new Intl.DateTimeFormat('en-US', options).format(dateObj), pattern);
21
+
22
+ options.timeZone = timeZone;
23
+ var dateObj2 = date.parse(new Intl.DateTimeFormat('en-US', options).format(dateObj), pattern);
24
+
25
+ var dateObj3 = date.addMilliseconds(dateObj2, dateObj.getMilliseconds());
26
+
27
+ dateObj3.getTimezoneOffset = function () { return (utcObj.getTime() - dateObj2.getTime()) / 60000 | 0; };
28
+ return localized_date.format(dateObj3, arg);
29
+ };
30
+ var adjustments = [
31
+ -60, -30, -20,
32
+ 0,
33
+ 60, 30, 20
34
+ ];
35
+ var parseTZ = function (dateString, arg, timeZone) {
36
+ var pattern2 = typeof arg === 'string' ? date.compile(arg) : arg;
37
+ var dateObj = localized_date.parse(dateString, pattern2, true);
38
+
39
+ for (var i = 1, len = pattern2.length; i < len; i++) {
40
+ if (pattern2[i].indexOf('Z') === 0) {
41
+ return dateObj;
42
+ }
43
+ }
44
+
45
+ options.timeZone = timeZone;
46
+ var dateTimeFormat = new Intl.DateTimeFormat('en-US', options);
47
+ var dateObj2 = date.addMilliseconds(
48
+ date.parse(dateTimeFormat.format(dateObj), pattern, true),
49
+ dateObj.getMilliseconds()
50
+ );
51
+ var offset = dateObj.getTime() - dateObj2.getTime();
52
+ var dateString2 = date.format(localized_date.parse(dateString, pattern2), pattern);
53
+
54
+ var comparer = function (d) {
55
+ return dateString2 === dateTimeFormat.format(d);
56
+ };
57
+
58
+ // Trying to adjust for daylight saving time.
59
+ for (var j = 0, len2 = adjustments.length; j < len2; j++) {
60
+ var d = date.addMilliseconds(dateObj, offset + adjustments[j] * 60000);
61
+ if (comparer(d)) {
62
+ return d;
63
+ }
64
+ }
65
+ return NaN;
66
+ };
67
+
68
+ var name = 'timezone';
69
+
70
+ date.plugin(name, {
71
+ extender: {
72
+ formatTZ: formatTZ,
73
+ parseTZ: parseTZ
74
+ }
75
+ });
76
+ return name;
77
+ };
78
+
79
+ return plugin;
80
+
81
+ }));
@@ -1,7 +1,15 @@
1
- (function (global) {
2
- 'use strict';
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin["two-digit-year"] = factory()));
5
+ })(this, (function () { 'use strict';
3
6
 
4
- var exec = function (date) {
7
+ /**
8
+ * @preserve date-and-time.js plugin
9
+ * @preserve two-digit-year
10
+ */
11
+
12
+ var plugin = function (date) {
5
13
  var name = 'two-digit-year';
6
14
 
7
15
  date.plugin(name, {
@@ -10,26 +18,12 @@
10
18
  var result = this.exec(/^\d\d/, str);
11
19
  result.value += result.value < 70 ? 2000 : 1900;
12
20
  return result;
13
- },
14
- Y: function (str) {
15
- var result = this.exec(/^\d\d?/, str);
16
- result.value += result.value < 70 ? 2000 : 1900;
17
- return result;
18
21
  }
19
22
  }
20
23
  });
21
24
  return name;
22
25
  };
23
26
 
24
- if (typeof module === 'object' && typeof module.exports === 'object') {
25
- (module.paths || []).push('./');
26
- module.exports = exec;
27
- // This line will be removed in the next version.
28
- exec(require('date-and-time'));
29
- } else if (typeof define === 'function' && define.amd) {
30
- define(['date-and-time'], exec);
31
- } else {
32
- exec(global.date);
33
- }
27
+ return plugin;
34
28
 
35
- }(this));
29
+ }));