@learncard/react 2.3.52 → 2.3.55

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