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