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