date-and-time 1.0.0 → 2.1.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.
Files changed (136) hide show
  1. package/EXTEND.md +28 -10
  2. package/LOCALE.md +1 -0
  3. package/PLUGINS.md +185 -63
  4. package/README.md +91 -76
  5. package/date-and-time.js +140 -102
  6. package/date-and-time.min.js +12 -12
  7. package/esm/date-and-time.es.js +138 -100
  8. package/esm/date-and-time.es.min.js +13 -12
  9. package/esm/date-and-time.mjs +138 -100
  10. package/esm/locale/ar.es.js +1 -1
  11. package/esm/locale/ar.mjs +1 -1
  12. package/esm/locale/az.es.js +1 -1
  13. package/esm/locale/az.mjs +1 -1
  14. package/esm/locale/bn.es.js +1 -1
  15. package/esm/locale/bn.mjs +1 -1
  16. package/esm/locale/cs.es.js +1 -1
  17. package/esm/locale/cs.mjs +1 -1
  18. package/esm/locale/de.es.js +1 -1
  19. package/esm/locale/de.mjs +1 -1
  20. package/esm/locale/dk.es.js +1 -1
  21. package/esm/locale/dk.mjs +1 -1
  22. package/esm/locale/el.es.js +7 -5
  23. package/esm/locale/el.mjs +7 -5
  24. package/esm/locale/en.es.js +3 -2
  25. package/esm/locale/en.mjs +3 -2
  26. package/esm/locale/es.es.js +1 -1
  27. package/esm/locale/es.mjs +1 -1
  28. package/esm/locale/fa.es.js +1 -1
  29. package/esm/locale/fa.mjs +1 -1
  30. package/esm/locale/fr.es.js +1 -1
  31. package/esm/locale/fr.mjs +1 -1
  32. package/esm/locale/hi.es.js +1 -1
  33. package/esm/locale/hi.mjs +1 -1
  34. package/esm/locale/hu.es.js +1 -1
  35. package/esm/locale/hu.mjs +1 -1
  36. package/esm/locale/id.es.js +1 -1
  37. package/esm/locale/id.mjs +1 -1
  38. package/esm/locale/it.es.js +1 -1
  39. package/esm/locale/it.mjs +1 -1
  40. package/esm/locale/ja.es.js +1 -1
  41. package/esm/locale/ja.mjs +1 -1
  42. package/esm/locale/jv.es.js +1 -1
  43. package/esm/locale/jv.mjs +1 -1
  44. package/esm/locale/ko.es.js +1 -1
  45. package/esm/locale/ko.mjs +1 -1
  46. package/esm/locale/my.es.js +1 -1
  47. package/esm/locale/my.mjs +1 -1
  48. package/esm/locale/nl.es.js +7 -5
  49. package/esm/locale/nl.mjs +7 -5
  50. package/esm/locale/pa-in.es.js +1 -1
  51. package/esm/locale/pa-in.mjs +1 -1
  52. package/esm/locale/pl.es.js +7 -5
  53. package/esm/locale/pl.mjs +7 -5
  54. package/esm/locale/pt.es.js +1 -1
  55. package/esm/locale/pt.mjs +1 -1
  56. package/esm/locale/ro.es.js +1 -1
  57. package/esm/locale/ro.mjs +1 -1
  58. package/esm/locale/ru.es.js +1 -1
  59. package/esm/locale/ru.mjs +1 -1
  60. package/esm/locale/rw.es.js +1 -1
  61. package/esm/locale/rw.mjs +1 -1
  62. package/esm/locale/sr.es.js +1 -1
  63. package/esm/locale/sr.mjs +1 -1
  64. package/esm/locale/sv.es.js +22 -0
  65. package/esm/locale/sv.mjs +22 -0
  66. package/esm/locale/th.es.js +1 -1
  67. package/esm/locale/th.mjs +1 -1
  68. package/esm/locale/tr.es.js +1 -1
  69. package/esm/locale/tr.mjs +1 -1
  70. package/esm/locale/uk.es.js +10 -8
  71. package/esm/locale/uk.mjs +10 -8
  72. package/esm/locale/uz.es.js +1 -1
  73. package/esm/locale/uz.mjs +1 -1
  74. package/esm/locale/vi.es.js +1 -1
  75. package/esm/locale/vi.mjs +1 -1
  76. package/esm/locale/zh-cn.es.js +1 -1
  77. package/esm/locale/zh-cn.mjs +1 -1
  78. package/esm/locale/zh-tw.es.js +1 -1
  79. package/esm/locale/zh-tw.mjs +1 -1
  80. package/esm/plugin/day-of-week.es.js +1 -1
  81. package/esm/plugin/day-of-week.mjs +1 -1
  82. package/esm/plugin/meridiem.es.js +20 -11
  83. package/esm/plugin/meridiem.mjs +20 -11
  84. package/esm/plugin/microsecond.es.js +1 -1
  85. package/esm/plugin/microsecond.mjs +1 -1
  86. package/esm/plugin/ordinal.es.js +1 -1
  87. package/esm/plugin/ordinal.mjs +1 -1
  88. package/esm/plugin/timespan.es.js +1 -1
  89. package/esm/plugin/timespan.mjs +1 -1
  90. package/esm/plugin/timezone.es.js +73 -0
  91. package/esm/plugin/timezone.mjs +73 -0
  92. package/esm/plugin/two-digit-year.es.js +1 -6
  93. package/esm/plugin/two-digit-year.mjs +1 -6
  94. package/locale/ar.js +2 -2
  95. package/locale/az.js +2 -2
  96. package/locale/bn.js +2 -2
  97. package/locale/cs.js +2 -2
  98. package/locale/de.js +2 -2
  99. package/locale/dk.js +2 -2
  100. package/locale/el.js +8 -6
  101. package/locale/en.js +4 -3
  102. package/locale/es.js +2 -2
  103. package/locale/fa.js +2 -2
  104. package/locale/fr.js +2 -2
  105. package/locale/hi.js +2 -2
  106. package/locale/hu.js +2 -2
  107. package/locale/id.js +2 -2
  108. package/locale/it.js +2 -2
  109. package/locale/ja.js +2 -2
  110. package/locale/jv.js +2 -2
  111. package/locale/ko.js +2 -2
  112. package/locale/my.js +2 -2
  113. package/locale/nl.js +8 -6
  114. package/locale/pa-in.js +3 -3
  115. package/locale/pl.js +8 -6
  116. package/locale/pt.js +2 -2
  117. package/locale/ro.js +2 -2
  118. package/locale/ru.js +2 -2
  119. package/locale/rw.js +2 -2
  120. package/locale/sr.js +2 -2
  121. package/locale/sv.js +30 -0
  122. package/locale/th.js +2 -2
  123. package/locale/tr.js +2 -2
  124. package/locale/uk.js +11 -9
  125. package/locale/uz.js +2 -2
  126. package/locale/vi.js +2 -2
  127. package/locale/zh-cn.js +3 -3
  128. package/locale/zh-tw.js +3 -3
  129. package/package.json +4 -4
  130. package/plugin/day-of-week.js +3 -3
  131. package/plugin/meridiem.js +21 -12
  132. package/plugin/microsecond.js +2 -2
  133. package/plugin/ordinal.js +2 -2
  134. package/plugin/timespan.js +2 -2
  135. package/plugin/timezone.js +81 -0
  136. package/plugin/two-digit-year.js +3 -8
package/locale/nl.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.nl = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -16,20 +16,22 @@
16
16
  date.locale(code, {
17
17
  res: {
18
18
  MMMM: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
19
- MMM_withdots: ['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
20
- MMM_withoutdots: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
19
+ MMM: [
20
+ ['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
21
+ ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec']
22
+ ],
21
23
  dddd: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
22
24
  ddd: ['zo.', 'ma.', 'di.', 'wo.', 'do.', 'vr.', 'za.'],
23
25
  dd: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za']
24
26
  },
25
27
  formatter: {
26
28
  MMM: function (d, formatString) {
27
- return this.res['MMM_' + (/-MMM-/.test(formatString) ? 'withoutdots' : 'withdots')][d.getMonth()];
29
+ return this.res.MMM[/-MMM-/.test(formatString) | 0][d.getMonth()];
28
30
  }
29
31
  },
30
32
  parser: {
31
33
  MMM: function (str, formatString) {
32
- var result = this.find(this.res['MMM_' + (/-MMM-/.test(formatString) ? 'withoutdots' : 'withdots')], str);
34
+ var result = this.find(this.res.MMM[/-MMM-/.test(formatString) | 0], str);
33
35
  result.value++;
34
36
  return result;
35
37
  }
@@ -40,4 +42,4 @@
40
42
 
41
43
  return nl;
42
44
 
43
- })));
45
+ }));
package/locale/pa-in.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
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['pa-in'] = factory()));
5
- }(this, (function () { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale["pa-in"] = factory()));
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -67,4 +67,4 @@
67
67
 
68
68
  return pa_in;
69
69
 
70
- })));
70
+ }));
package/locale/pl.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.pl = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -15,8 +15,10 @@
15
15
 
16
16
  date.locale(code, {
17
17
  res: {
18
- MMMM_nominative: ['styczeń', 'luty', 'marzec', 'kwiecień', 'maj', 'czerwiec', 'lipiec', 'sierpień', 'wrzesień', 'październik', 'listopad', 'grudzień'],
19
- MMMM_subjective: ['stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia'],
18
+ MMMM: [
19
+ ['styczeń', 'luty', 'marzec', 'kwiecień', 'maj', 'czerwiec', 'lipiec', 'sierpień', 'wrzesień', 'październik', 'listopad', 'grudzień'],
20
+ ['stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia']
21
+ ],
20
22
  MMM: ['sty', 'lut', 'mar', 'kwi', 'maj', 'cze', 'lip', 'sie', 'wrz', 'paź', 'lis', 'gru'],
21
23
  dddd: ['niedziela', 'poniedziałek', 'wtorek', 'środa', 'czwartek', 'piątek', 'sobota'],
22
24
  ddd: ['nie', 'pon', 'wt', 'śr', 'czw', 'pt', 'sb'],
@@ -24,12 +26,12 @@
24
26
  },
25
27
  formatter: {
26
28
  MMMM: function (d, formatString) {
27
- return this.res['MMMM_' + (/D MMMM/.test(formatString) ? 'subjective' : 'nominative')][d.getMonth()];
29
+ return this.res.MMMM[/D MMMM/.test(formatString) | 0][d.getMonth()];
28
30
  }
29
31
  },
30
32
  parser: {
31
33
  MMMM: function (str, formatString) {
32
- var result = this.find(this.res['MMMM_' + (/D MMMM/.test(formatString) ? 'subjective' : 'nominative')], str);
34
+ var result = this.find(this.res.MMMM[/D MMMM/.test(formatString) | 0], str);
33
35
  result.value++;
34
36
  return result;
35
37
  }
@@ -40,4 +42,4 @@
40
42
 
41
43
  return pl;
42
44
 
43
- })));
45
+ }));
package/locale/pt.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.pt = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -49,4 +49,4 @@
49
49
 
50
50
  return pt;
51
51
 
52
- })));
52
+ }));
package/locale/ro.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.ro = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -27,4 +27,4 @@
27
27
 
28
28
  return ro;
29
29
 
30
- })));
30
+ }));
package/locale/ru.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.ru = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -49,4 +49,4 @@
49
49
 
50
50
  return ru;
51
51
 
52
- })));
52
+ }));
package/locale/rw.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.rw = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -27,4 +27,4 @@
27
27
 
28
28
  return rw;
29
29
 
30
- })));
30
+ }));
package/locale/sr.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.sr = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -27,4 +27,4 @@
27
27
 
28
28
  return sr;
29
29
 
30
- })));
30
+ }));
package/locale/sv.js ADDED
@@ -0,0 +1,30 @@
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.sv = factory()));
5
+ })(this, (function () { 'use strict';
6
+
7
+ /**
8
+ * @preserve date-and-time.js locale configuration
9
+ * @preserve Swedish (SV)
10
+ * @preserve It is using moment.js locale configuration as a reference.
11
+ */
12
+
13
+ var sv = function (date) {
14
+ var code = 'sv';
15
+
16
+ date.locale(code, {
17
+ res: {
18
+ MMMM: ['januari', 'februari', 'mars', 'april', 'maj', 'juni', 'juli', 'augusti', 'september', 'oktober', 'november', 'december'],
19
+ MMM: ['jan', 'feb', 'mar', 'apr', 'maj', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
20
+ dddd: ['söndag', 'måndag', 'tisdag', 'onsdag', 'torsdag', 'fredag', 'lördag'],
21
+ ddd: ['sön', 'mån', 'tis', 'ons', 'tor', 'fre', 'lör'],
22
+ dd: ['sö', 'må', 'ti', 'on', 'to', 'fr', 'lö']
23
+ }
24
+ });
25
+ return code;
26
+ };
27
+
28
+ return sv;
29
+
30
+ }));
package/locale/th.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.th = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -28,4 +28,4 @@
28
28
 
29
29
  return th;
30
30
 
31
- })));
31
+ }));
package/locale/tr.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.tr = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -27,4 +27,4 @@
27
27
 
28
28
  return tr;
29
29
 
30
- })));
30
+ }));
package/locale/uk.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.uk = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -17,9 +17,11 @@
17
17
  res: {
18
18
  MMMM: ['січня', 'лютого', 'березня', 'квітня', 'травня', 'червня', 'липня', 'серпня', 'вересня', 'жовтня', 'листопада', 'грудня'],
19
19
  MMM: ['січ', 'лют', 'бер', 'квіт', 'трав', 'черв', 'лип', 'серп', 'вер', 'жовт', 'лист', 'груд'],
20
- dddd_nominative: ['неділя', 'понеділок', 'вівторок', 'середа', 'четвер', 'п’ятниця', 'субота'],
21
- dddd_accusative: ['неділю', 'понеділок', 'вівторок', 'середу', 'четвер', 'п’ятницю', 'суботу'],
22
- dddd_genitive: ['неділі', 'понеділка', 'вівторка', 'середи', 'четверга', 'п’ятниці', 'суботи'],
20
+ dddd: [
21
+ ['неділя', 'понеділок', 'вівторок', 'середа', 'четвер', 'п’ятниця', 'субота'],
22
+ ['неділю', 'понеділок', 'вівторок', 'середу', 'четвер', 'п’ятницю', 'суботу'],
23
+ ['неділі', 'понеділка', 'вівторка', 'середи', 'четверга', 'п’ятниці', 'суботи']
24
+ ],
23
25
  ddd: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],
24
26
  dd: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],
25
27
  A: ['ночі', 'ранку', 'дня', 'вечора']
@@ -37,13 +39,13 @@
37
39
  return this.res.A[3]; // вечора
38
40
  },
39
41
  dddd: function (d, formatString) {
40
- var type = 'nominative';
42
+ var type = 0;
41
43
  if (/(\[[ВвУу]\]) ?dddd/.test(formatString)) {
42
- type = 'accusative';
44
+ type = 1;
43
45
  } else if (/\[?(?:минулої|наступної)? ?\] ?dddd/.test(formatString)) {
44
- type = 'genitive';
46
+ type = 2;
45
47
  }
46
- return this.res['dddd_' + type][d.getDay()];
48
+ return this.res.dddd[type][d.getDay()];
47
49
  }
48
50
  },
49
51
  parser: {
@@ -60,4 +62,4 @@
60
62
 
61
63
  return uk;
62
64
 
63
- })));
65
+ }));
package/locale/uz.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.uz = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -27,4 +27,4 @@
27
27
 
28
28
  return uz;
29
29
 
30
- })));
30
+ }));
package/locale/vi.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.vi = factory()));
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -28,4 +28,4 @@
28
28
 
29
29
  return vi;
30
30
 
31
- })));
31
+ }));
package/locale/zh-cn.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
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';
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';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -53,4 +53,4 @@
53
53
 
54
54
  return zh_cn;
55
55
 
56
- })));
56
+ }));
package/locale/zh-tw.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
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';
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';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js locale configuration
@@ -51,4 +51,4 @@
51
51
 
52
52
  return zh_tw;
53
53
 
54
- })));
54
+ }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "date-and-time",
3
- "version": "1.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "A Minimalist DateTime utility for Node.js and the browser",
5
5
  "main": "date-and-time.js",
6
6
  "module": "esm/date-and-time.es.js",
@@ -44,10 +44,10 @@
44
44
  },
45
45
  "homepage": "https://github.com/knowledgecode/date-and-time",
46
46
  "devDependencies": {
47
- "@ampproject/rollup-plugin-closure-compiler": "^0.26.0",
47
+ "@ampproject/rollup-plugin-closure-compiler": "^0.27.0",
48
48
  "expect.js": "^0.3.1",
49
- "mocha": "^8.3.2",
49
+ "mocha": "^9.1.3",
50
50
  "mocha-headless-chrome": "^3.1.0",
51
- "rollup": "^2.44.0"
51
+ "rollup": "^2.63.0"
52
52
  }
53
53
  }
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
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';
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';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js plugin
@@ -24,4 +24,4 @@
24
24
 
25
25
  return plugin;
26
26
 
27
- })));
27
+ }));
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
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';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js plugin
@@ -14,26 +14,35 @@
14
14
 
15
15
  date.plugin(name, {
16
16
  res: {
17
- 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.']
18
20
  },
19
21
  formatter: {
20
22
  AA: function (d) {
21
- // A.M. / P.M.
22
- return this.res.A[d.getHours() > 11 | 0 + 2];
23
+ return this.res.AA[d.getHours() > 11 | 0];
23
24
  },
24
25
  a: function (d) {
25
- // am / pm
26
- return this.res.A[d.getHours() > 11 | 0 + 4];
26
+ return this.res.a[d.getHours() > 11 | 0];
27
27
  },
28
28
  aa: function (d) {
29
- // a.m. / p.m.
30
- return this.res.A[d.getHours() > 11 | 0 + 6];
29
+ return this.res.aa[d.getHours() > 11 | 0];
31
30
  }
32
31
  },
33
32
  parser: {
34
- A: function (str) {
35
- var result = this.find(this.res.A, str);
36
- 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';
37
46
  return result;
38
47
  }
39
48
  }
@@ -43,4 +52,4 @@
43
52
 
44
53
  return plugin;
45
54
 
46
- })));
55
+ }));
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
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';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js plugin
@@ -36,4 +36,4 @@
36
36
 
37
37
  return plugin;
38
38
 
39
- })));
39
+ }));
package/plugin/ordinal.js CHANGED
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
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';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js plugin
@@ -39,4 +39,4 @@
39
39
 
40
40
  return plugin;
41
41
 
42
- })));
42
+ }));
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
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';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js plugin
@@ -80,4 +80,4 @@
80
80
 
81
81
  return plugin;
82
82
 
83
- })));
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,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
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';
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';
6
6
 
7
7
  /**
8
8
  * @preserve date-and-time.js plugin
@@ -18,11 +18,6 @@
18
18
  var result = this.exec(/^\d\d/, str);
19
19
  result.value += result.value < 70 ? 2000 : 1900;
20
20
  return result;
21
- },
22
- Y: function (str) {
23
- var result = this.exec(/^\d\d?/, str);
24
- result.value += result.value < 70 ? 2000 : 1900;
25
- return result;
26
21
  }
27
22
  }
28
23
  });
@@ -31,4 +26,4 @@
31
26
 
32
27
  return plugin;
33
28
 
34
- })));
29
+ }));