@learncard/react 2.3.68 → 2.4.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 (205) hide show
  1. package/dist/cjs/{AchievementCard-0123be96.js → AchievementCard-69413826.js} +5 -5
  2. package/dist/cjs/{AchievementCard-0123be96.js.map → AchievementCard-69413826.js.map} +1 -1
  3. package/dist/cjs/AwardRibbon-14ba45fb.js +33 -0
  4. package/dist/cjs/AwardRibbon-14ba45fb.js.map +1 -0
  5. package/dist/cjs/{CircleCheckButton-97c4f608.js → CircleCheckButton-78959cce.js} +2 -2
  6. package/dist/cjs/{CircleCheckButton-97c4f608.js.map → CircleCheckButton-78959cce.js.map} +1 -1
  7. package/dist/cjs/CircleIcon-03cc33dc.js +1083 -0
  8. package/dist/cjs/CircleIcon-03cc33dc.js.map +1 -0
  9. package/dist/cjs/{CourseVerticalCard-ef3e7ea6.js → CourseVerticalCard-5ac6adea.js} +4 -4
  10. package/dist/cjs/{CourseVerticalCard-ef3e7ea6.js.map → CourseVerticalCard-5ac6adea.js.map} +1 -1
  11. package/dist/cjs/{GenericCard-39248302.js → GenericCard-346b55ab.js} +4 -4
  12. package/dist/cjs/{GenericCard-39248302.js.map → GenericCard-346b55ab.js.map} +1 -1
  13. package/dist/cjs/{JobListCard-f9033e07.js → JobListCard-672fadc3.js} +3 -3
  14. package/dist/cjs/{JobListCard-f9033e07.js.map → JobListCard-672fadc3.js.map} +1 -1
  15. package/dist/cjs/{LearnPill-23ff7225.js → LearnPill-75e3af2f.js} +3 -3
  16. package/dist/cjs/{LearnPill-23ff7225.js.map → LearnPill-75e3af2f.js.map} +1 -1
  17. package/dist/cjs/{RoundedPill-15c0aca9.js → RoundedPill-75454f72.js} +2 -2
  18. package/dist/cjs/{RoundedPill-15c0aca9.js.map → RoundedPill-75454f72.js.map} +1 -1
  19. package/dist/cjs/{SkillTabCard-2f6e8b78.js → SkillTabCard-eb50fde5.js} +4 -4
  20. package/dist/cjs/{SkillTabCard-2f6e8b78.js.map → SkillTabCard-eb50fde5.js.map} +1 -1
  21. package/dist/cjs/{VCCard-47af6178.js → VCCard-32c759a8.js} +33 -7
  22. package/dist/cjs/VCCard-32c759a8.js.map +1 -0
  23. package/dist/cjs/{VCDisplayBackFace-b1e35a5e.js → VCDisplayBackFace-128b5cb2.js} +5 -25
  24. package/dist/cjs/VCDisplayBackFace-128b5cb2.js.map +1 -0
  25. package/dist/cjs/VCDisplayCard-77133b71.js +191 -0
  26. package/dist/cjs/VCDisplayCard-77133b71.js.map +1 -0
  27. package/dist/cjs/VCDisplayCard2-a0a66aa6.js +920 -0
  28. package/dist/cjs/VCDisplayCard2-a0a66aa6.js.map +1 -0
  29. package/dist/cjs/{VCVerificationCheck-0e495524.js → VCVerificationCheck-08011d1a.js} +32 -22
  30. package/dist/cjs/VCVerificationCheck-08011d1a.js.map +1 -0
  31. package/dist/cjs/VCVerificationPill-66e2a90f.js +75 -0
  32. package/dist/cjs/VCVerificationPill-66e2a90f.js.map +1 -0
  33. package/dist/cjs/award.svg +3 -0
  34. package/dist/cjs/{constants-678d0aa9.js → constants-82581ffe.js} +10 -12
  35. package/dist/cjs/constants-82581ffe.js.map +1 -0
  36. package/dist/cjs/credential.helpers-7f7b9b02.js +2188 -0
  37. package/dist/cjs/credential.helpers-7f7b9b02.js.map +1 -0
  38. package/dist/cjs/{icons-cf98ef88.js → icons-6433b474.js} +6 -3
  39. package/dist/cjs/icons-6433b474.js.map +1 -0
  40. package/dist/cjs/{index-63ee021e.js → index-6b34c190.js} +3 -1
  41. package/dist/cjs/index-6b34c190.js.map +1 -0
  42. package/dist/{esm/VCDisplayCard-1bd179d2.js → cjs/index-a961acab.js} +12 -2328
  43. package/dist/cjs/index-a961acab.js.map +1 -0
  44. package/dist/cjs/{index-6cab6d37.js → index-f30fca07.js} +12 -6
  45. package/dist/cjs/index-f30fca07.js.map +1 -0
  46. package/dist/cjs/index.js +28 -18
  47. package/dist/cjs/index.js.map +1 -1
  48. package/dist/cjs/index10.js +28 -18
  49. package/dist/cjs/index10.js.map +1 -1
  50. package/dist/cjs/index12.js +4 -3
  51. package/dist/cjs/index12.js.map +1 -1
  52. package/dist/cjs/index15.js +4 -3
  53. package/dist/cjs/index15.js.map +1 -1
  54. package/dist/cjs/index2.js +8 -6
  55. package/dist/cjs/index2.js.map +1 -1
  56. package/dist/cjs/index20.js +4 -3
  57. package/dist/cjs/index20.js.map +1 -1
  58. package/dist/cjs/index21.js +7 -5
  59. package/dist/cjs/index21.js.map +1 -1
  60. package/dist/cjs/index25.js +6 -5
  61. package/dist/cjs/index25.js.map +1 -1
  62. package/dist/cjs/index28.js +3 -1
  63. package/dist/cjs/index28.js.map +1 -1
  64. package/dist/cjs/index29.js +10 -5
  65. package/dist/cjs/index29.js.map +1 -1
  66. package/dist/cjs/index30.js +6 -3
  67. package/dist/cjs/index30.js.map +1 -1
  68. package/dist/cjs/index31.js +7 -4
  69. package/dist/cjs/index31.js.map +1 -1
  70. package/dist/cjs/index32.js +12 -1
  71. package/dist/cjs/index32.js.map +1 -1
  72. package/dist/cjs/index33.js +4 -7
  73. package/dist/cjs/index33.js.map +1 -1
  74. package/dist/cjs/index34.js +4 -5
  75. package/dist/cjs/index34.js.map +1 -1
  76. package/dist/cjs/index35.js +6 -5
  77. package/dist/cjs/index35.js.map +1 -1
  78. package/dist/cjs/index36.js +15 -0
  79. package/dist/cjs/index36.js.map +1 -0
  80. package/dist/cjs/index4.js +5 -4
  81. package/dist/cjs/index4.js.map +1 -1
  82. package/dist/cjs/index5.js +4 -3
  83. package/dist/cjs/index5.js.map +1 -1
  84. package/dist/cjs/index7.js +6 -5
  85. package/dist/cjs/index7.js.map +1 -1
  86. package/dist/cjs/index9.js +8 -6
  87. package/dist/cjs/index9.js.map +1 -1
  88. package/dist/cjs/social-badge.png +0 -0
  89. package/dist/{esm/VCVerificationPill-7a09f9fa.js → cjs/types.esm-034454a2.js} +3 -63
  90. package/dist/cjs/types.esm-034454a2.js.map +1 -0
  91. package/dist/esm/{AchievementCard-92b5a3ea.js → AchievementCard-3f315f82.js} +5 -5
  92. package/dist/esm/{AchievementCard-92b5a3ea.js.map → AchievementCard-3f315f82.js.map} +1 -1
  93. package/dist/esm/AwardRibbon-3e682281.js +27 -0
  94. package/dist/esm/AwardRibbon-3e682281.js.map +1 -0
  95. package/dist/esm/{CircleCheckButton-a55dfd2a.js → CircleCheckButton-3bad7847.js} +2 -2
  96. package/dist/esm/{CircleCheckButton-a55dfd2a.js.map → CircleCheckButton-3bad7847.js.map} +1 -1
  97. package/dist/esm/CircleIcon-3ab835f3.js +1076 -0
  98. package/dist/esm/CircleIcon-3ab835f3.js.map +1 -0
  99. package/dist/esm/{CourseVerticalCard-c91c7a7a.js → CourseVerticalCard-cfb09a77.js} +4 -4
  100. package/dist/esm/{CourseVerticalCard-c91c7a7a.js.map → CourseVerticalCard-cfb09a77.js.map} +1 -1
  101. package/dist/esm/{GenericCard-2aaadb4b.js → GenericCard-446f46e0.js} +4 -4
  102. package/dist/esm/{GenericCard-2aaadb4b.js.map → GenericCard-446f46e0.js.map} +1 -1
  103. package/dist/esm/{JobListCard-3a2bd655.js → JobListCard-9ac7ac1b.js} +3 -3
  104. package/dist/esm/{JobListCard-3a2bd655.js.map → JobListCard-9ac7ac1b.js.map} +1 -1
  105. package/dist/esm/{LearnPill-a1001ae7.js → LearnPill-a62adef1.js} +3 -3
  106. package/dist/esm/{LearnPill-a1001ae7.js.map → LearnPill-a62adef1.js.map} +1 -1
  107. package/dist/esm/{RoundedPill-2f4dc646.js → RoundedPill-c03442e5.js} +2 -2
  108. package/dist/esm/{RoundedPill-2f4dc646.js.map → RoundedPill-c03442e5.js.map} +1 -1
  109. package/dist/esm/{SkillTabCard-82b97c62.js → SkillTabCard-2677de0d.js} +4 -4
  110. package/dist/esm/{SkillTabCard-82b97c62.js.map → SkillTabCard-2677de0d.js.map} +1 -1
  111. package/dist/esm/{VCCard-f53514a4.js → VCCard-c4096573.js} +33 -7
  112. package/dist/esm/VCCard-c4096573.js.map +1 -0
  113. package/dist/esm/{VCDisplayBackFace-919ed9e8.js → VCDisplayBackFace-853b8fdf.js} +5 -23
  114. package/dist/esm/VCDisplayBackFace-853b8fdf.js.map +1 -0
  115. package/dist/esm/VCDisplayCard-be496708.js +183 -0
  116. package/dist/esm/VCDisplayCard-be496708.js.map +1 -0
  117. package/dist/esm/VCDisplayCard2-c8e96ce8.js +913 -0
  118. package/dist/esm/VCDisplayCard2-c8e96ce8.js.map +1 -0
  119. package/dist/esm/{VCVerificationCheck-b2de0477.js → VCVerificationCheck-a6909b44.js} +32 -23
  120. package/dist/esm/VCVerificationCheck-a6909b44.js.map +1 -0
  121. package/dist/esm/VCVerificationPill-fc7b53d0.js +65 -0
  122. package/dist/esm/VCVerificationPill-fc7b53d0.js.map +1 -0
  123. package/dist/esm/award.svg +3 -0
  124. package/dist/esm/{constants-e0d87a29.js → constants-c0a08298.js} +10 -12
  125. package/dist/esm/constants-c0a08298.js.map +1 -0
  126. package/dist/esm/credential.helpers-78d3c24a.js +2182 -0
  127. package/dist/esm/credential.helpers-78d3c24a.js.map +1 -0
  128. package/dist/esm/{icons-10f38bbd.js → icons-2c3532f9.js} +5 -3
  129. package/dist/esm/icons-2c3532f9.js.map +1 -0
  130. package/dist/esm/{index-15b828c0.js → index-52cf2d17.js} +3 -1
  131. package/dist/esm/index-52cf2d17.js.map +1 -0
  132. package/dist/esm/{index-2ef79548.js → index-ac32d7be.js} +11 -6
  133. package/dist/esm/index-ac32d7be.js.map +1 -0
  134. package/dist/{cjs/VCDisplayCard-2981600a.js → esm/index-e1f279c6.js} +4 -2337
  135. package/dist/esm/index-e1f279c6.js.map +1 -0
  136. package/dist/esm/index.js +25 -18
  137. package/dist/esm/index.js.map +1 -1
  138. package/dist/esm/index10.js +25 -18
  139. package/dist/esm/index10.js.map +1 -1
  140. package/dist/esm/index12.js +4 -3
  141. package/dist/esm/index12.js.map +1 -1
  142. package/dist/esm/index15.js +4 -3
  143. package/dist/esm/index15.js.map +1 -1
  144. package/dist/esm/index2.js +8 -6
  145. package/dist/esm/index2.js.map +1 -1
  146. package/dist/esm/index20.js +4 -3
  147. package/dist/esm/index20.js.map +1 -1
  148. package/dist/esm/index21.js +7 -5
  149. package/dist/esm/index21.js.map +1 -1
  150. package/dist/esm/index25.js +6 -5
  151. package/dist/esm/index25.js.map +1 -1
  152. package/dist/esm/index28.js +2 -1
  153. package/dist/esm/index28.js.map +1 -1
  154. package/dist/esm/index29.js +10 -5
  155. package/dist/esm/index29.js.map +1 -1
  156. package/dist/esm/index30.js +6 -3
  157. package/dist/esm/index30.js.map +1 -1
  158. package/dist/esm/index31.js +7 -4
  159. package/dist/esm/index31.js.map +1 -1
  160. package/dist/esm/index32.js +7 -1
  161. package/dist/esm/index32.js.map +1 -1
  162. package/dist/esm/index33.js +4 -2
  163. package/dist/esm/index33.js.map +1 -1
  164. package/dist/esm/index34.js +3 -3
  165. package/dist/esm/index35.js +3 -4
  166. package/dist/esm/index35.js.map +1 -1
  167. package/dist/esm/index36.js +7 -0
  168. package/dist/esm/index36.js.map +1 -0
  169. package/dist/esm/index4.js +5 -4
  170. package/dist/esm/index4.js.map +1 -1
  171. package/dist/esm/index5.js +4 -3
  172. package/dist/esm/index5.js.map +1 -1
  173. package/dist/esm/index7.js +6 -5
  174. package/dist/esm/index7.js.map +1 -1
  175. package/dist/esm/index9.js +8 -6
  176. package/dist/esm/index9.js.map +1 -1
  177. package/dist/esm/social-badge.png +0 -0
  178. package/dist/{cjs/VCVerificationPill-9e8e4264.js → esm/types.esm-9db3d858.js} +2 -74
  179. package/dist/esm/types.esm-9db3d858.js.map +1 -0
  180. package/dist/index.d.ts +67 -5
  181. package/dist/main.css +1 -1
  182. package/dist/main.js +1 -1
  183. package/package.json +7 -4
  184. package/dist/cjs/CircleIcon-41b3fa88.js +0 -67
  185. package/dist/cjs/CircleIcon-41b3fa88.js.map +0 -1
  186. package/dist/cjs/VCCard-47af6178.js.map +0 -1
  187. package/dist/cjs/VCDisplayBackFace-b1e35a5e.js.map +0 -1
  188. package/dist/cjs/VCDisplayCard-2981600a.js.map +0 -1
  189. package/dist/cjs/VCVerificationCheck-0e495524.js.map +0 -1
  190. package/dist/cjs/VCVerificationPill-9e8e4264.js.map +0 -1
  191. package/dist/cjs/constants-678d0aa9.js.map +0 -1
  192. package/dist/cjs/icons-cf98ef88.js.map +0 -1
  193. package/dist/cjs/index-63ee021e.js.map +0 -1
  194. package/dist/cjs/index-6cab6d37.js.map +0 -1
  195. package/dist/esm/CircleIcon-b0dca4b6.js +0 -60
  196. package/dist/esm/CircleIcon-b0dca4b6.js.map +0 -1
  197. package/dist/esm/VCCard-f53514a4.js.map +0 -1
  198. package/dist/esm/VCDisplayBackFace-919ed9e8.js.map +0 -1
  199. package/dist/esm/VCDisplayCard-1bd179d2.js.map +0 -1
  200. package/dist/esm/VCVerificationCheck-b2de0477.js.map +0 -1
  201. package/dist/esm/VCVerificationPill-7a09f9fa.js.map +0 -1
  202. package/dist/esm/constants-e0d87a29.js.map +0 -1
  203. package/dist/esm/icons-10f38bbd.js.map +0 -1
  204. package/dist/esm/index-15b828c0.js.map +0 -1
  205. package/dist/esm/index-2ef79548.js.map +0 -1
@@ -1,18 +1,3 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var FlippyCard = require('./FlippyCard-2cbe2dbe.js');
5
- var FatArrow = require('./icon.green.fat-arrow.png');
6
- var DefaultFace = require('./default-face.jpeg');
7
- var VCVerificationCheck = require('./VCVerificationCheck-0e495524.js');
8
- var VCDisplayBackFace = require('./VCDisplayBackFace-b1e35a5e.js');
9
-
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
-
12
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
13
- var FatArrow__default = /*#__PURE__*/_interopDefaultLegacy(FatArrow);
14
- var DefaultFace__default = /*#__PURE__*/_interopDefaultLegacy(DefaultFace);
15
-
16
1
  function toInteger(dirtyNumber) {
17
2
  if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
18
3
  return NaN;
@@ -33,7 +18,7 @@ function requiredArgs(required, args) {
33
18
  }
34
19
  }
35
20
 
36
- function _typeof$x(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$x = function _typeof(obj) { return typeof obj; }; } else { _typeof$x = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$x(obj); }
21
+ function _typeof$w(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$w = function _typeof(obj) { return typeof obj; }; } else { _typeof$w = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$w(obj); }
37
22
  /**
38
23
  * @name toDate
39
24
  * @category Common Helpers
@@ -69,7 +54,7 @@ function toDate(argument) {
69
54
  requiredArgs(1, arguments);
70
55
  var argStr = Object.prototype.toString.call(argument); // Clone the date
71
56
 
72
- if (argument instanceof Date || _typeof$x(argument) === 'object' && argStr === '[object Date]') {
57
+ if (argument instanceof Date || _typeof$w(argument) === 'object' && argStr === '[object Date]') {
73
58
  // Prevent the date to lose the milliseconds when passed to new Date() in IE10
74
59
  return new Date(argument.getTime());
75
60
  } else if (typeof argument === 'number' || argStr === '[object Number]') {
@@ -86,54 +71,11 @@ function toDate(argument) {
86
71
  }
87
72
  }
88
73
 
89
- /**
90
- * @name addMilliseconds
91
- * @category Millisecond Helpers
92
- * @summary Add the specified number of milliseconds to the given date.
93
- *
94
- * @description
95
- * Add the specified number of milliseconds to the given date.
96
- *
97
- * @param {Date|Number} date - the date to be changed
98
- * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
99
- * @returns {Date} the new date with the milliseconds added
100
- * @throws {TypeError} 2 arguments required
101
- *
102
- * @example
103
- * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
104
- * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
105
- * //=> Thu Jul 10 2014 12:45:30.750
106
- */
107
-
108
- function addMilliseconds(dirtyDate, dirtyAmount) {
109
- requiredArgs(2, arguments);
110
- var timestamp = toDate(dirtyDate).getTime();
111
- var amount = toInteger(dirtyAmount);
112
- return new Date(timestamp + amount);
113
- }
114
-
115
74
  var defaultOptions = {};
116
75
  function getDefaultOptions() {
117
76
  return defaultOptions;
118
77
  }
119
78
 
120
- /**
121
- * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
122
- * They usually appear for dates that denote time before the timezones were introduced
123
- * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
124
- * and GMT+01:00:00 after that date)
125
- *
126
- * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
127
- * which would lead to incorrect calculations.
128
- *
129
- * This function returns the timezone offset in milliseconds that takes seconds in account.
130
- */
131
- function getTimezoneOffsetInMilliseconds(date) {
132
- var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
133
- utcDate.setUTCFullYear(date.getFullYear());
134
- return date.getTime() - utcDate.getTime();
135
- }
136
-
137
79
  /**
138
80
  * Days in 1 week.
139
81
  *
@@ -173,125 +115,6 @@ var millisecondsInHour = 3600000;
173
115
 
174
116
  var millisecondsInSecond = 1000;
175
117
 
176
- function _typeof$w(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$w = function _typeof(obj) { return typeof obj; }; } else { _typeof$w = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$w(obj); }
177
- /**
178
- * @name isDate
179
- * @category Common Helpers
180
- * @summary Is the given value a date?
181
- *
182
- * @description
183
- * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
184
- *
185
- * @param {*} value - the value to check
186
- * @returns {boolean} true if the given value is a date
187
- * @throws {TypeError} 1 arguments required
188
- *
189
- * @example
190
- * // For a valid date:
191
- * const result = isDate(new Date())
192
- * //=> true
193
- *
194
- * @example
195
- * // For an invalid date:
196
- * const result = isDate(new Date(NaN))
197
- * //=> true
198
- *
199
- * @example
200
- * // For some value:
201
- * const result = isDate('2014-02-31')
202
- * //=> false
203
- *
204
- * @example
205
- * // For an object:
206
- * const result = isDate({})
207
- * //=> false
208
- */
209
-
210
- function isDate(value) {
211
- requiredArgs(1, arguments);
212
- return value instanceof Date || _typeof$w(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
213
- }
214
-
215
- /**
216
- * @name isValid
217
- * @category Common Helpers
218
- * @summary Is the given date valid?
219
- *
220
- * @description
221
- * Returns false if argument is Invalid Date and true otherwise.
222
- * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
223
- * Invalid Date is a Date, whose time value is NaN.
224
- *
225
- * Time value of Date: http://es5.github.io/#x15.9.1.1
226
- *
227
- * @param {*} date - the date to check
228
- * @returns {Boolean} the date is valid
229
- * @throws {TypeError} 1 argument required
230
- *
231
- * @example
232
- * // For the valid date:
233
- * const result = isValid(new Date(2014, 1, 31))
234
- * //=> true
235
- *
236
- * @example
237
- * // For the value, convertable into a date:
238
- * const result = isValid(1393804800000)
239
- * //=> true
240
- *
241
- * @example
242
- * // For the invalid date:
243
- * const result = isValid(new Date(''))
244
- * //=> false
245
- */
246
-
247
- function isValid(dirtyDate) {
248
- requiredArgs(1, arguments);
249
-
250
- if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
251
- return false;
252
- }
253
-
254
- var date = toDate(dirtyDate);
255
- return !isNaN(Number(date));
256
- }
257
-
258
- /**
259
- * @name subMilliseconds
260
- * @category Millisecond Helpers
261
- * @summary Subtract the specified number of milliseconds from the given date.
262
- *
263
- * @description
264
- * Subtract the specified number of milliseconds from the given date.
265
- *
266
- * @param {Date|Number} date - the date to be changed
267
- * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
268
- * @returns {Date} the new date with the milliseconds subtracted
269
- * @throws {TypeError} 2 arguments required
270
- *
271
- * @example
272
- * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
273
- * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
274
- * //=> Thu Jul 10 2014 12:45:29.250
275
- */
276
-
277
- function subMilliseconds(dirtyDate, dirtyAmount) {
278
- requiredArgs(2, arguments);
279
- var amount = toInteger(dirtyAmount);
280
- return addMilliseconds(dirtyDate, -amount);
281
- }
282
-
283
- var MILLISECONDS_IN_DAY = 86400000;
284
- function getUTCDayOfYear(dirtyDate) {
285
- requiredArgs(1, arguments);
286
- var date = toDate(dirtyDate);
287
- var timestamp = date.getTime();
288
- date.setUTCMonth(0, 1);
289
- date.setUTCHours(0, 0, 0, 0);
290
- var startOfYearTimestamp = date.getTime();
291
- var difference = timestamp - startOfYearTimestamp;
292
- return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
293
- }
294
-
295
118
  function startOfUTCISOWeek(dirtyDate) {
296
119
  requiredArgs(1, arguments);
297
120
  var weekStartsOn = 1;
@@ -421,1980 +244,6 @@ function getUTCWeek(dirtyDate, options) {
421
244
  return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
422
245
  }
423
246
 
424
- function addLeadingZeros(number, targetLength) {
425
- var sign = number < 0 ? '-' : '';
426
- var output = Math.abs(number).toString();
427
-
428
- while (output.length < targetLength) {
429
- output = '0' + output;
430
- }
431
-
432
- return sign + output;
433
- }
434
-
435
- /*
436
- * | | Unit | | Unit |
437
- * |-----|--------------------------------|-----|--------------------------------|
438
- * | a | AM, PM | A* | |
439
- * | d | Day of month | D | |
440
- * | h | Hour [1-12] | H | Hour [0-23] |
441
- * | m | Minute | M | Month |
442
- * | s | Second | S | Fraction of second |
443
- * | y | Year (abs) | Y | |
444
- *
445
- * Letters marked by * are not implemented but reserved by Unicode standard.
446
- */
447
-
448
- var formatters$1 = {
449
- // Year
450
- y: function y(date, token) {
451
- // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
452
- // | Year | y | yy | yyy | yyyy | yyyyy |
453
- // |----------|-------|----|-------|-------|-------|
454
- // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
455
- // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
456
- // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
457
- // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
458
- // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
459
- var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
460
-
461
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
462
- return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
463
- },
464
- // Month
465
- M: function M(date, token) {
466
- var month = date.getUTCMonth();
467
- return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
468
- },
469
- // Day of the month
470
- d: function d(date, token) {
471
- return addLeadingZeros(date.getUTCDate(), token.length);
472
- },
473
- // AM or PM
474
- a: function a(date, token) {
475
- var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
476
-
477
- switch (token) {
478
- case 'a':
479
- case 'aa':
480
- return dayPeriodEnumValue.toUpperCase();
481
-
482
- case 'aaa':
483
- return dayPeriodEnumValue;
484
-
485
- case 'aaaaa':
486
- return dayPeriodEnumValue[0];
487
-
488
- case 'aaaa':
489
- default:
490
- return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
491
- }
492
- },
493
- // Hour [1-12]
494
- h: function h(date, token) {
495
- return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
496
- },
497
- // Hour [0-23]
498
- H: function H(date, token) {
499
- return addLeadingZeros(date.getUTCHours(), token.length);
500
- },
501
- // Minute
502
- m: function m(date, token) {
503
- return addLeadingZeros(date.getUTCMinutes(), token.length);
504
- },
505
- // Second
506
- s: function s(date, token) {
507
- return addLeadingZeros(date.getUTCSeconds(), token.length);
508
- },
509
- // Fraction of second
510
- S: function S(date, token) {
511
- var numberOfDigits = token.length;
512
- var milliseconds = date.getUTCMilliseconds();
513
- var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
514
- return addLeadingZeros(fractionalSeconds, token.length);
515
- }
516
- };
517
-
518
- var dayPeriodEnum = {
519
- am: 'am',
520
- pm: 'pm',
521
- midnight: 'midnight',
522
- noon: 'noon',
523
- morning: 'morning',
524
- afternoon: 'afternoon',
525
- evening: 'evening',
526
- night: 'night'
527
- };
528
-
529
- /*
530
- * | | Unit | | Unit |
531
- * |-----|--------------------------------|-----|--------------------------------|
532
- * | a | AM, PM | A* | Milliseconds in day |
533
- * | b | AM, PM, noon, midnight | B | Flexible day period |
534
- * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
535
- * | d | Day of month | D | Day of year |
536
- * | e | Local day of week | E | Day of week |
537
- * | f | | F* | Day of week in month |
538
- * | g* | Modified Julian day | G | Era |
539
- * | h | Hour [1-12] | H | Hour [0-23] |
540
- * | i! | ISO day of week | I! | ISO week of year |
541
- * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
542
- * | k | Hour [1-24] | K | Hour [0-11] |
543
- * | l* | (deprecated) | L | Stand-alone month |
544
- * | m | Minute | M | Month |
545
- * | n | | N | |
546
- * | o! | Ordinal number modifier | O | Timezone (GMT) |
547
- * | p! | Long localized time | P! | Long localized date |
548
- * | q | Stand-alone quarter | Q | Quarter |
549
- * | r* | Related Gregorian year | R! | ISO week-numbering year |
550
- * | s | Second | S | Fraction of second |
551
- * | t! | Seconds timestamp | T! | Milliseconds timestamp |
552
- * | u | Extended year | U* | Cyclic year |
553
- * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
554
- * | w | Local week of year | W* | Week of month |
555
- * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
556
- * | y | Year (abs) | Y | Local week-numbering year |
557
- * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
558
- *
559
- * Letters marked by * are not implemented but reserved by Unicode standard.
560
- *
561
- * Letters marked by ! are non-standard, but implemented by date-fns:
562
- * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
563
- * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
564
- * i.e. 7 for Sunday, 1 for Monday, etc.
565
- * - `I` is ISO week of year, as opposed to `w` which is local week of year.
566
- * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
567
- * `R` is supposed to be used in conjunction with `I` and `i`
568
- * for universal ISO week-numbering date, whereas
569
- * `Y` is supposed to be used in conjunction with `w` and `e`
570
- * for week-numbering date specific to the locale.
571
- * - `P` is long localized date format
572
- * - `p` is long localized time format
573
- */
574
- var formatters = {
575
- // Era
576
- G: function G(date, token, localize) {
577
- var era = date.getUTCFullYear() > 0 ? 1 : 0;
578
-
579
- switch (token) {
580
- // AD, BC
581
- case 'G':
582
- case 'GG':
583
- case 'GGG':
584
- return localize.era(era, {
585
- width: 'abbreviated'
586
- });
587
- // A, B
588
-
589
- case 'GGGGG':
590
- return localize.era(era, {
591
- width: 'narrow'
592
- });
593
- // Anno Domini, Before Christ
594
-
595
- case 'GGGG':
596
- default:
597
- return localize.era(era, {
598
- width: 'wide'
599
- });
600
- }
601
- },
602
- // Year
603
- y: function y(date, token, localize) {
604
- // Ordinal number
605
- if (token === 'yo') {
606
- var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
607
-
608
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
609
- return localize.ordinalNumber(year, {
610
- unit: 'year'
611
- });
612
- }
613
-
614
- return formatters$1.y(date, token);
615
- },
616
- // Local week-numbering year
617
- Y: function Y(date, token, localize, options) {
618
- var signedWeekYear = getUTCWeekYear(date, options); // Returns 1 for 1 BC (which is year 0 in JavaScript)
619
-
620
- var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; // Two digit year
621
-
622
- if (token === 'YY') {
623
- var twoDigitYear = weekYear % 100;
624
- return addLeadingZeros(twoDigitYear, 2);
625
- } // Ordinal number
626
-
627
-
628
- if (token === 'Yo') {
629
- return localize.ordinalNumber(weekYear, {
630
- unit: 'year'
631
- });
632
- } // Padding
633
-
634
-
635
- return addLeadingZeros(weekYear, token.length);
636
- },
637
- // ISO week-numbering year
638
- R: function R(date, token) {
639
- var isoWeekYear = getUTCISOWeekYear(date); // Padding
640
-
641
- return addLeadingZeros(isoWeekYear, token.length);
642
- },
643
- // Extended year. This is a single number designating the year of this calendar system.
644
- // The main difference between `y` and `u` localizers are B.C. years:
645
- // | Year | `y` | `u` |
646
- // |------|-----|-----|
647
- // | AC 1 | 1 | 1 |
648
- // | BC 1 | 1 | 0 |
649
- // | BC 2 | 2 | -1 |
650
- // Also `yy` always returns the last two digits of a year,
651
- // while `uu` pads single digit years to 2 characters and returns other years unchanged.
652
- u: function u(date, token) {
653
- var year = date.getUTCFullYear();
654
- return addLeadingZeros(year, token.length);
655
- },
656
- // Quarter
657
- Q: function Q(date, token, localize) {
658
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
659
-
660
- switch (token) {
661
- // 1, 2, 3, 4
662
- case 'Q':
663
- return String(quarter);
664
- // 01, 02, 03, 04
665
-
666
- case 'QQ':
667
- return addLeadingZeros(quarter, 2);
668
- // 1st, 2nd, 3rd, 4th
669
-
670
- case 'Qo':
671
- return localize.ordinalNumber(quarter, {
672
- unit: 'quarter'
673
- });
674
- // Q1, Q2, Q3, Q4
675
-
676
- case 'QQQ':
677
- return localize.quarter(quarter, {
678
- width: 'abbreviated',
679
- context: 'formatting'
680
- });
681
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
682
-
683
- case 'QQQQQ':
684
- return localize.quarter(quarter, {
685
- width: 'narrow',
686
- context: 'formatting'
687
- });
688
- // 1st quarter, 2nd quarter, ...
689
-
690
- case 'QQQQ':
691
- default:
692
- return localize.quarter(quarter, {
693
- width: 'wide',
694
- context: 'formatting'
695
- });
696
- }
697
- },
698
- // Stand-alone quarter
699
- q: function q(date, token, localize) {
700
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
701
-
702
- switch (token) {
703
- // 1, 2, 3, 4
704
- case 'q':
705
- return String(quarter);
706
- // 01, 02, 03, 04
707
-
708
- case 'qq':
709
- return addLeadingZeros(quarter, 2);
710
- // 1st, 2nd, 3rd, 4th
711
-
712
- case 'qo':
713
- return localize.ordinalNumber(quarter, {
714
- unit: 'quarter'
715
- });
716
- // Q1, Q2, Q3, Q4
717
-
718
- case 'qqq':
719
- return localize.quarter(quarter, {
720
- width: 'abbreviated',
721
- context: 'standalone'
722
- });
723
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
724
-
725
- case 'qqqqq':
726
- return localize.quarter(quarter, {
727
- width: 'narrow',
728
- context: 'standalone'
729
- });
730
- // 1st quarter, 2nd quarter, ...
731
-
732
- case 'qqqq':
733
- default:
734
- return localize.quarter(quarter, {
735
- width: 'wide',
736
- context: 'standalone'
737
- });
738
- }
739
- },
740
- // Month
741
- M: function M(date, token, localize) {
742
- var month = date.getUTCMonth();
743
-
744
- switch (token) {
745
- case 'M':
746
- case 'MM':
747
- return formatters$1.M(date, token);
748
- // 1st, 2nd, ..., 12th
749
-
750
- case 'Mo':
751
- return localize.ordinalNumber(month + 1, {
752
- unit: 'month'
753
- });
754
- // Jan, Feb, ..., Dec
755
-
756
- case 'MMM':
757
- return localize.month(month, {
758
- width: 'abbreviated',
759
- context: 'formatting'
760
- });
761
- // J, F, ..., D
762
-
763
- case 'MMMMM':
764
- return localize.month(month, {
765
- width: 'narrow',
766
- context: 'formatting'
767
- });
768
- // January, February, ..., December
769
-
770
- case 'MMMM':
771
- default:
772
- return localize.month(month, {
773
- width: 'wide',
774
- context: 'formatting'
775
- });
776
- }
777
- },
778
- // Stand-alone month
779
- L: function L(date, token, localize) {
780
- var month = date.getUTCMonth();
781
-
782
- switch (token) {
783
- // 1, 2, ..., 12
784
- case 'L':
785
- return String(month + 1);
786
- // 01, 02, ..., 12
787
-
788
- case 'LL':
789
- return addLeadingZeros(month + 1, 2);
790
- // 1st, 2nd, ..., 12th
791
-
792
- case 'Lo':
793
- return localize.ordinalNumber(month + 1, {
794
- unit: 'month'
795
- });
796
- // Jan, Feb, ..., Dec
797
-
798
- case 'LLL':
799
- return localize.month(month, {
800
- width: 'abbreviated',
801
- context: 'standalone'
802
- });
803
- // J, F, ..., D
804
-
805
- case 'LLLLL':
806
- return localize.month(month, {
807
- width: 'narrow',
808
- context: 'standalone'
809
- });
810
- // January, February, ..., December
811
-
812
- case 'LLLL':
813
- default:
814
- return localize.month(month, {
815
- width: 'wide',
816
- context: 'standalone'
817
- });
818
- }
819
- },
820
- // Local week of year
821
- w: function w(date, token, localize, options) {
822
- var week = getUTCWeek(date, options);
823
-
824
- if (token === 'wo') {
825
- return localize.ordinalNumber(week, {
826
- unit: 'week'
827
- });
828
- }
829
-
830
- return addLeadingZeros(week, token.length);
831
- },
832
- // ISO week of year
833
- I: function I(date, token, localize) {
834
- var isoWeek = getUTCISOWeek(date);
835
-
836
- if (token === 'Io') {
837
- return localize.ordinalNumber(isoWeek, {
838
- unit: 'week'
839
- });
840
- }
841
-
842
- return addLeadingZeros(isoWeek, token.length);
843
- },
844
- // Day of the month
845
- d: function d(date, token, localize) {
846
- if (token === 'do') {
847
- return localize.ordinalNumber(date.getUTCDate(), {
848
- unit: 'date'
849
- });
850
- }
851
-
852
- return formatters$1.d(date, token);
853
- },
854
- // Day of year
855
- D: function D(date, token, localize) {
856
- var dayOfYear = getUTCDayOfYear(date);
857
-
858
- if (token === 'Do') {
859
- return localize.ordinalNumber(dayOfYear, {
860
- unit: 'dayOfYear'
861
- });
862
- }
863
-
864
- return addLeadingZeros(dayOfYear, token.length);
865
- },
866
- // Day of week
867
- E: function E(date, token, localize) {
868
- var dayOfWeek = date.getUTCDay();
869
-
870
- switch (token) {
871
- // Tue
872
- case 'E':
873
- case 'EE':
874
- case 'EEE':
875
- return localize.day(dayOfWeek, {
876
- width: 'abbreviated',
877
- context: 'formatting'
878
- });
879
- // T
880
-
881
- case 'EEEEE':
882
- return localize.day(dayOfWeek, {
883
- width: 'narrow',
884
- context: 'formatting'
885
- });
886
- // Tu
887
-
888
- case 'EEEEEE':
889
- return localize.day(dayOfWeek, {
890
- width: 'short',
891
- context: 'formatting'
892
- });
893
- // Tuesday
894
-
895
- case 'EEEE':
896
- default:
897
- return localize.day(dayOfWeek, {
898
- width: 'wide',
899
- context: 'formatting'
900
- });
901
- }
902
- },
903
- // Local day of week
904
- e: function e(date, token, localize, options) {
905
- var dayOfWeek = date.getUTCDay();
906
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
907
-
908
- switch (token) {
909
- // Numerical value (Nth day of week with current locale or weekStartsOn)
910
- case 'e':
911
- return String(localDayOfWeek);
912
- // Padded numerical value
913
-
914
- case 'ee':
915
- return addLeadingZeros(localDayOfWeek, 2);
916
- // 1st, 2nd, ..., 7th
917
-
918
- case 'eo':
919
- return localize.ordinalNumber(localDayOfWeek, {
920
- unit: 'day'
921
- });
922
-
923
- case 'eee':
924
- return localize.day(dayOfWeek, {
925
- width: 'abbreviated',
926
- context: 'formatting'
927
- });
928
- // T
929
-
930
- case 'eeeee':
931
- return localize.day(dayOfWeek, {
932
- width: 'narrow',
933
- context: 'formatting'
934
- });
935
- // Tu
936
-
937
- case 'eeeeee':
938
- return localize.day(dayOfWeek, {
939
- width: 'short',
940
- context: 'formatting'
941
- });
942
- // Tuesday
943
-
944
- case 'eeee':
945
- default:
946
- return localize.day(dayOfWeek, {
947
- width: 'wide',
948
- context: 'formatting'
949
- });
950
- }
951
- },
952
- // Stand-alone local day of week
953
- c: function c(date, token, localize, options) {
954
- var dayOfWeek = date.getUTCDay();
955
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
956
-
957
- switch (token) {
958
- // Numerical value (same as in `e`)
959
- case 'c':
960
- return String(localDayOfWeek);
961
- // Padded numerical value
962
-
963
- case 'cc':
964
- return addLeadingZeros(localDayOfWeek, token.length);
965
- // 1st, 2nd, ..., 7th
966
-
967
- case 'co':
968
- return localize.ordinalNumber(localDayOfWeek, {
969
- unit: 'day'
970
- });
971
-
972
- case 'ccc':
973
- return localize.day(dayOfWeek, {
974
- width: 'abbreviated',
975
- context: 'standalone'
976
- });
977
- // T
978
-
979
- case 'ccccc':
980
- return localize.day(dayOfWeek, {
981
- width: 'narrow',
982
- context: 'standalone'
983
- });
984
- // Tu
985
-
986
- case 'cccccc':
987
- return localize.day(dayOfWeek, {
988
- width: 'short',
989
- context: 'standalone'
990
- });
991
- // Tuesday
992
-
993
- case 'cccc':
994
- default:
995
- return localize.day(dayOfWeek, {
996
- width: 'wide',
997
- context: 'standalone'
998
- });
999
- }
1000
- },
1001
- // ISO day of week
1002
- i: function i(date, token, localize) {
1003
- var dayOfWeek = date.getUTCDay();
1004
- var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1005
-
1006
- switch (token) {
1007
- // 2
1008
- case 'i':
1009
- return String(isoDayOfWeek);
1010
- // 02
1011
-
1012
- case 'ii':
1013
- return addLeadingZeros(isoDayOfWeek, token.length);
1014
- // 2nd
1015
-
1016
- case 'io':
1017
- return localize.ordinalNumber(isoDayOfWeek, {
1018
- unit: 'day'
1019
- });
1020
- // Tue
1021
-
1022
- case 'iii':
1023
- return localize.day(dayOfWeek, {
1024
- width: 'abbreviated',
1025
- context: 'formatting'
1026
- });
1027
- // T
1028
-
1029
- case 'iiiii':
1030
- return localize.day(dayOfWeek, {
1031
- width: 'narrow',
1032
- context: 'formatting'
1033
- });
1034
- // Tu
1035
-
1036
- case 'iiiiii':
1037
- return localize.day(dayOfWeek, {
1038
- width: 'short',
1039
- context: 'formatting'
1040
- });
1041
- // Tuesday
1042
-
1043
- case 'iiii':
1044
- default:
1045
- return localize.day(dayOfWeek, {
1046
- width: 'wide',
1047
- context: 'formatting'
1048
- });
1049
- }
1050
- },
1051
- // AM or PM
1052
- a: function a(date, token, localize) {
1053
- var hours = date.getUTCHours();
1054
- var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1055
-
1056
- switch (token) {
1057
- case 'a':
1058
- case 'aa':
1059
- return localize.dayPeriod(dayPeriodEnumValue, {
1060
- width: 'abbreviated',
1061
- context: 'formatting'
1062
- });
1063
-
1064
- case 'aaa':
1065
- return localize.dayPeriod(dayPeriodEnumValue, {
1066
- width: 'abbreviated',
1067
- context: 'formatting'
1068
- }).toLowerCase();
1069
-
1070
- case 'aaaaa':
1071
- return localize.dayPeriod(dayPeriodEnumValue, {
1072
- width: 'narrow',
1073
- context: 'formatting'
1074
- });
1075
-
1076
- case 'aaaa':
1077
- default:
1078
- return localize.dayPeriod(dayPeriodEnumValue, {
1079
- width: 'wide',
1080
- context: 'formatting'
1081
- });
1082
- }
1083
- },
1084
- // AM, PM, midnight, noon
1085
- b: function b(date, token, localize) {
1086
- var hours = date.getUTCHours();
1087
- var dayPeriodEnumValue;
1088
-
1089
- if (hours === 12) {
1090
- dayPeriodEnumValue = dayPeriodEnum.noon;
1091
- } else if (hours === 0) {
1092
- dayPeriodEnumValue = dayPeriodEnum.midnight;
1093
- } else {
1094
- dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1095
- }
1096
-
1097
- switch (token) {
1098
- case 'b':
1099
- case 'bb':
1100
- return localize.dayPeriod(dayPeriodEnumValue, {
1101
- width: 'abbreviated',
1102
- context: 'formatting'
1103
- });
1104
-
1105
- case 'bbb':
1106
- return localize.dayPeriod(dayPeriodEnumValue, {
1107
- width: 'abbreviated',
1108
- context: 'formatting'
1109
- }).toLowerCase();
1110
-
1111
- case 'bbbbb':
1112
- return localize.dayPeriod(dayPeriodEnumValue, {
1113
- width: 'narrow',
1114
- context: 'formatting'
1115
- });
1116
-
1117
- case 'bbbb':
1118
- default:
1119
- return localize.dayPeriod(dayPeriodEnumValue, {
1120
- width: 'wide',
1121
- context: 'formatting'
1122
- });
1123
- }
1124
- },
1125
- // in the morning, in the afternoon, in the evening, at night
1126
- B: function B(date, token, localize) {
1127
- var hours = date.getUTCHours();
1128
- var dayPeriodEnumValue;
1129
-
1130
- if (hours >= 17) {
1131
- dayPeriodEnumValue = dayPeriodEnum.evening;
1132
- } else if (hours >= 12) {
1133
- dayPeriodEnumValue = dayPeriodEnum.afternoon;
1134
- } else if (hours >= 4) {
1135
- dayPeriodEnumValue = dayPeriodEnum.morning;
1136
- } else {
1137
- dayPeriodEnumValue = dayPeriodEnum.night;
1138
- }
1139
-
1140
- switch (token) {
1141
- case 'B':
1142
- case 'BB':
1143
- case 'BBB':
1144
- return localize.dayPeriod(dayPeriodEnumValue, {
1145
- width: 'abbreviated',
1146
- context: 'formatting'
1147
- });
1148
-
1149
- case 'BBBBB':
1150
- return localize.dayPeriod(dayPeriodEnumValue, {
1151
- width: 'narrow',
1152
- context: 'formatting'
1153
- });
1154
-
1155
- case 'BBBB':
1156
- default:
1157
- return localize.dayPeriod(dayPeriodEnumValue, {
1158
- width: 'wide',
1159
- context: 'formatting'
1160
- });
1161
- }
1162
- },
1163
- // Hour [1-12]
1164
- h: function h(date, token, localize) {
1165
- if (token === 'ho') {
1166
- var hours = date.getUTCHours() % 12;
1167
- if (hours === 0) hours = 12;
1168
- return localize.ordinalNumber(hours, {
1169
- unit: 'hour'
1170
- });
1171
- }
1172
-
1173
- return formatters$1.h(date, token);
1174
- },
1175
- // Hour [0-23]
1176
- H: function H(date, token, localize) {
1177
- if (token === 'Ho') {
1178
- return localize.ordinalNumber(date.getUTCHours(), {
1179
- unit: 'hour'
1180
- });
1181
- }
1182
-
1183
- return formatters$1.H(date, token);
1184
- },
1185
- // Hour [0-11]
1186
- K: function K(date, token, localize) {
1187
- var hours = date.getUTCHours() % 12;
1188
-
1189
- if (token === 'Ko') {
1190
- return localize.ordinalNumber(hours, {
1191
- unit: 'hour'
1192
- });
1193
- }
1194
-
1195
- return addLeadingZeros(hours, token.length);
1196
- },
1197
- // Hour [1-24]
1198
- k: function k(date, token, localize) {
1199
- var hours = date.getUTCHours();
1200
- if (hours === 0) hours = 24;
1201
-
1202
- if (token === 'ko') {
1203
- return localize.ordinalNumber(hours, {
1204
- unit: 'hour'
1205
- });
1206
- }
1207
-
1208
- return addLeadingZeros(hours, token.length);
1209
- },
1210
- // Minute
1211
- m: function m(date, token, localize) {
1212
- if (token === 'mo') {
1213
- return localize.ordinalNumber(date.getUTCMinutes(), {
1214
- unit: 'minute'
1215
- });
1216
- }
1217
-
1218
- return formatters$1.m(date, token);
1219
- },
1220
- // Second
1221
- s: function s(date, token, localize) {
1222
- if (token === 'so') {
1223
- return localize.ordinalNumber(date.getUTCSeconds(), {
1224
- unit: 'second'
1225
- });
1226
- }
1227
-
1228
- return formatters$1.s(date, token);
1229
- },
1230
- // Fraction of second
1231
- S: function S(date, token) {
1232
- return formatters$1.S(date, token);
1233
- },
1234
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1235
- X: function X(date, token, _localize, options) {
1236
- var originalDate = options._originalDate || date;
1237
- var timezoneOffset = originalDate.getTimezoneOffset();
1238
-
1239
- if (timezoneOffset === 0) {
1240
- return 'Z';
1241
- }
1242
-
1243
- switch (token) {
1244
- // Hours and optional minutes
1245
- case 'X':
1246
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1247
- // Hours, minutes and optional seconds without `:` delimiter
1248
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1249
- // so this token always has the same output as `XX`
1250
-
1251
- case 'XXXX':
1252
- case 'XX':
1253
- // Hours and minutes without `:` delimiter
1254
- return formatTimezone(timezoneOffset);
1255
- // Hours, minutes and optional seconds with `:` delimiter
1256
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1257
- // so this token always has the same output as `XXX`
1258
-
1259
- case 'XXXXX':
1260
- case 'XXX': // Hours and minutes with `:` delimiter
1261
-
1262
- default:
1263
- return formatTimezone(timezoneOffset, ':');
1264
- }
1265
- },
1266
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1267
- x: function x(date, token, _localize, options) {
1268
- var originalDate = options._originalDate || date;
1269
- var timezoneOffset = originalDate.getTimezoneOffset();
1270
-
1271
- switch (token) {
1272
- // Hours and optional minutes
1273
- case 'x':
1274
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1275
- // Hours, minutes and optional seconds without `:` delimiter
1276
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1277
- // so this token always has the same output as `xx`
1278
-
1279
- case 'xxxx':
1280
- case 'xx':
1281
- // Hours and minutes without `:` delimiter
1282
- return formatTimezone(timezoneOffset);
1283
- // Hours, minutes and optional seconds with `:` delimiter
1284
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1285
- // so this token always has the same output as `xxx`
1286
-
1287
- case 'xxxxx':
1288
- case 'xxx': // Hours and minutes with `:` delimiter
1289
-
1290
- default:
1291
- return formatTimezone(timezoneOffset, ':');
1292
- }
1293
- },
1294
- // Timezone (GMT)
1295
- O: function O(date, token, _localize, options) {
1296
- var originalDate = options._originalDate || date;
1297
- var timezoneOffset = originalDate.getTimezoneOffset();
1298
-
1299
- switch (token) {
1300
- // Short
1301
- case 'O':
1302
- case 'OO':
1303
- case 'OOO':
1304
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1305
- // Long
1306
-
1307
- case 'OOOO':
1308
- default:
1309
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1310
- }
1311
- },
1312
- // Timezone (specific non-location)
1313
- z: function z(date, token, _localize, options) {
1314
- var originalDate = options._originalDate || date;
1315
- var timezoneOffset = originalDate.getTimezoneOffset();
1316
-
1317
- switch (token) {
1318
- // Short
1319
- case 'z':
1320
- case 'zz':
1321
- case 'zzz':
1322
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1323
- // Long
1324
-
1325
- case 'zzzz':
1326
- default:
1327
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1328
- }
1329
- },
1330
- // Seconds timestamp
1331
- t: function t(date, token, _localize, options) {
1332
- var originalDate = options._originalDate || date;
1333
- var timestamp = Math.floor(originalDate.getTime() / 1000);
1334
- return addLeadingZeros(timestamp, token.length);
1335
- },
1336
- // Milliseconds timestamp
1337
- T: function T(date, token, _localize, options) {
1338
- var originalDate = options._originalDate || date;
1339
- var timestamp = originalDate.getTime();
1340
- return addLeadingZeros(timestamp, token.length);
1341
- }
1342
- };
1343
-
1344
- function formatTimezoneShort(offset, dirtyDelimiter) {
1345
- var sign = offset > 0 ? '-' : '+';
1346
- var absOffset = Math.abs(offset);
1347
- var hours = Math.floor(absOffset / 60);
1348
- var minutes = absOffset % 60;
1349
-
1350
- if (minutes === 0) {
1351
- return sign + String(hours);
1352
- }
1353
-
1354
- var delimiter = dirtyDelimiter || '';
1355
- return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1356
- }
1357
-
1358
- function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1359
- if (offset % 60 === 0) {
1360
- var sign = offset > 0 ? '-' : '+';
1361
- return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1362
- }
1363
-
1364
- return formatTimezone(offset, dirtyDelimiter);
1365
- }
1366
-
1367
- function formatTimezone(offset, dirtyDelimiter) {
1368
- var delimiter = dirtyDelimiter || '';
1369
- var sign = offset > 0 ? '-' : '+';
1370
- var absOffset = Math.abs(offset);
1371
- var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1372
- var minutes = addLeadingZeros(absOffset % 60, 2);
1373
- return sign + hours + delimiter + minutes;
1374
- }
1375
-
1376
- var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1377
- switch (pattern) {
1378
- case 'P':
1379
- return formatLong.date({
1380
- width: 'short'
1381
- });
1382
-
1383
- case 'PP':
1384
- return formatLong.date({
1385
- width: 'medium'
1386
- });
1387
-
1388
- case 'PPP':
1389
- return formatLong.date({
1390
- width: 'long'
1391
- });
1392
-
1393
- case 'PPPP':
1394
- default:
1395
- return formatLong.date({
1396
- width: 'full'
1397
- });
1398
- }
1399
- };
1400
-
1401
- var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1402
- switch (pattern) {
1403
- case 'p':
1404
- return formatLong.time({
1405
- width: 'short'
1406
- });
1407
-
1408
- case 'pp':
1409
- return formatLong.time({
1410
- width: 'medium'
1411
- });
1412
-
1413
- case 'ppp':
1414
- return formatLong.time({
1415
- width: 'long'
1416
- });
1417
-
1418
- case 'pppp':
1419
- default:
1420
- return formatLong.time({
1421
- width: 'full'
1422
- });
1423
- }
1424
- };
1425
-
1426
- var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1427
- var matchResult = pattern.match(/(P+)(p+)?/) || [];
1428
- var datePattern = matchResult[1];
1429
- var timePattern = matchResult[2];
1430
-
1431
- if (!timePattern) {
1432
- return dateLongFormatter(pattern, formatLong);
1433
- }
1434
-
1435
- var dateTimeFormat;
1436
-
1437
- switch (datePattern) {
1438
- case 'P':
1439
- dateTimeFormat = formatLong.dateTime({
1440
- width: 'short'
1441
- });
1442
- break;
1443
-
1444
- case 'PP':
1445
- dateTimeFormat = formatLong.dateTime({
1446
- width: 'medium'
1447
- });
1448
- break;
1449
-
1450
- case 'PPP':
1451
- dateTimeFormat = formatLong.dateTime({
1452
- width: 'long'
1453
- });
1454
- break;
1455
-
1456
- case 'PPPP':
1457
- default:
1458
- dateTimeFormat = formatLong.dateTime({
1459
- width: 'full'
1460
- });
1461
- break;
1462
- }
1463
-
1464
- return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1465
- };
1466
-
1467
- var longFormatters = {
1468
- p: timeLongFormatter,
1469
- P: dateTimeLongFormatter
1470
- };
1471
-
1472
- var protectedDayOfYearTokens = ['D', 'DD'];
1473
- var protectedWeekYearTokens = ['YY', 'YYYY'];
1474
- function isProtectedDayOfYearToken(token) {
1475
- return protectedDayOfYearTokens.indexOf(token) !== -1;
1476
- }
1477
- function isProtectedWeekYearToken(token) {
1478
- return protectedWeekYearTokens.indexOf(token) !== -1;
1479
- }
1480
- function throwProtectedError(token, format, input) {
1481
- if (token === 'YYYY') {
1482
- throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1483
- } else if (token === 'YY') {
1484
- throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1485
- } else if (token === 'D') {
1486
- throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1487
- } else if (token === 'DD') {
1488
- throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1489
- }
1490
- }
1491
-
1492
- var formatDistanceLocale = {
1493
- lessThanXSeconds: {
1494
- one: 'less than a second',
1495
- other: 'less than {{count}} seconds'
1496
- },
1497
- xSeconds: {
1498
- one: '1 second',
1499
- other: '{{count}} seconds'
1500
- },
1501
- halfAMinute: 'half a minute',
1502
- lessThanXMinutes: {
1503
- one: 'less than a minute',
1504
- other: 'less than {{count}} minutes'
1505
- },
1506
- xMinutes: {
1507
- one: '1 minute',
1508
- other: '{{count}} minutes'
1509
- },
1510
- aboutXHours: {
1511
- one: 'about 1 hour',
1512
- other: 'about {{count}} hours'
1513
- },
1514
- xHours: {
1515
- one: '1 hour',
1516
- other: '{{count}} hours'
1517
- },
1518
- xDays: {
1519
- one: '1 day',
1520
- other: '{{count}} days'
1521
- },
1522
- aboutXWeeks: {
1523
- one: 'about 1 week',
1524
- other: 'about {{count}} weeks'
1525
- },
1526
- xWeeks: {
1527
- one: '1 week',
1528
- other: '{{count}} weeks'
1529
- },
1530
- aboutXMonths: {
1531
- one: 'about 1 month',
1532
- other: 'about {{count}} months'
1533
- },
1534
- xMonths: {
1535
- one: '1 month',
1536
- other: '{{count}} months'
1537
- },
1538
- aboutXYears: {
1539
- one: 'about 1 year',
1540
- other: 'about {{count}} years'
1541
- },
1542
- xYears: {
1543
- one: '1 year',
1544
- other: '{{count}} years'
1545
- },
1546
- overXYears: {
1547
- one: 'over 1 year',
1548
- other: 'over {{count}} years'
1549
- },
1550
- almostXYears: {
1551
- one: 'almost 1 year',
1552
- other: 'almost {{count}} years'
1553
- }
1554
- };
1555
-
1556
- var formatDistance = function formatDistance(token, count, options) {
1557
- var result;
1558
- var tokenValue = formatDistanceLocale[token];
1559
-
1560
- if (typeof tokenValue === 'string') {
1561
- result = tokenValue;
1562
- } else if (count === 1) {
1563
- result = tokenValue.one;
1564
- } else {
1565
- result = tokenValue.other.replace('{{count}}', count.toString());
1566
- }
1567
-
1568
- if (options !== null && options !== void 0 && options.addSuffix) {
1569
- if (options.comparison && options.comparison > 0) {
1570
- return 'in ' + result;
1571
- } else {
1572
- return result + ' ago';
1573
- }
1574
- }
1575
-
1576
- return result;
1577
- };
1578
-
1579
- function buildFormatLongFn(args) {
1580
- return function () {
1581
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1582
- // TODO: Remove String()
1583
- var width = options.width ? String(options.width) : args.defaultWidth;
1584
- var format = args.formats[width] || args.formats[args.defaultWidth];
1585
- return format;
1586
- };
1587
- }
1588
-
1589
- var dateFormats = {
1590
- full: 'EEEE, MMMM do, y',
1591
- long: 'MMMM do, y',
1592
- medium: 'MMM d, y',
1593
- short: 'MM/dd/yyyy'
1594
- };
1595
- var timeFormats = {
1596
- full: 'h:mm:ss a zzzz',
1597
- long: 'h:mm:ss a z',
1598
- medium: 'h:mm:ss a',
1599
- short: 'h:mm a'
1600
- };
1601
- var dateTimeFormats = {
1602
- full: "{{date}} 'at' {{time}}",
1603
- long: "{{date}} 'at' {{time}}",
1604
- medium: '{{date}}, {{time}}',
1605
- short: '{{date}}, {{time}}'
1606
- };
1607
- var formatLong = {
1608
- date: buildFormatLongFn({
1609
- formats: dateFormats,
1610
- defaultWidth: 'full'
1611
- }),
1612
- time: buildFormatLongFn({
1613
- formats: timeFormats,
1614
- defaultWidth: 'full'
1615
- }),
1616
- dateTime: buildFormatLongFn({
1617
- formats: dateTimeFormats,
1618
- defaultWidth: 'full'
1619
- })
1620
- };
1621
-
1622
- var formatRelativeLocale = {
1623
- lastWeek: "'last' eeee 'at' p",
1624
- yesterday: "'yesterday at' p",
1625
- today: "'today at' p",
1626
- tomorrow: "'tomorrow at' p",
1627
- nextWeek: "eeee 'at' p",
1628
- other: 'P'
1629
- };
1630
-
1631
- var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1632
- return formatRelativeLocale[token];
1633
- };
1634
-
1635
- function buildLocalizeFn(args) {
1636
- return function (dirtyIndex, options) {
1637
- var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1638
- var valuesArray;
1639
-
1640
- if (context === 'formatting' && args.formattingValues) {
1641
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1642
- var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1643
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1644
- } else {
1645
- var _defaultWidth = args.defaultWidth;
1646
-
1647
- var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1648
-
1649
- valuesArray = args.values[_width] || args.values[_defaultWidth];
1650
- }
1651
-
1652
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
1653
-
1654
- return valuesArray[index];
1655
- };
1656
- }
1657
-
1658
- var eraValues = {
1659
- narrow: ['B', 'A'],
1660
- abbreviated: ['BC', 'AD'],
1661
- wide: ['Before Christ', 'Anno Domini']
1662
- };
1663
- var quarterValues = {
1664
- narrow: ['1', '2', '3', '4'],
1665
- abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1666
- wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1667
- }; // Note: in English, the names of days of the week and months are capitalized.
1668
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1669
- // Generally, formatted dates should look like they are in the middle of a sentence,
1670
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
1671
-
1672
- var monthValues = {
1673
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1674
- abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1675
- wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1676
- };
1677
- var dayValues = {
1678
- narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1679
- short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1680
- abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1681
- wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1682
- };
1683
- var dayPeriodValues = {
1684
- narrow: {
1685
- am: 'a',
1686
- pm: 'p',
1687
- midnight: 'mi',
1688
- noon: 'n',
1689
- morning: 'morning',
1690
- afternoon: 'afternoon',
1691
- evening: 'evening',
1692
- night: 'night'
1693
- },
1694
- abbreviated: {
1695
- am: 'AM',
1696
- pm: 'PM',
1697
- midnight: 'midnight',
1698
- noon: 'noon',
1699
- morning: 'morning',
1700
- afternoon: 'afternoon',
1701
- evening: 'evening',
1702
- night: 'night'
1703
- },
1704
- wide: {
1705
- am: 'a.m.',
1706
- pm: 'p.m.',
1707
- midnight: 'midnight',
1708
- noon: 'noon',
1709
- morning: 'morning',
1710
- afternoon: 'afternoon',
1711
- evening: 'evening',
1712
- night: 'night'
1713
- }
1714
- };
1715
- var formattingDayPeriodValues = {
1716
- narrow: {
1717
- am: 'a',
1718
- pm: 'p',
1719
- midnight: 'mi',
1720
- noon: 'n',
1721
- morning: 'in the morning',
1722
- afternoon: 'in the afternoon',
1723
- evening: 'in the evening',
1724
- night: 'at night'
1725
- },
1726
- abbreviated: {
1727
- am: 'AM',
1728
- pm: 'PM',
1729
- midnight: 'midnight',
1730
- noon: 'noon',
1731
- morning: 'in the morning',
1732
- afternoon: 'in the afternoon',
1733
- evening: 'in the evening',
1734
- night: 'at night'
1735
- },
1736
- wide: {
1737
- am: 'a.m.',
1738
- pm: 'p.m.',
1739
- midnight: 'midnight',
1740
- noon: 'noon',
1741
- morning: 'in the morning',
1742
- afternoon: 'in the afternoon',
1743
- evening: 'in the evening',
1744
- night: 'at night'
1745
- }
1746
- };
1747
-
1748
- var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1749
- var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
1750
- // if they are different for different grammatical genders,
1751
- // use `options.unit`.
1752
- //
1753
- // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1754
- // 'day', 'hour', 'minute', 'second'.
1755
-
1756
- var rem100 = number % 100;
1757
-
1758
- if (rem100 > 20 || rem100 < 10) {
1759
- switch (rem100 % 10) {
1760
- case 1:
1761
- return number + 'st';
1762
-
1763
- case 2:
1764
- return number + 'nd';
1765
-
1766
- case 3:
1767
- return number + 'rd';
1768
- }
1769
- }
1770
-
1771
- return number + 'th';
1772
- };
1773
-
1774
- var localize = {
1775
- ordinalNumber: ordinalNumber,
1776
- era: buildLocalizeFn({
1777
- values: eraValues,
1778
- defaultWidth: 'wide'
1779
- }),
1780
- quarter: buildLocalizeFn({
1781
- values: quarterValues,
1782
- defaultWidth: 'wide',
1783
- argumentCallback: function argumentCallback(quarter) {
1784
- return quarter - 1;
1785
- }
1786
- }),
1787
- month: buildLocalizeFn({
1788
- values: monthValues,
1789
- defaultWidth: 'wide'
1790
- }),
1791
- day: buildLocalizeFn({
1792
- values: dayValues,
1793
- defaultWidth: 'wide'
1794
- }),
1795
- dayPeriod: buildLocalizeFn({
1796
- values: dayPeriodValues,
1797
- defaultWidth: 'wide',
1798
- formattingValues: formattingDayPeriodValues,
1799
- defaultFormattingWidth: 'wide'
1800
- })
1801
- };
1802
-
1803
- function buildMatchFn(args) {
1804
- return function (string) {
1805
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1806
- var width = options.width;
1807
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1808
- var matchResult = string.match(matchPattern);
1809
-
1810
- if (!matchResult) {
1811
- return null;
1812
- }
1813
-
1814
- var matchedString = matchResult[0];
1815
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1816
- var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1817
- return pattern.test(matchedString);
1818
- }) : findKey(parsePatterns, function (pattern) {
1819
- return pattern.test(matchedString);
1820
- });
1821
- var value;
1822
- value = args.valueCallback ? args.valueCallback(key) : key;
1823
- value = options.valueCallback ? options.valueCallback(value) : value;
1824
- var rest = string.slice(matchedString.length);
1825
- return {
1826
- value: value,
1827
- rest: rest
1828
- };
1829
- };
1830
- }
1831
-
1832
- function findKey(object, predicate) {
1833
- for (var key in object) {
1834
- if (object.hasOwnProperty(key) && predicate(object[key])) {
1835
- return key;
1836
- }
1837
- }
1838
-
1839
- return undefined;
1840
- }
1841
-
1842
- function findIndex(array, predicate) {
1843
- for (var key = 0; key < array.length; key++) {
1844
- if (predicate(array[key])) {
1845
- return key;
1846
- }
1847
- }
1848
-
1849
- return undefined;
1850
- }
1851
-
1852
- function buildMatchPatternFn(args) {
1853
- return function (string) {
1854
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1855
- var matchResult = string.match(args.matchPattern);
1856
- if (!matchResult) return null;
1857
- var matchedString = matchResult[0];
1858
- var parseResult = string.match(args.parsePattern);
1859
- if (!parseResult) return null;
1860
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1861
- value = options.valueCallback ? options.valueCallback(value) : value;
1862
- var rest = string.slice(matchedString.length);
1863
- return {
1864
- value: value,
1865
- rest: rest
1866
- };
1867
- };
1868
- }
1869
-
1870
- var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1871
- var parseOrdinalNumberPattern = /\d+/i;
1872
- var matchEraPatterns = {
1873
- narrow: /^(b|a)/i,
1874
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1875
- wide: /^(before christ|before common era|anno domini|common era)/i
1876
- };
1877
- var parseEraPatterns = {
1878
- any: [/^b/i, /^(a|c)/i]
1879
- };
1880
- var matchQuarterPatterns = {
1881
- narrow: /^[1234]/i,
1882
- abbreviated: /^q[1234]/i,
1883
- wide: /^[1234](th|st|nd|rd)? quarter/i
1884
- };
1885
- var parseQuarterPatterns = {
1886
- any: [/1/i, /2/i, /3/i, /4/i]
1887
- };
1888
- var matchMonthPatterns = {
1889
- narrow: /^[jfmasond]/i,
1890
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1891
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1892
- };
1893
- var parseMonthPatterns = {
1894
- narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
1895
- any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
1896
- };
1897
- var matchDayPatterns = {
1898
- narrow: /^[smtwf]/i,
1899
- short: /^(su|mo|tu|we|th|fr|sa)/i,
1900
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1901
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1902
- };
1903
- var parseDayPatterns = {
1904
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1905
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1906
- };
1907
- var matchDayPeriodPatterns = {
1908
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1909
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1910
- };
1911
- var parseDayPeriodPatterns = {
1912
- any: {
1913
- am: /^a/i,
1914
- pm: /^p/i,
1915
- midnight: /^mi/i,
1916
- noon: /^no/i,
1917
- morning: /morning/i,
1918
- afternoon: /afternoon/i,
1919
- evening: /evening/i,
1920
- night: /night/i
1921
- }
1922
- };
1923
- var match = {
1924
- ordinalNumber: buildMatchPatternFn({
1925
- matchPattern: matchOrdinalNumberPattern,
1926
- parsePattern: parseOrdinalNumberPattern,
1927
- valueCallback: function valueCallback(value) {
1928
- return parseInt(value, 10);
1929
- }
1930
- }),
1931
- era: buildMatchFn({
1932
- matchPatterns: matchEraPatterns,
1933
- defaultMatchWidth: 'wide',
1934
- parsePatterns: parseEraPatterns,
1935
- defaultParseWidth: 'any'
1936
- }),
1937
- quarter: buildMatchFn({
1938
- matchPatterns: matchQuarterPatterns,
1939
- defaultMatchWidth: 'wide',
1940
- parsePatterns: parseQuarterPatterns,
1941
- defaultParseWidth: 'any',
1942
- valueCallback: function valueCallback(index) {
1943
- return index + 1;
1944
- }
1945
- }),
1946
- month: buildMatchFn({
1947
- matchPatterns: matchMonthPatterns,
1948
- defaultMatchWidth: 'wide',
1949
- parsePatterns: parseMonthPatterns,
1950
- defaultParseWidth: 'any'
1951
- }),
1952
- day: buildMatchFn({
1953
- matchPatterns: matchDayPatterns,
1954
- defaultMatchWidth: 'wide',
1955
- parsePatterns: parseDayPatterns,
1956
- defaultParseWidth: 'any'
1957
- }),
1958
- dayPeriod: buildMatchFn({
1959
- matchPatterns: matchDayPeriodPatterns,
1960
- defaultMatchWidth: 'any',
1961
- parsePatterns: parseDayPeriodPatterns,
1962
- defaultParseWidth: 'any'
1963
- })
1964
- };
1965
-
1966
- /**
1967
- * @type {Locale}
1968
- * @category Locales
1969
- * @summary English locale (United States).
1970
- * @language English
1971
- * @iso-639-2 eng
1972
- * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1973
- * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1974
- */
1975
- var locale = {
1976
- code: 'en-US',
1977
- formatDistance: formatDistance,
1978
- formatLong: formatLong,
1979
- formatRelative: formatRelative,
1980
- localize: localize,
1981
- match: match,
1982
- options: {
1983
- weekStartsOn: 0
1984
- /* Sunday */
1985
- ,
1986
- firstWeekContainsDate: 1
1987
- }
1988
- };
1989
-
1990
- // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1991
- // (one of the certain letters followed by `o`)
1992
- // - (\w)\1* matches any sequences of the same letter
1993
- // - '' matches two quote characters in a row
1994
- // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
1995
- // except a single quote symbol, which ends the sequence.
1996
- // Two quote characters do not end the sequence.
1997
- // If there is no matching single quote
1998
- // then the sequence will continue until the end of the string.
1999
- // - . matches any single character unmatched by previous parts of the RegExps
2000
-
2001
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; // This RegExp catches symbols escaped by quotes, and also
2002
- // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2003
-
2004
- var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2005
- var escapedStringRegExp = /^'([^]*?)'?$/;
2006
- var doubleQuoteRegExp = /''/g;
2007
- var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2008
- /**
2009
- * @name format
2010
- * @category Common Helpers
2011
- * @summary Format the date.
2012
- *
2013
- * @description
2014
- * Return the formatted date string in the given format. The result may vary by locale.
2015
- *
2016
- * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2017
- * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2018
- *
2019
- * The characters wrapped between two single quotes characters (') are escaped.
2020
- * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2021
- * (see the last example)
2022
- *
2023
- * Format of the string is based on Unicode Technical Standard #35:
2024
- * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2025
- * with a few additions (see note 7 below the table).
2026
- *
2027
- * Accepted patterns:
2028
- * | Unit | Pattern | Result examples | Notes |
2029
- * |---------------------------------|---------|-----------------------------------|-------|
2030
- * | Era | G..GGG | AD, BC | |
2031
- * | | GGGG | Anno Domini, Before Christ | 2 |
2032
- * | | GGGGG | A, B | |
2033
- * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2034
- * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2035
- * | | yy | 44, 01, 00, 17 | 5 |
2036
- * | | yyy | 044, 001, 1900, 2017 | 5 |
2037
- * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2038
- * | | yyyyy | ... | 3,5 |
2039
- * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2040
- * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2041
- * | | YY | 44, 01, 00, 17 | 5,8 |
2042
- * | | YYY | 044, 001, 1900, 2017 | 5 |
2043
- * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2044
- * | | YYYYY | ... | 3,5 |
2045
- * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2046
- * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2047
- * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2048
- * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2049
- * | | RRRRR | ... | 3,5,7 |
2050
- * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2051
- * | | uu | -43, 01, 1900, 2017 | 5 |
2052
- * | | uuu | -043, 001, 1900, 2017 | 5 |
2053
- * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2054
- * | | uuuuu | ... | 3,5 |
2055
- * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2056
- * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2057
- * | | QQ | 01, 02, 03, 04 | |
2058
- * | | QQQ | Q1, Q2, Q3, Q4 | |
2059
- * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2060
- * | | QQQQQ | 1, 2, 3, 4 | 4 |
2061
- * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2062
- * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2063
- * | | qq | 01, 02, 03, 04 | |
2064
- * | | qqq | Q1, Q2, Q3, Q4 | |
2065
- * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2066
- * | | qqqqq | 1, 2, 3, 4 | 4 |
2067
- * | Month (formatting) | M | 1, 2, ..., 12 | |
2068
- * | | Mo | 1st, 2nd, ..., 12th | 7 |
2069
- * | | MM | 01, 02, ..., 12 | |
2070
- * | | MMM | Jan, Feb, ..., Dec | |
2071
- * | | MMMM | January, February, ..., December | 2 |
2072
- * | | MMMMM | J, F, ..., D | |
2073
- * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2074
- * | | Lo | 1st, 2nd, ..., 12th | 7 |
2075
- * | | LL | 01, 02, ..., 12 | |
2076
- * | | LLL | Jan, Feb, ..., Dec | |
2077
- * | | LLLL | January, February, ..., December | 2 |
2078
- * | | LLLLL | J, F, ..., D | |
2079
- * | Local week of year | w | 1, 2, ..., 53 | |
2080
- * | | wo | 1st, 2nd, ..., 53th | 7 |
2081
- * | | ww | 01, 02, ..., 53 | |
2082
- * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2083
- * | | Io | 1st, 2nd, ..., 53th | 7 |
2084
- * | | II | 01, 02, ..., 53 | 7 |
2085
- * | Day of month | d | 1, 2, ..., 31 | |
2086
- * | | do | 1st, 2nd, ..., 31st | 7 |
2087
- * | | dd | 01, 02, ..., 31 | |
2088
- * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2089
- * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2090
- * | | DD | 01, 02, ..., 365, 366 | 9 |
2091
- * | | DDD | 001, 002, ..., 365, 366 | |
2092
- * | | DDDD | ... | 3 |
2093
- * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2094
- * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2095
- * | | EEEEE | M, T, W, T, F, S, S | |
2096
- * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2097
- * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2098
- * | | io | 1st, 2nd, ..., 7th | 7 |
2099
- * | | ii | 01, 02, ..., 07 | 7 |
2100
- * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2101
- * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2102
- * | | iiiii | M, T, W, T, F, S, S | 7 |
2103
- * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2104
- * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2105
- * | | eo | 2nd, 3rd, ..., 1st | 7 |
2106
- * | | ee | 02, 03, ..., 01 | |
2107
- * | | eee | Mon, Tue, Wed, ..., Sun | |
2108
- * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2109
- * | | eeeee | M, T, W, T, F, S, S | |
2110
- * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2111
- * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2112
- * | | co | 2nd, 3rd, ..., 1st | 7 |
2113
- * | | cc | 02, 03, ..., 01 | |
2114
- * | | ccc | Mon, Tue, Wed, ..., Sun | |
2115
- * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2116
- * | | ccccc | M, T, W, T, F, S, S | |
2117
- * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2118
- * | AM, PM | a..aa | AM, PM | |
2119
- * | | aaa | am, pm | |
2120
- * | | aaaa | a.m., p.m. | 2 |
2121
- * | | aaaaa | a, p | |
2122
- * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2123
- * | | bbb | am, pm, noon, midnight | |
2124
- * | | bbbb | a.m., p.m., noon, midnight | 2 |
2125
- * | | bbbbb | a, p, n, mi | |
2126
- * | Flexible day period | B..BBB | at night, in the morning, ... | |
2127
- * | | BBBB | at night, in the morning, ... | 2 |
2128
- * | | BBBBB | at night, in the morning, ... | |
2129
- * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2130
- * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2131
- * | | hh | 01, 02, ..., 11, 12 | |
2132
- * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2133
- * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2134
- * | | HH | 00, 01, 02, ..., 23 | |
2135
- * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2136
- * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2137
- * | | KK | 01, 02, ..., 11, 00 | |
2138
- * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2139
- * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2140
- * | | kk | 24, 01, 02, ..., 23 | |
2141
- * | Minute | m | 0, 1, ..., 59 | |
2142
- * | | mo | 0th, 1st, ..., 59th | 7 |
2143
- * | | mm | 00, 01, ..., 59 | |
2144
- * | Second | s | 0, 1, ..., 59 | |
2145
- * | | so | 0th, 1st, ..., 59th | 7 |
2146
- * | | ss | 00, 01, ..., 59 | |
2147
- * | Fraction of second | S | 0, 1, ..., 9 | |
2148
- * | | SS | 00, 01, ..., 99 | |
2149
- * | | SSS | 000, 001, ..., 999 | |
2150
- * | | SSSS | ... | 3 |
2151
- * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2152
- * | | XX | -0800, +0530, Z | |
2153
- * | | XXX | -08:00, +05:30, Z | |
2154
- * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2155
- * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2156
- * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2157
- * | | xx | -0800, +0530, +0000 | |
2158
- * | | xxx | -08:00, +05:30, +00:00 | 2 |
2159
- * | | xxxx | -0800, +0530, +0000, +123456 | |
2160
- * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2161
- * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2162
- * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2163
- * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2164
- * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2165
- * | Seconds timestamp | t | 512969520 | 7 |
2166
- * | | tt | ... | 3,7 |
2167
- * | Milliseconds timestamp | T | 512969520900 | 7 |
2168
- * | | TT | ... | 3,7 |
2169
- * | Long localized date | P | 04/29/1453 | 7 |
2170
- * | | PP | Apr 29, 1453 | 7 |
2171
- * | | PPP | April 29th, 1453 | 7 |
2172
- * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2173
- * | Long localized time | p | 12:00 AM | 7 |
2174
- * | | pp | 12:00:00 AM | 7 |
2175
- * | | ppp | 12:00:00 AM GMT+2 | 7 |
2176
- * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2177
- * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2178
- * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2179
- * | | PPPppp | April 29th, 1453 at ... | 7 |
2180
- * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2181
- * Notes:
2182
- * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2183
- * are the same as "stand-alone" units, but are different in some languages.
2184
- * "Formatting" units are declined according to the rules of the language
2185
- * in the context of a date. "Stand-alone" units are always nominative singular:
2186
- *
2187
- * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2188
- *
2189
- * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2190
- *
2191
- * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2192
- * the single quote characters (see below).
2193
- * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2194
- * the output will be the same as default pattern for this unit, usually
2195
- * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2196
- * are marked with "2" in the last column of the table.
2197
- *
2198
- * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2199
- *
2200
- * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2201
- *
2202
- * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2203
- *
2204
- * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2205
- *
2206
- * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2207
- *
2208
- * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2209
- * The output will be padded with zeros to match the length of the pattern.
2210
- *
2211
- * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2212
- *
2213
- * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2214
- * These tokens represent the shortest form of the quarter.
2215
- *
2216
- * 5. The main difference between `y` and `u` patterns are B.C. years:
2217
- *
2218
- * | Year | `y` | `u` |
2219
- * |------|-----|-----|
2220
- * | AC 1 | 1 | 1 |
2221
- * | BC 1 | 1 | 0 |
2222
- * | BC 2 | 2 | -1 |
2223
- *
2224
- * Also `yy` always returns the last two digits of a year,
2225
- * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2226
- *
2227
- * | Year | `yy` | `uu` |
2228
- * |------|------|------|
2229
- * | 1 | 01 | 01 |
2230
- * | 14 | 14 | 14 |
2231
- * | 376 | 76 | 376 |
2232
- * | 1453 | 53 | 1453 |
2233
- *
2234
- * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2235
- * except local week-numbering years are dependent on `options.weekStartsOn`
2236
- * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2237
- * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2238
- *
2239
- * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2240
- * so right now these tokens fall back to GMT timezones.
2241
- *
2242
- * 7. These patterns are not in the Unicode Technical Standard #35:
2243
- * - `i`: ISO day of week
2244
- * - `I`: ISO week of year
2245
- * - `R`: ISO week-numbering year
2246
- * - `t`: seconds timestamp
2247
- * - `T`: milliseconds timestamp
2248
- * - `o`: ordinal number modifier
2249
- * - `P`: long localized date
2250
- * - `p`: long localized time
2251
- *
2252
- * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2253
- * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2254
- *
2255
- * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2256
- * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2257
- *
2258
- * @param {Date|Number} date - the original date
2259
- * @param {String} format - the string of tokens
2260
- * @param {Object} [options] - an object with options.
2261
- * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2262
- * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2263
- * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2264
- * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2265
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2266
- * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2267
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2268
- * @returns {String} the formatted date string
2269
- * @throws {TypeError} 2 arguments required
2270
- * @throws {RangeError} `date` must not be Invalid Date
2271
- * @throws {RangeError} `options.locale` must contain `localize` property
2272
- * @throws {RangeError} `options.locale` must contain `formatLong` property
2273
- * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2274
- * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2275
- * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2276
- * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2277
- * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2278
- * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2279
- * @throws {RangeError} format string contains an unescaped latin alphabet character
2280
- *
2281
- * @example
2282
- * // Represent 11 February 2014 in middle-endian format:
2283
- * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2284
- * //=> '02/11/2014'
2285
- *
2286
- * @example
2287
- * // Represent 2 July 2014 in Esperanto:
2288
- * import { eoLocale } from 'date-fns/locale/eo'
2289
- * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2290
- * locale: eoLocale
2291
- * })
2292
- * //=> '2-a de julio 2014'
2293
- *
2294
- * @example
2295
- * // Escape string by single quote characters:
2296
- * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2297
- * //=> "3 o'clock"
2298
- */
2299
-
2300
- function format(dirtyDate, dirtyFormatStr, options) {
2301
- var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
2302
-
2303
- requiredArgs(2, arguments);
2304
- var formatStr = String(dirtyFormatStr);
2305
- var defaultOptions = getDefaultOptions();
2306
- var locale$1 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : locale;
2307
- var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2308
-
2309
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2310
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2311
- }
2312
-
2313
- var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2314
-
2315
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2316
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2317
- }
2318
-
2319
- if (!locale$1.localize) {
2320
- throw new RangeError('locale must contain localize property');
2321
- }
2322
-
2323
- if (!locale$1.formatLong) {
2324
- throw new RangeError('locale must contain formatLong property');
2325
- }
2326
-
2327
- var originalDate = toDate(dirtyDate);
2328
-
2329
- if (!isValid(originalDate)) {
2330
- throw new RangeError('Invalid time value');
2331
- } // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2332
- // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2333
- // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2334
-
2335
-
2336
- var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2337
- var utcDate = subMilliseconds(originalDate, timezoneOffset);
2338
- var formatterOptions = {
2339
- firstWeekContainsDate: firstWeekContainsDate,
2340
- weekStartsOn: weekStartsOn,
2341
- locale: locale$1,
2342
- _originalDate: originalDate
2343
- };
2344
- var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2345
- var firstCharacter = substring[0];
2346
-
2347
- if (firstCharacter === 'p' || firstCharacter === 'P') {
2348
- var longFormatter = longFormatters[firstCharacter];
2349
- return longFormatter(substring, locale$1.formatLong);
2350
- }
2351
-
2352
- return substring;
2353
- }).join('').match(formattingTokensRegExp).map(function (substring) {
2354
- // Replace two single quote characters with one single quote character
2355
- if (substring === "''") {
2356
- return "'";
2357
- }
2358
-
2359
- var firstCharacter = substring[0];
2360
-
2361
- if (firstCharacter === "'") {
2362
- return cleanEscapedString(substring);
2363
- }
2364
-
2365
- var formatter = formatters[firstCharacter];
2366
-
2367
- if (formatter) {
2368
- if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2369
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2370
- }
2371
-
2372
- if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2373
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2374
- }
2375
-
2376
- return formatter(utcDate, substring, locale$1.localize, formatterOptions);
2377
- }
2378
-
2379
- if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2380
- throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2381
- }
2382
-
2383
- return substring;
2384
- }).join('');
2385
- return result;
2386
- }
2387
-
2388
- function cleanEscapedString(input) {
2389
- var matched = input.match(escapedStringRegExp);
2390
-
2391
- if (!matched) {
2392
- return input;
2393
- }
2394
-
2395
- return matched[1].replace(doubleQuoteRegExp, "'");
2396
- }
2397
-
2398
247
  function _typeof$v(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$v = function _typeof(obj) { return typeof obj; }; } else { _typeof$v = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$v(obj); }
2399
248
 
2400
249
  function _inherits$v(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$v(subClass, superClass); }
@@ -5676,187 +3525,5 @@ var TimestampMillisecondsParser = /*#__PURE__*/function (_Parser) {
5676
3525
  T: new TimestampMillisecondsParser()
5677
3526
  });
5678
3527
 
5679
- const VCDisplayFrontFace = ({
5680
- title,
5681
- createdAt,
5682
- issuer,
5683
- issuee,
5684
- subjectImageComponent,
5685
- issuerImageComponent,
5686
- hideProfileBubbles = false,
5687
- credentialSubject,
5688
- className = "",
5689
- loading,
5690
- handleClick,
5691
- overrideCardImageComponent,
5692
- overrideCardTitle,
5693
- customHeaderComponent
5694
- }) => {
5695
- var _a, _b, _c, _d, _e;
5696
- const credentialAchievementImage = ((_b = (_a = credentialSubject == null ? void 0 : credentialSubject.achievement) == null ? void 0 : _a.image) == null ? void 0 : _b.id) || ((_c = credentialSubject == null ? void 0 : credentialSubject.achievement) == null ? void 0 : _c.image);
5697
- const issuerName = VCDisplayBackFace.getNameFromProfile(issuer != null ? issuer : "");
5698
- const issueeName = VCDisplayBackFace.getNameFromProfile(issuee != null ? issuee : "");
5699
- const issuerImage = VCDisplayBackFace.getImageFromProfile(issuer != null ? issuer : "");
5700
- const issueeImage = VCDisplayBackFace.getImageFromProfile(issuee != null ? issuee : "");
5701
- const issuerNameAbr = (_d = issuerName == null ? void 0 : issuerName.slice(0, 1)) != null ? _d : "";
5702
- let issueeImageEl = null;
5703
- const issuerImgExists = issuerImage && issuerImage !== "";
5704
- const issueeImgExists = issueeImage && issueeImage !== "";
5705
- if (issueeImgExists) {
5706
- issueeImageEl = /* @__PURE__ */ React__default["default"].createElement("div", {
5707
- className: "flex flex-row items-center justify-center h-full w-full rounded-full border-solid border-4 border-white overflow-hidden bg-white"
5708
- }, /* @__PURE__ */ React__default["default"].createElement("img", {
5709
- className: "h-full w-full object-cover",
5710
- src: issueeImage || DefaultFace__default["default"],
5711
- alt: "Issuee image"
5712
- }));
5713
- } else if (!issueeImgExists && subjectImageComponent) {
5714
- issueeImageEl = subjectImageComponent;
5715
- }
5716
- let issuerImageEl = null;
5717
- if (issuerImgExists) {
5718
- issuerImageEl = /* @__PURE__ */ React__default["default"].createElement("img", {
5719
- className: "w-4/6 h-4/6 object-cover",
5720
- src: issuerImage,
5721
- alt: "Issuer image"
5722
- });
5723
- } else {
5724
- issuerImageEl = /* @__PURE__ */ React__default["default"].createElement("div", {
5725
- className: "flex flex-row items-center justify-center h-full w-full overflow-hidden bg-emerald-700 text-white font-medium text-3xl"
5726
- }, issuerNameAbr);
5727
- }
5728
- if (issuerImageComponent) {
5729
- issuerImageEl = issuerImageComponent;
5730
- }
5731
- const credImg = credentialAchievementImage ? /* @__PURE__ */ React__default["default"].createElement("img", {
5732
- className: "h-full w-full object-cover",
5733
- src: credentialAchievementImage != null ? credentialAchievementImage : "",
5734
- alt: "Credential Achievement Image"
5735
- }) : /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null);
5736
- const renderCardImg = overrideCardImageComponent ? overrideCardImageComponent : credImg;
5737
- const cardTitle = overrideCardTitle ? overrideCardTitle : title;
5738
- return /* @__PURE__ */ React__default["default"].createElement("div", {
5739
- className: `z-[9] vc-display-main-card-front flex overflow-hidden flex-col items-center justify-between relative max-w-[400px] h-[100%] max-h-[600px] min-h-[600px] p-7 rounded-3xl shadow-3xl bg-emerald-700 vc-display-card-full-container ${className}`
5740
- }, /* @__PURE__ */ React__default["default"].createElement("section", {
5741
- className: "bg-white rounded-bl-[50%] rounded-br-[50%] absolute top-0 w-[110%] h-[77%]"
5742
- }), /* @__PURE__ */ React__default["default"].createElement("section", {
5743
- className: "flex flex-col items-center justify-center z-10 text-center credential-thumb-img"
5744
- }, /* @__PURE__ */ React__default["default"].createElement("section", {
5745
- className: "max-w-[100px] max-h-[100px]"
5746
- }, renderCardImg), /* @__PURE__ */ React__default["default"].createElement("section", {
5747
- className: "flex flex-row w-full line-clamp-2"
5748
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
5749
- className: "flex flex-row w-full line-clamp-2 py-4 vc-flippy-card-title-front "
5750
- }, /* @__PURE__ */ React__default["default"].createElement("h3", {
5751
- className: "vc-thumbnail-title w-full text-2xl line-clamp-2 tracking-wide leading-snug text-center vc-display-title text-gray-900 font-medium",
5752
- "data-testid": "vc-thumbnail-title"
5753
- }, cardTitle != null ? cardTitle : "")), customHeaderComponent && customHeaderComponent), /* @__PURE__ */ React__default["default"].createElement("section", {
5754
- className: "flex flex-row items-center justify-center mt-2 w-full my-2 vc-card-issuer-thumbs"
5755
- }, !hideProfileBubbles && /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
5756
- className: "flex items-center justify-center h-16 w-16 shadow-3xl rounded-full overflow-hidden bg-white"
5757
- }, issuerImageEl), /* @__PURE__ */ React__default["default"].createElement("img", {
5758
- className: "h-8 w-8 my-0 mx-4",
5759
- src: (_e = FatArrow__default["default"]) != null ? _e : "",
5760
- alt: "fat arrow icon"
5761
- }), /* @__PURE__ */ React__default["default"].createElement("div", {
5762
- className: "flex items-center justify-center h-16 w-16 shadow-3xl rounded-full overflow-hidden bg-white"
5763
- }, issueeImageEl))), /* @__PURE__ */ React__default["default"].createElement("div", {
5764
- className: "w-full mt-2 vc-card-issued-to-info"
5765
- }, /* @__PURE__ */ React__default["default"].createElement("p", {
5766
- className: "text-sm font-light text-center line-clamp-2 vc-display-issue-details text-gray-900",
5767
- "data-testid": "vc-thumbnail-createdAt"
5768
- }, "Issued to ", /* @__PURE__ */ React__default["default"].createElement("span", {
5769
- className: "font-bold text-gray-900"
5770
- }, issueeName), " on", " ", createdAt != null ? createdAt : "", " by", " ", /* @__PURE__ */ React__default["default"].createElement("span", {
5771
- className: "font-bold text-gray-900"
5772
- }, " ", issuerName))), /* @__PURE__ */ React__default["default"].createElement("button", {
5773
- onClick: handleClick,
5774
- className: "cursor-alias bg-white my-3 border-0 text-indigo-500 font-semibold py-2 px-4 sl"
5775
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
5776
- className: "flex justify-center"
5777
- }, /* @__PURE__ */ React__default["default"].createElement("p", {
5778
- className: "flex items-center"
5779
- }, "View Details")))), /* @__PURE__ */ React__default["default"].createElement("div", {
5780
- className: "flex items-center justify-center w-full"
5781
- }, /* @__PURE__ */ React__default["default"].createElement(VCVerificationCheck.VCVerificationCheckWithText, {
5782
- loading
5783
- })));
5784
- };
5785
-
5786
- const FRONT_FACE = "front";
5787
- const BACK_FACE = "back";
5788
- const getInfoFromCredential = (credential) => {
5789
- var _a;
5790
- const { issuer, issuanceDate } = credential;
5791
- const credentialSubject = Array.isArray(credential.credentialSubject) ? credential.credentialSubject[0] : credential.credentialSubject;
5792
- const title = (_a = credentialSubject.achievement) == null ? void 0 : _a.name;
5793
- const createdAt = format(new Date(issuanceDate), "dd MMM yyyy").toUpperCase();
5794
- const issuee = credentialSubject.id;
5795
- return { title, createdAt, issuer, issuee, credentialSubject };
5796
- };
5797
- const VCDisplayCard = ({
5798
- credential,
5799
- issueeOverride,
5800
- issuerOverride,
5801
- className = "",
5802
- loading = false,
5803
- verification = [],
5804
- hideProfileBubbles = false,
5805
- subjectImageComponent,
5806
- issuerImageComponent,
5807
- overrideDetailsComponent,
5808
- overrideCardTitle,
5809
- overrideCardImageComponent,
5810
- customHeaderComponent
5811
- }) => {
5812
- const [flipState, setFlipState] = React.useState(FRONT_FACE);
5813
- const {
5814
- title,
5815
- createdAt,
5816
- issuer: _issuer,
5817
- issuee: _issuee,
5818
- credentialSubject
5819
- } = getInfoFromCredential(credential);
5820
- const issuee = issueeOverride || _issuee;
5821
- const issuer = issuerOverride || _issuer;
5822
- const handleFlip = () => {
5823
- if (flipState === FRONT_FACE) {
5824
- setFlipState(BACK_FACE);
5825
- }
5826
- if (flipState === BACK_FACE) {
5827
- setFlipState(FRONT_FACE);
5828
- }
5829
- };
5830
- return /* @__PURE__ */ React__default["default"].createElement(FlippyCard.FlippyCard, {
5831
- flipState
5832
- }, /* @__PURE__ */ React__default["default"].createElement(VCDisplayFrontFace, {
5833
- title,
5834
- credentialSubject,
5835
- customHeaderComponent,
5836
- issuer,
5837
- issuee,
5838
- subjectImageComponent,
5839
- issuerImageComponent,
5840
- overrideCardImageComponent,
5841
- overrideCardTitle,
5842
- hideProfileBubbles,
5843
- createdAt,
5844
- className,
5845
- loading,
5846
- handleClick: handleFlip
5847
- }), /* @__PURE__ */ React__default["default"].createElement(VCDisplayBackFace.VCDisplayBackFace, {
5848
- title,
5849
- credentialSubject,
5850
- overrideDetailsComponent,
5851
- issuer,
5852
- issuee,
5853
- createdAt,
5854
- className,
5855
- loading,
5856
- verification,
5857
- handleClick: handleFlip
5858
- }));
5859
- };
5860
-
5861
- exports.VCDisplayCard = VCDisplayCard;
5862
- //# sourceMappingURL=VCDisplayCard-2981600a.js.map
3528
+ export { toInteger as a, getUTCISOWeekYear as b, getUTCWeek as c, getUTCISOWeek as d, getDefaultOptions as e, getUTCWeekYear as g, requiredArgs as r, toDate as t };
3529
+ //# sourceMappingURL=index-e1f279c6.js.map