@everymatrix/player-elevate-level 1.43.4 → 1.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/bonus-elevate-levels_8.cjs.entry.js +644 -674
  3. package/dist/cjs/index-91eb0bf0.js +1682 -0
  4. package/dist/cjs/loader.cjs.js +7 -13
  5. package/dist/cjs/{player-elevate-card-items-9e7a9a23.js → player-elevate-card-items-ae20c19f.js} +171 -285
  6. package/dist/cjs/player-elevate-card.cjs.entry.js +59 -70
  7. package/dist/cjs/player-elevate-level.cjs.js +17 -11
  8. package/dist/cjs/player-elevate-pointcard.cjs.entry.js +61 -77
  9. package/dist/collection/collection-manifest.json +3 -3
  10. package/dist/collection/components/player-elevate-level/index.js +1 -0
  11. package/dist/collection/components/player-elevate-level/player-elevate-level.js +208 -209
  12. package/dist/esm/app-globals-0f993ce5.js +3 -0
  13. package/dist/esm/bonus-elevate-levels_8.entry.js +644 -674
  14. package/dist/esm/index-32ed7fbd.js +1651 -0
  15. package/dist/esm/loader.js +7 -13
  16. package/dist/esm/{player-elevate-card-items-08ee8fab.js → player-elevate-card-items-2eccd763.js} +172 -285
  17. package/dist/esm/player-elevate-card.entry.js +59 -70
  18. package/dist/esm/player-elevate-level.js +14 -11
  19. package/dist/esm/player-elevate-pointcard.entry.js +61 -77
  20. package/dist/player-elevate-level/p-5f93600c.entry.js +1 -0
  21. package/dist/player-elevate-level/p-6d39391e.js +2 -0
  22. package/dist/player-elevate-level/p-73e5a291.entry.js +1 -0
  23. package/dist/player-elevate-level/p-a622755e.js +1 -0
  24. package/dist/player-elevate-level/p-acd808d7.entry.js +1 -0
  25. package/dist/player-elevate-level/p-e1255160.js +1 -0
  26. package/dist/player-elevate-level/player-elevate-level.esm.js +1 -1
  27. package/dist/stencil.config.dev.js +17 -0
  28. package/dist/stencil.config.js +14 -22
  29. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-elevate-level/.stencil/packages/stencil/player-elevate-level/stencil.config.d.ts +2 -0
  30. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-elevate-level/.stencil/packages/stencil/player-elevate-level/stencil.config.dev.d.ts +2 -0
  31. package/dist/types/components/player-elevate-level/index.d.ts +1 -0
  32. package/dist/types/components/player-elevate-level/player-elevate-level.d.ts +41 -41
  33. package/dist/types/stencil-public-runtime.d.ts +142 -33
  34. package/loader/cdn.js +1 -3
  35. package/loader/index.cjs.js +1 -3
  36. package/loader/index.d.ts +13 -1
  37. package/loader/index.es2017.js +1 -3
  38. package/loader/index.js +1 -3
  39. package/loader/package.json +1 -0
  40. package/package.json +12 -6
  41. package/dist/cjs/index-c706b0d2.js +0 -1726
  42. package/dist/components/bonus-elevate-levels.js +0 -6
  43. package/dist/components/bonus-elevate-levels2.js +0 -138
  44. package/dist/components/elevate-level-list.js +0 -6
  45. package/dist/components/elevate-level-list2.js +0 -198
  46. package/dist/components/elevate-level-presentation.js +0 -6
  47. package/dist/components/elevate-level-presentation2.js +0 -31
  48. package/dist/components/elevate-levels-data.js +0 -6
  49. package/dist/components/elevate-levels-data2.js +0 -102
  50. package/dist/components/general-styling-wrapper.js +0 -6
  51. package/dist/components/general-styling-wrapper2.js +0 -103
  52. package/dist/components/index.d.ts +0 -26
  53. package/dist/components/index.js +0 -1
  54. package/dist/components/player-elevate-card-data.js +0 -6
  55. package/dist/components/player-elevate-card-data2.js +0 -635
  56. package/dist/components/player-elevate-card-items.js +0 -2250
  57. package/dist/components/player-elevate-card.js +0 -126
  58. package/dist/components/player-elevate-level.d.ts +0 -11
  59. package/dist/components/player-elevate-level.js +0 -107
  60. package/dist/components/player-elevate-loyaltycard.js +0 -6
  61. package/dist/components/player-elevate-loyaltycard2.js +0 -129
  62. package/dist/components/player-elevate-pointcard.js +0 -135
  63. package/dist/esm/index-104132db.js +0 -1696
  64. package/dist/esm/polyfills/core-js.js +0 -11
  65. package/dist/esm/polyfills/css-shim.js +0 -1
  66. package/dist/esm/polyfills/dom.js +0 -79
  67. package/dist/esm/polyfills/es5-html-element.js +0 -1
  68. package/dist/esm/polyfills/index.js +0 -34
  69. package/dist/esm/polyfills/system.js +0 -6
  70. package/dist/player-elevate-level/p-04a5ef33.entry.js +0 -1
  71. package/dist/player-elevate-level/p-46fd6f51.js +0 -1
  72. package/dist/player-elevate-level/p-6766466f.js +0 -1
  73. package/dist/player-elevate-level/p-d5d234f8.entry.js +0 -1
  74. package/dist/player-elevate-level/p-d8ae2452.entry.js +0 -1
  75. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/player-elevate-level/.stencil/packages/player-elevate-level/stencil.config.d.ts +0 -2
@@ -1,2250 +0,0 @@
1
- import { h, getAssetPath } from '@stencil/core/internal/client';
2
- import { r as requiredArgs, _ as _typeof, t as toDate, g as getTimezoneOffsetInMilliseconds, a as translate } from './player-elevate-card-data2.js';
3
-
4
- const LoyaltyProgress = `<svg width="100%" height="28" style="opacity: 0" fill="none" xmlns="http://www.w3.org/2000/svg">
5
- <rect y="12" x="2" width="100%" id="total_level" height="5" rx="2.5" fill="white" fill-opacity="0.5"/>
6
- <rect y="12" x="2" id="current_level" width="64" height="5" rx="2.5" fill="white"/>
7
- <g filter="url(#filter_current_level)">
8
- <circle id="circle_current_level" cx="74.5" cy="14.5" r="6.5" fill="white"/>
9
- </g>
10
- <g filter="url(#filter_heart_ball)">
11
- <g filter="url(#filter_ball)">
12
- <circle cx="169" cy="14" r="10" id="lock" fill="url(#paint0_linear_ball)"/>
13
- </g>
14
- <g filter="url(#filter_heart)">
15
- <svg x="0" y="4" id="lock_box">
16
- <path d="M10.217 6.42442c-0.713,-0.574,-1.304,-1.083,-1.928,-1.622c-0.348,-0.299,-0.707,-0.611,-1.101,-0.943l-0.013,-0.01c0,0,-0.023,-0.017,-0.04,-0.027l-0.167,-0.095l-0.15,0.12c0,0,-0.015,0.012,-0.024,0.02c-0.391,0.33,-0.749,0.64,-1.094,0.939c-0.622,0.539,-1.211,1.048,-1.924,1.624c-1.816,1.463,-3.598,3.263,-3.033,5.506c0.404,1.601,2.104,2.905,3.789,2.905c0.211,0,0.423,-0.02,0.626,-0.061c0.286,-0.058,0.572,-0.145,0.864,-0.265c-0.079,0.962,-0.413,1.864,-0.881,2.369l-0.423,0.459h0.633c0.633,0,1.018,-0.007,1.356,-0.013c0.248,-0.004,0.462,-0.008,0.72,-0.008c0.335,0,0.709,0.006,1.215,0.021l0.686,0.02l-0.474,-0.483c-0.504,-0.514,-0.847,-1.403,-0.923,-2.385c0.311,0.132,0.616,0.227,0.916,0.287c0.204,0.039,0.411,0.059,0.623,0.059c1.687,0,3.386,-1.304,3.789,-2.909c0.56,-2.243,-1.224,-4.041,-3.042,-5.504v-0.004z" fill="#933CBF"/>
17
- <path d="M9.727,6.98459c-1.004,-0.83,-1.741,-1.515,-2.723,-2.365c-0.002,0,-0.004,-0.004,-0.007,-0.006c-0.002,0,-0.004,0.004,-0.006,0.006c-0.98,0.85,-1.715,1.537,-2.721,2.367c-1.455,1.202,-3.126,2.821,-2.638,4.81c0.37,1.511,2.091,2.751,3.665,2.43c0.389,-0.08,0.75,-0.224,1.094,-0.402c0,0.116,-0.004,0.233,-0.012,0.353c-0.064,0.991,-0.398,1.892,-0.86,2.401c1.481,0,1.481,-0.043,2.961,0c-0.481,-0.503,-0.834,-1.382,-0.9,-2.401c-0.008,-0.127,-0.012,-0.253,-0.012,-0.378c0.357,0.19,0.733,0.342,1.14,0.425c1.574,0.319,3.292,-0.922,3.661,-2.433c0.486,-1.992,-1.189,-3.609,-2.644,
18
- -4.809l0.002,0.002z" fill="url(#paint1_linear_lock)"/>
19
- <path d="M9.255,7.551c-0.844,-0.716,-1.462,-1.309,-2.286,-2.045c-0.002,0,-0.004,-0.004,-0.006,-0.006c0,0,-0.004,0.004,-0.006,0.006c-0.824,0.736,-1.44,1.329,-2.284,2.047c-0.919,0.782,-1.94,1.769,-2.214,2.943c-0.115,0.021,-0.914,0.044,-0.914,0.044l0.887,0.083c-0.039,0.206,-0.055,0.418,-0.041,0.638c0.087,-1.371,1.25,-2.507,2.282,-3.384c0.844,-0.718,1.462,-1.313,2.284,-2.047c0.002,-0.002,0.004,-0.004,0.006,-0.006c0.002,0,0.004,0.004,0.006,0.004c0.824,0.734,1.442,1.329,2.286,2.045c1.034,0.879,2.198,2.013,2.286,3.386c0.093,-1.517,-1.173,-2.761,-2.286,-3.708z" fill="#9040C9"/>
20
- </svg>
21
- </g>
22
- </g>
23
- <g filter="url(#filter_lock)">
24
- <svg x="100%" y="9" id="heart_box">
25
- <path d="M7,6c-0.19,-0.002,-0.377,0.052,-0.534,0.154c-0.158,0.103,-0.278,0.25,-0.346,0.42c-0.069,0.171,-0.081,0.357,-0.035,0.535c0.046,0.177,0.147,0.337,0.29,0.457v0.834c0,0.159,0.066,0.312,0.183,0.424c0.117,0.113,0.276,0.176,0.442,0.176c0.166,0,0.325,-0.063,0.442,-0.176c0.117,-0.112,0.183,-0.265,0.183,-0.424v-0.834c0.143,-0.12,0.244,-0.28,0.29,-0.457c0.046,-0.178,0.034,-0.364,-0.035,-0.535c-0.068,-0.17,-0.188,-0.317,-0.346,-0.42c-0.157,-0.102,-0.344,-0.156,-0.534,-0.154zm3.125,-2.4v-1.2c0,-0.796,-0.329,-1.559,-0.915,-2.121c-0.586,-0.563,-1.381,-0.879,-2.21,-0.879c-0.829,0,-1.624,0.316,-2.21,0.879c-0.586,0.562,-0.915,1.325,-0.915,2.121v1.2c-0.497,0,-0.974,0.19,-1.326,0.527c-0.351,0.338,-0.549,0.796,-0.549,1.273v4.2c0,0.477,0.198,0.935,0.549,1.273c0.352,0.337,0.829,0.527,1.326,0.527h6.25c0.497,0,0.974,-0.19,1.326,-0.527c0.351,-0.338,0.549,-0.796,0.549,-1.273v-4.2c0,-0.477,-0.198,-0.935,-0.549,-1.273c-0.352,-0.337,-0.829,-0.527,-1.326,-0.527zm-5,-1.2c0,-0.477,0.198,-0.935,0.549,-1.273c0.352,-0.337,0.829,-0.527,1.326,-0.527c0.497,0,0.974,0.19,1.326,0.527c0.351,0.338,0.549,0.796,0.549,1.273v1.2h-3.75v-1.2zm5.625,7.2c0,0.159,-0.066,0.312,-0.183,0.424c-0.117,0.113,-0.276,0.176,-0.442,0.176h-6.25c-0.166,0,-0.325,-0.063,-0.442,-0.176c-0.117,-0.112,-0.183,-0.265,-0.183,-0.424v-4.2c0,-0.159,0.066,-0.312,0.183,-0.424c0.117,-0.113,0.276,-0.176,0.442,-0.176h6.25c0.166,0,0.325,0.063,0.442,0.176c0.117,0.112,0.183,0.265,0.183,0.424v4.2z" fill="white"/>
26
- </svg>
27
- </g>
28
- <defs>
29
- <filter id="filter_current_level" x="64" y="4" width="21" height="21" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
30
- <feFlood flood-opacity="0" result="BackgroundImageFix"/>
31
- <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
32
- <feGaussianBlur stdDeviation="2" result="effect1_foregroundBlur_305_23"/>
33
- </filter>
34
- <filter id="filter_heart_ball" x="155" y="0" width="28" height="28" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
35
- <feFlood flood-opacity="0" result="BackgroundImageFix"/>
36
- <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
37
- <feOffset/>
38
- <feGaussianBlur stdDeviation="2"/>
39
- <feComposite in2="hardAlpha" operator="out"/>
40
- <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
41
- <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
42
- <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
43
- </filter>
44
- <filter id="filter_ball" x="159" y="4" width="20" height="21" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
45
- <feFlood flood-opacity="0" result="BackgroundImageFix"/>
46
- <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
47
- <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
48
- <feOffset dy="1"/>
49
- <feGaussianBlur stdDeviation="1"/>
50
- <feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
51
- <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0"/>
52
- <feBlend mode="normal" in2="shape" result="effect1_innerShadow_305_23"/>
53
- </filter>
54
- <filter id="filter_heart" x="161.636" y="5.72727" width="14.7271" height="15.6364" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
55
- <feFlood flood-opacity="0" result="BackgroundImageFix"/>
56
- <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
57
- <feOffset/>
58
- <feGaussianBlur stdDeviation="0.5"/>
59
- <feComposite in2="hardAlpha" operator="out"/>
60
- <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
61
- <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
62
- <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
63
- </filter>
64
- <filter id="filter_lock" x="50" y="7" width="12" height="14" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
65
- <feFlood flood-opacity="0" result="BackgroundImageFix"/>
66
- <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
67
- <feOffset/>
68
- <feGaussianBlur stdDeviation="0.5"/>
69
- <feComposite in2="hardAlpha" operator="out"/>
70
- <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
71
- <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
72
- <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
73
- </filter>
74
- <linearGradient id="paint0_linear_ball" x1="163" y1="6" x2="174.2" y2="22.6" gradientUnits="userSpaceOnUse">
75
- <stop stop-color="#946AD7"/>
76
- <stop offset="1" stop-color="#EFABEB"/>
77
- </linearGradient>
78
- <linearGradient id="paint1_linear_lock" x1="100%" y1="18.4056" x2="169.002" y2="10.2845" gradientUnits="userSpaceOnUse">
79
- <stop stop-color="#814FD6"/>
80
- <stop offset="1" stop-color="#D679D8"/>
81
- </linearGradient>
82
- </defs>
83
- </svg>
84
- `;
85
-
86
- /**
87
- * @name isDate
88
- * @category Common Helpers
89
- * @summary Is the given value a date?
90
- *
91
- * @description
92
- * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
93
- *
94
- * @param {*} value - the value to check
95
- * @returns {boolean} true if the given value is a date
96
- * @throws {TypeError} 1 arguments required
97
- *
98
- * @example
99
- * // For a valid date:
100
- * const result = isDate(new Date())
101
- * //=> true
102
- *
103
- * @example
104
- * // For an invalid date:
105
- * const result = isDate(new Date(NaN))
106
- * //=> true
107
- *
108
- * @example
109
- * // For some value:
110
- * const result = isDate('2014-02-31')
111
- * //=> false
112
- *
113
- * @example
114
- * // For an object:
115
- * const result = isDate({})
116
- * //=> false
117
- */
118
- function isDate(value) {
119
- requiredArgs(1, arguments);
120
- return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
121
- }
122
-
123
- /**
124
- * @name isValid
125
- * @category Common Helpers
126
- * @summary Is the given date valid?
127
- *
128
- * @description
129
- * Returns false if argument is Invalid Date and true otherwise.
130
- * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
131
- * Invalid Date is a Date, whose time value is NaN.
132
- *
133
- * Time value of Date: http://es5.github.io/#x15.9.1.1
134
- *
135
- * @param {*} date - the date to check
136
- * @returns {Boolean} the date is valid
137
- * @throws {TypeError} 1 argument required
138
- *
139
- * @example
140
- * // For the valid date:
141
- * const result = isValid(new Date(2014, 1, 31))
142
- * //=> true
143
- *
144
- * @example
145
- * // For the value, convertable into a date:
146
- * const result = isValid(1393804800000)
147
- * //=> true
148
- *
149
- * @example
150
- * // For the invalid date:
151
- * const result = isValid(new Date(''))
152
- * //=> false
153
- */
154
- function isValid(dirtyDate) {
155
- requiredArgs(1, arguments);
156
- if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
157
- return false;
158
- }
159
- var date = toDate(dirtyDate);
160
- return !isNaN(Number(date));
161
- }
162
-
163
- function toInteger(dirtyNumber) {
164
- if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
165
- return NaN;
166
- }
167
- var number = Number(dirtyNumber);
168
- if (isNaN(number)) {
169
- return number;
170
- }
171
- return number < 0 ? Math.ceil(number) : Math.floor(number);
172
- }
173
-
174
- /**
175
- * @name addMilliseconds
176
- * @category Millisecond Helpers
177
- * @summary Add the specified number of milliseconds to the given date.
178
- *
179
- * @description
180
- * Add the specified number of milliseconds to the given date.
181
- *
182
- * @param {Date|Number} date - the date to be changed
183
- * @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`.
184
- * @returns {Date} the new date with the milliseconds added
185
- * @throws {TypeError} 2 arguments required
186
- *
187
- * @example
188
- * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
189
- * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
190
- * //=> Thu Jul 10 2014 12:45:30.750
191
- */
192
- function addMilliseconds(dirtyDate, dirtyAmount) {
193
- requiredArgs(2, arguments);
194
- var timestamp = toDate(dirtyDate).getTime();
195
- var amount = toInteger(dirtyAmount);
196
- return new Date(timestamp + amount);
197
- }
198
-
199
- /**
200
- * @name subMilliseconds
201
- * @category Millisecond Helpers
202
- * @summary Subtract the specified number of milliseconds from the given date.
203
- *
204
- * @description
205
- * Subtract the specified number of milliseconds from the given date.
206
- *
207
- * @param {Date|Number} date - the date to be changed
208
- * @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`.
209
- * @returns {Date} the new date with the milliseconds subtracted
210
- * @throws {TypeError} 2 arguments required
211
- *
212
- * @example
213
- * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
214
- * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
215
- * //=> Thu Jul 10 2014 12:45:29.250
216
- */
217
- function subMilliseconds(dirtyDate, dirtyAmount) {
218
- requiredArgs(2, arguments);
219
- var amount = toInteger(dirtyAmount);
220
- return addMilliseconds(dirtyDate, -amount);
221
- }
222
-
223
- var MILLISECONDS_IN_DAY = 86400000;
224
- function getUTCDayOfYear(dirtyDate) {
225
- requiredArgs(1, arguments);
226
- var date = toDate(dirtyDate);
227
- var timestamp = date.getTime();
228
- date.setUTCMonth(0, 1);
229
- date.setUTCHours(0, 0, 0, 0);
230
- var startOfYearTimestamp = date.getTime();
231
- var difference = timestamp - startOfYearTimestamp;
232
- return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
233
- }
234
-
235
- function startOfUTCISOWeek(dirtyDate) {
236
- requiredArgs(1, arguments);
237
- var weekStartsOn = 1;
238
- var date = toDate(dirtyDate);
239
- var day = date.getUTCDay();
240
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
241
- date.setUTCDate(date.getUTCDate() - diff);
242
- date.setUTCHours(0, 0, 0, 0);
243
- return date;
244
- }
245
-
246
- function getUTCISOWeekYear(dirtyDate) {
247
- requiredArgs(1, arguments);
248
- var date = toDate(dirtyDate);
249
- var year = date.getUTCFullYear();
250
- var fourthOfJanuaryOfNextYear = new Date(0);
251
- fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
252
- fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
253
- var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
254
- var fourthOfJanuaryOfThisYear = new Date(0);
255
- fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
256
- fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
257
- var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
258
- if (date.getTime() >= startOfNextYear.getTime()) {
259
- return year + 1;
260
- } else if (date.getTime() >= startOfThisYear.getTime()) {
261
- return year;
262
- } else {
263
- return year - 1;
264
- }
265
- }
266
-
267
- function startOfUTCISOWeekYear(dirtyDate) {
268
- requiredArgs(1, arguments);
269
- var year = getUTCISOWeekYear(dirtyDate);
270
- var fourthOfJanuary = new Date(0);
271
- fourthOfJanuary.setUTCFullYear(year, 0, 4);
272
- fourthOfJanuary.setUTCHours(0, 0, 0, 0);
273
- var date = startOfUTCISOWeek(fourthOfJanuary);
274
- return date;
275
- }
276
-
277
- var MILLISECONDS_IN_WEEK$1 = 604800000;
278
- function getUTCISOWeek(dirtyDate) {
279
- requiredArgs(1, arguments);
280
- var date = toDate(dirtyDate);
281
- var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
282
-
283
- // Round the number of days to the nearest integer
284
- // because the number of milliseconds in a week is not constant
285
- // (e.g. it's different in the week of the daylight saving time clock shift)
286
- return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
287
- }
288
-
289
- var defaultOptions = {};
290
- function getDefaultOptions() {
291
- return defaultOptions;
292
- }
293
-
294
- function startOfUTCWeek(dirtyDate, options) {
295
- var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
296
- requiredArgs(1, arguments);
297
- var defaultOptions = getDefaultOptions();
298
- var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
299
-
300
- // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
301
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
302
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
303
- }
304
- var date = toDate(dirtyDate);
305
- var day = date.getUTCDay();
306
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
307
- date.setUTCDate(date.getUTCDate() - diff);
308
- date.setUTCHours(0, 0, 0, 0);
309
- return date;
310
- }
311
-
312
- function getUTCWeekYear(dirtyDate, options) {
313
- var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
314
- requiredArgs(1, arguments);
315
- var date = toDate(dirtyDate);
316
- var year = date.getUTCFullYear();
317
- var defaultOptions = getDefaultOptions();
318
- var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
319
-
320
- // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
321
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
322
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
323
- }
324
- var firstWeekOfNextYear = new Date(0);
325
- firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
326
- firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
327
- var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
328
- var firstWeekOfThisYear = new Date(0);
329
- firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
330
- firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
331
- var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
332
- if (date.getTime() >= startOfNextYear.getTime()) {
333
- return year + 1;
334
- } else if (date.getTime() >= startOfThisYear.getTime()) {
335
- return year;
336
- } else {
337
- return year - 1;
338
- }
339
- }
340
-
341
- function startOfUTCWeekYear(dirtyDate, options) {
342
- var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
343
- requiredArgs(1, arguments);
344
- var defaultOptions = getDefaultOptions();
345
- var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
346
- var year = getUTCWeekYear(dirtyDate, options);
347
- var firstWeek = new Date(0);
348
- firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
349
- firstWeek.setUTCHours(0, 0, 0, 0);
350
- var date = startOfUTCWeek(firstWeek, options);
351
- return date;
352
- }
353
-
354
- var MILLISECONDS_IN_WEEK = 604800000;
355
- function getUTCWeek(dirtyDate, options) {
356
- requiredArgs(1, arguments);
357
- var date = toDate(dirtyDate);
358
- var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
359
-
360
- // Round the number of days to the nearest integer
361
- // because the number of milliseconds in a week is not constant
362
- // (e.g. it's different in the week of the daylight saving time clock shift)
363
- return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
364
- }
365
-
366
- function addLeadingZeros(number, targetLength) {
367
- var sign = number < 0 ? '-' : '';
368
- var output = Math.abs(number).toString();
369
- while (output.length < targetLength) {
370
- output = '0' + output;
371
- }
372
- return sign + output;
373
- }
374
-
375
- /*
376
- * | | Unit | | Unit |
377
- * |-----|--------------------------------|-----|--------------------------------|
378
- * | a | AM, PM | A* | |
379
- * | d | Day of month | D | |
380
- * | h | Hour [1-12] | H | Hour [0-23] |
381
- * | m | Minute | M | Month |
382
- * | s | Second | S | Fraction of second |
383
- * | y | Year (abs) | Y | |
384
- *
385
- * Letters marked by * are not implemented but reserved by Unicode standard.
386
- */
387
- var formatters$1 = {
388
- // Year
389
- y: function y(date, token) {
390
- // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
391
- // | Year | y | yy | yyy | yyyy | yyyyy |
392
- // |----------|-------|----|-------|-------|-------|
393
- // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
394
- // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
395
- // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
396
- // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
397
- // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
398
-
399
- var signedYear = date.getUTCFullYear();
400
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
401
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
402
- return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
403
- },
404
- // Month
405
- M: function M(date, token) {
406
- var month = date.getUTCMonth();
407
- return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
408
- },
409
- // Day of the month
410
- d: function d(date, token) {
411
- return addLeadingZeros(date.getUTCDate(), token.length);
412
- },
413
- // AM or PM
414
- a: function a(date, token) {
415
- var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
416
- switch (token) {
417
- case 'a':
418
- case 'aa':
419
- return dayPeriodEnumValue.toUpperCase();
420
- case 'aaa':
421
- return dayPeriodEnumValue;
422
- case 'aaaaa':
423
- return dayPeriodEnumValue[0];
424
- case 'aaaa':
425
- default:
426
- return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
427
- }
428
- },
429
- // Hour [1-12]
430
- h: function h(date, token) {
431
- return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
432
- },
433
- // Hour [0-23]
434
- H: function H(date, token) {
435
- return addLeadingZeros(date.getUTCHours(), token.length);
436
- },
437
- // Minute
438
- m: function m(date, token) {
439
- return addLeadingZeros(date.getUTCMinutes(), token.length);
440
- },
441
- // Second
442
- s: function s(date, token) {
443
- return addLeadingZeros(date.getUTCSeconds(), token.length);
444
- },
445
- // Fraction of second
446
- S: function S(date, token) {
447
- var numberOfDigits = token.length;
448
- var milliseconds = date.getUTCMilliseconds();
449
- var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
450
- return addLeadingZeros(fractionalSeconds, token.length);
451
- }
452
- };
453
-
454
- var dayPeriodEnum = {
455
- am: 'am',
456
- pm: 'pm',
457
- midnight: 'midnight',
458
- noon: 'noon',
459
- morning: 'morning',
460
- afternoon: 'afternoon',
461
- evening: 'evening',
462
- night: 'night'
463
- };
464
- /*
465
- * | | Unit | | Unit |
466
- * |-----|--------------------------------|-----|--------------------------------|
467
- * | a | AM, PM | A* | Milliseconds in day |
468
- * | b | AM, PM, noon, midnight | B | Flexible day period |
469
- * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
470
- * | d | Day of month | D | Day of year |
471
- * | e | Local day of week | E | Day of week |
472
- * | f | | F* | Day of week in month |
473
- * | g* | Modified Julian day | G | Era |
474
- * | h | Hour [1-12] | H | Hour [0-23] |
475
- * | i! | ISO day of week | I! | ISO week of year |
476
- * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
477
- * | k | Hour [1-24] | K | Hour [0-11] |
478
- * | l* | (deprecated) | L | Stand-alone month |
479
- * | m | Minute | M | Month |
480
- * | n | | N | |
481
- * | o! | Ordinal number modifier | O | Timezone (GMT) |
482
- * | p! | Long localized time | P! | Long localized date |
483
- * | q | Stand-alone quarter | Q | Quarter |
484
- * | r* | Related Gregorian year | R! | ISO week-numbering year |
485
- * | s | Second | S | Fraction of second |
486
- * | t! | Seconds timestamp | T! | Milliseconds timestamp |
487
- * | u | Extended year | U* | Cyclic year |
488
- * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
489
- * | w | Local week of year | W* | Week of month |
490
- * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
491
- * | y | Year (abs) | Y | Local week-numbering year |
492
- * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
493
- *
494
- * Letters marked by * are not implemented but reserved by Unicode standard.
495
- *
496
- * Letters marked by ! are non-standard, but implemented by date-fns:
497
- * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
498
- * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
499
- * i.e. 7 for Sunday, 1 for Monday, etc.
500
- * - `I` is ISO week of year, as opposed to `w` which is local week of year.
501
- * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
502
- * `R` is supposed to be used in conjunction with `I` and `i`
503
- * for universal ISO week-numbering date, whereas
504
- * `Y` is supposed to be used in conjunction with `w` and `e`
505
- * for week-numbering date specific to the locale.
506
- * - `P` is long localized date format
507
- * - `p` is long localized time format
508
- */
509
-
510
- var formatters = {
511
- // Era
512
- G: function G(date, token, localize) {
513
- var era = date.getUTCFullYear() > 0 ? 1 : 0;
514
- switch (token) {
515
- // AD, BC
516
- case 'G':
517
- case 'GG':
518
- case 'GGG':
519
- return localize.era(era, {
520
- width: 'abbreviated'
521
- });
522
- // A, B
523
- case 'GGGGG':
524
- return localize.era(era, {
525
- width: 'narrow'
526
- });
527
- // Anno Domini, Before Christ
528
- case 'GGGG':
529
- default:
530
- return localize.era(era, {
531
- width: 'wide'
532
- });
533
- }
534
- },
535
- // Year
536
- y: function y(date, token, localize) {
537
- // Ordinal number
538
- if (token === 'yo') {
539
- var signedYear = date.getUTCFullYear();
540
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
541
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
542
- return localize.ordinalNumber(year, {
543
- unit: 'year'
544
- });
545
- }
546
- return formatters$1.y(date, token);
547
- },
548
- // Local week-numbering year
549
- Y: function Y(date, token, localize, options) {
550
- var signedWeekYear = getUTCWeekYear(date, options);
551
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
552
- var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
553
-
554
- // Two digit year
555
- if (token === 'YY') {
556
- var twoDigitYear = weekYear % 100;
557
- return addLeadingZeros(twoDigitYear, 2);
558
- }
559
-
560
- // Ordinal number
561
- if (token === 'Yo') {
562
- return localize.ordinalNumber(weekYear, {
563
- unit: 'year'
564
- });
565
- }
566
-
567
- // Padding
568
- return addLeadingZeros(weekYear, token.length);
569
- },
570
- // ISO week-numbering year
571
- R: function R(date, token) {
572
- var isoWeekYear = getUTCISOWeekYear(date);
573
-
574
- // Padding
575
- return addLeadingZeros(isoWeekYear, token.length);
576
- },
577
- // Extended year. This is a single number designating the year of this calendar system.
578
- // The main difference between `y` and `u` localizers are B.C. years:
579
- // | Year | `y` | `u` |
580
- // |------|-----|-----|
581
- // | AC 1 | 1 | 1 |
582
- // | BC 1 | 1 | 0 |
583
- // | BC 2 | 2 | -1 |
584
- // Also `yy` always returns the last two digits of a year,
585
- // while `uu` pads single digit years to 2 characters and returns other years unchanged.
586
- u: function u(date, token) {
587
- var year = date.getUTCFullYear();
588
- return addLeadingZeros(year, token.length);
589
- },
590
- // Quarter
591
- Q: function Q(date, token, localize) {
592
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
593
- switch (token) {
594
- // 1, 2, 3, 4
595
- case 'Q':
596
- return String(quarter);
597
- // 01, 02, 03, 04
598
- case 'QQ':
599
- return addLeadingZeros(quarter, 2);
600
- // 1st, 2nd, 3rd, 4th
601
- case 'Qo':
602
- return localize.ordinalNumber(quarter, {
603
- unit: 'quarter'
604
- });
605
- // Q1, Q2, Q3, Q4
606
- case 'QQQ':
607
- return localize.quarter(quarter, {
608
- width: 'abbreviated',
609
- context: 'formatting'
610
- });
611
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
612
- case 'QQQQQ':
613
- return localize.quarter(quarter, {
614
- width: 'narrow',
615
- context: 'formatting'
616
- });
617
- // 1st quarter, 2nd quarter, ...
618
- case 'QQQQ':
619
- default:
620
- return localize.quarter(quarter, {
621
- width: 'wide',
622
- context: 'formatting'
623
- });
624
- }
625
- },
626
- // Stand-alone quarter
627
- q: function q(date, token, localize) {
628
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
629
- switch (token) {
630
- // 1, 2, 3, 4
631
- case 'q':
632
- return String(quarter);
633
- // 01, 02, 03, 04
634
- case 'qq':
635
- return addLeadingZeros(quarter, 2);
636
- // 1st, 2nd, 3rd, 4th
637
- case 'qo':
638
- return localize.ordinalNumber(quarter, {
639
- unit: 'quarter'
640
- });
641
- // Q1, Q2, Q3, Q4
642
- case 'qqq':
643
- return localize.quarter(quarter, {
644
- width: 'abbreviated',
645
- context: 'standalone'
646
- });
647
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
648
- case 'qqqqq':
649
- return localize.quarter(quarter, {
650
- width: 'narrow',
651
- context: 'standalone'
652
- });
653
- // 1st quarter, 2nd quarter, ...
654
- case 'qqqq':
655
- default:
656
- return localize.quarter(quarter, {
657
- width: 'wide',
658
- context: 'standalone'
659
- });
660
- }
661
- },
662
- // Month
663
- M: function M(date, token, localize) {
664
- var month = date.getUTCMonth();
665
- switch (token) {
666
- case 'M':
667
- case 'MM':
668
- return formatters$1.M(date, token);
669
- // 1st, 2nd, ..., 12th
670
- case 'Mo':
671
- return localize.ordinalNumber(month + 1, {
672
- unit: 'month'
673
- });
674
- // Jan, Feb, ..., Dec
675
- case 'MMM':
676
- return localize.month(month, {
677
- width: 'abbreviated',
678
- context: 'formatting'
679
- });
680
- // J, F, ..., D
681
- case 'MMMMM':
682
- return localize.month(month, {
683
- width: 'narrow',
684
- context: 'formatting'
685
- });
686
- // January, February, ..., December
687
- case 'MMMM':
688
- default:
689
- return localize.month(month, {
690
- width: 'wide',
691
- context: 'formatting'
692
- });
693
- }
694
- },
695
- // Stand-alone month
696
- L: function L(date, token, localize) {
697
- var month = date.getUTCMonth();
698
- switch (token) {
699
- // 1, 2, ..., 12
700
- case 'L':
701
- return String(month + 1);
702
- // 01, 02, ..., 12
703
- case 'LL':
704
- return addLeadingZeros(month + 1, 2);
705
- // 1st, 2nd, ..., 12th
706
- case 'Lo':
707
- return localize.ordinalNumber(month + 1, {
708
- unit: 'month'
709
- });
710
- // Jan, Feb, ..., Dec
711
- case 'LLL':
712
- return localize.month(month, {
713
- width: 'abbreviated',
714
- context: 'standalone'
715
- });
716
- // J, F, ..., D
717
- case 'LLLLL':
718
- return localize.month(month, {
719
- width: 'narrow',
720
- context: 'standalone'
721
- });
722
- // January, February, ..., December
723
- case 'LLLL':
724
- default:
725
- return localize.month(month, {
726
- width: 'wide',
727
- context: 'standalone'
728
- });
729
- }
730
- },
731
- // Local week of year
732
- w: function w(date, token, localize, options) {
733
- var week = getUTCWeek(date, options);
734
- if (token === 'wo') {
735
- return localize.ordinalNumber(week, {
736
- unit: 'week'
737
- });
738
- }
739
- return addLeadingZeros(week, token.length);
740
- },
741
- // ISO week of year
742
- I: function I(date, token, localize) {
743
- var isoWeek = getUTCISOWeek(date);
744
- if (token === 'Io') {
745
- return localize.ordinalNumber(isoWeek, {
746
- unit: 'week'
747
- });
748
- }
749
- return addLeadingZeros(isoWeek, token.length);
750
- },
751
- // Day of the month
752
- d: function d(date, token, localize) {
753
- if (token === 'do') {
754
- return localize.ordinalNumber(date.getUTCDate(), {
755
- unit: 'date'
756
- });
757
- }
758
- return formatters$1.d(date, token);
759
- },
760
- // Day of year
761
- D: function D(date, token, localize) {
762
- var dayOfYear = getUTCDayOfYear(date);
763
- if (token === 'Do') {
764
- return localize.ordinalNumber(dayOfYear, {
765
- unit: 'dayOfYear'
766
- });
767
- }
768
- return addLeadingZeros(dayOfYear, token.length);
769
- },
770
- // Day of week
771
- E: function E(date, token, localize) {
772
- var dayOfWeek = date.getUTCDay();
773
- switch (token) {
774
- // Tue
775
- case 'E':
776
- case 'EE':
777
- case 'EEE':
778
- return localize.day(dayOfWeek, {
779
- width: 'abbreviated',
780
- context: 'formatting'
781
- });
782
- // T
783
- case 'EEEEE':
784
- return localize.day(dayOfWeek, {
785
- width: 'narrow',
786
- context: 'formatting'
787
- });
788
- // Tu
789
- case 'EEEEEE':
790
- return localize.day(dayOfWeek, {
791
- width: 'short',
792
- context: 'formatting'
793
- });
794
- // Tuesday
795
- case 'EEEE':
796
- default:
797
- return localize.day(dayOfWeek, {
798
- width: 'wide',
799
- context: 'formatting'
800
- });
801
- }
802
- },
803
- // Local day of week
804
- e: function e(date, token, localize, options) {
805
- var dayOfWeek = date.getUTCDay();
806
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
807
- switch (token) {
808
- // Numerical value (Nth day of week with current locale or weekStartsOn)
809
- case 'e':
810
- return String(localDayOfWeek);
811
- // Padded numerical value
812
- case 'ee':
813
- return addLeadingZeros(localDayOfWeek, 2);
814
- // 1st, 2nd, ..., 7th
815
- case 'eo':
816
- return localize.ordinalNumber(localDayOfWeek, {
817
- unit: 'day'
818
- });
819
- case 'eee':
820
- return localize.day(dayOfWeek, {
821
- width: 'abbreviated',
822
- context: 'formatting'
823
- });
824
- // T
825
- case 'eeeee':
826
- return localize.day(dayOfWeek, {
827
- width: 'narrow',
828
- context: 'formatting'
829
- });
830
- // Tu
831
- case 'eeeeee':
832
- return localize.day(dayOfWeek, {
833
- width: 'short',
834
- context: 'formatting'
835
- });
836
- // Tuesday
837
- case 'eeee':
838
- default:
839
- return localize.day(dayOfWeek, {
840
- width: 'wide',
841
- context: 'formatting'
842
- });
843
- }
844
- },
845
- // Stand-alone local day of week
846
- c: function c(date, token, localize, options) {
847
- var dayOfWeek = date.getUTCDay();
848
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
849
- switch (token) {
850
- // Numerical value (same as in `e`)
851
- case 'c':
852
- return String(localDayOfWeek);
853
- // Padded numerical value
854
- case 'cc':
855
- return addLeadingZeros(localDayOfWeek, token.length);
856
- // 1st, 2nd, ..., 7th
857
- case 'co':
858
- return localize.ordinalNumber(localDayOfWeek, {
859
- unit: 'day'
860
- });
861
- case 'ccc':
862
- return localize.day(dayOfWeek, {
863
- width: 'abbreviated',
864
- context: 'standalone'
865
- });
866
- // T
867
- case 'ccccc':
868
- return localize.day(dayOfWeek, {
869
- width: 'narrow',
870
- context: 'standalone'
871
- });
872
- // Tu
873
- case 'cccccc':
874
- return localize.day(dayOfWeek, {
875
- width: 'short',
876
- context: 'standalone'
877
- });
878
- // Tuesday
879
- case 'cccc':
880
- default:
881
- return localize.day(dayOfWeek, {
882
- width: 'wide',
883
- context: 'standalone'
884
- });
885
- }
886
- },
887
- // ISO day of week
888
- i: function i(date, token, localize) {
889
- var dayOfWeek = date.getUTCDay();
890
- var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
891
- switch (token) {
892
- // 2
893
- case 'i':
894
- return String(isoDayOfWeek);
895
- // 02
896
- case 'ii':
897
- return addLeadingZeros(isoDayOfWeek, token.length);
898
- // 2nd
899
- case 'io':
900
- return localize.ordinalNumber(isoDayOfWeek, {
901
- unit: 'day'
902
- });
903
- // Tue
904
- case 'iii':
905
- return localize.day(dayOfWeek, {
906
- width: 'abbreviated',
907
- context: 'formatting'
908
- });
909
- // T
910
- case 'iiiii':
911
- return localize.day(dayOfWeek, {
912
- width: 'narrow',
913
- context: 'formatting'
914
- });
915
- // Tu
916
- case 'iiiiii':
917
- return localize.day(dayOfWeek, {
918
- width: 'short',
919
- context: 'formatting'
920
- });
921
- // Tuesday
922
- case 'iiii':
923
- default:
924
- return localize.day(dayOfWeek, {
925
- width: 'wide',
926
- context: 'formatting'
927
- });
928
- }
929
- },
930
- // AM or PM
931
- a: function a(date, token, localize) {
932
- var hours = date.getUTCHours();
933
- var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
934
- switch (token) {
935
- case 'a':
936
- case 'aa':
937
- return localize.dayPeriod(dayPeriodEnumValue, {
938
- width: 'abbreviated',
939
- context: 'formatting'
940
- });
941
- case 'aaa':
942
- return localize.dayPeriod(dayPeriodEnumValue, {
943
- width: 'abbreviated',
944
- context: 'formatting'
945
- }).toLowerCase();
946
- case 'aaaaa':
947
- return localize.dayPeriod(dayPeriodEnumValue, {
948
- width: 'narrow',
949
- context: 'formatting'
950
- });
951
- case 'aaaa':
952
- default:
953
- return localize.dayPeriod(dayPeriodEnumValue, {
954
- width: 'wide',
955
- context: 'formatting'
956
- });
957
- }
958
- },
959
- // AM, PM, midnight, noon
960
- b: function b(date, token, localize) {
961
- var hours = date.getUTCHours();
962
- var dayPeriodEnumValue;
963
- if (hours === 12) {
964
- dayPeriodEnumValue = dayPeriodEnum.noon;
965
- } else if (hours === 0) {
966
- dayPeriodEnumValue = dayPeriodEnum.midnight;
967
- } else {
968
- dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
969
- }
970
- switch (token) {
971
- case 'b':
972
- case 'bb':
973
- return localize.dayPeriod(dayPeriodEnumValue, {
974
- width: 'abbreviated',
975
- context: 'formatting'
976
- });
977
- case 'bbb':
978
- return localize.dayPeriod(dayPeriodEnumValue, {
979
- width: 'abbreviated',
980
- context: 'formatting'
981
- }).toLowerCase();
982
- case 'bbbbb':
983
- return localize.dayPeriod(dayPeriodEnumValue, {
984
- width: 'narrow',
985
- context: 'formatting'
986
- });
987
- case 'bbbb':
988
- default:
989
- return localize.dayPeriod(dayPeriodEnumValue, {
990
- width: 'wide',
991
- context: 'formatting'
992
- });
993
- }
994
- },
995
- // in the morning, in the afternoon, in the evening, at night
996
- B: function B(date, token, localize) {
997
- var hours = date.getUTCHours();
998
- var dayPeriodEnumValue;
999
- if (hours >= 17) {
1000
- dayPeriodEnumValue = dayPeriodEnum.evening;
1001
- } else if (hours >= 12) {
1002
- dayPeriodEnumValue = dayPeriodEnum.afternoon;
1003
- } else if (hours >= 4) {
1004
- dayPeriodEnumValue = dayPeriodEnum.morning;
1005
- } else {
1006
- dayPeriodEnumValue = dayPeriodEnum.night;
1007
- }
1008
- switch (token) {
1009
- case 'B':
1010
- case 'BB':
1011
- case 'BBB':
1012
- return localize.dayPeriod(dayPeriodEnumValue, {
1013
- width: 'abbreviated',
1014
- context: 'formatting'
1015
- });
1016
- case 'BBBBB':
1017
- return localize.dayPeriod(dayPeriodEnumValue, {
1018
- width: 'narrow',
1019
- context: 'formatting'
1020
- });
1021
- case 'BBBB':
1022
- default:
1023
- return localize.dayPeriod(dayPeriodEnumValue, {
1024
- width: 'wide',
1025
- context: 'formatting'
1026
- });
1027
- }
1028
- },
1029
- // Hour [1-12]
1030
- h: function h(date, token, localize) {
1031
- if (token === 'ho') {
1032
- var hours = date.getUTCHours() % 12;
1033
- if (hours === 0) hours = 12;
1034
- return localize.ordinalNumber(hours, {
1035
- unit: 'hour'
1036
- });
1037
- }
1038
- return formatters$1.h(date, token);
1039
- },
1040
- // Hour [0-23]
1041
- H: function H(date, token, localize) {
1042
- if (token === 'Ho') {
1043
- return localize.ordinalNumber(date.getUTCHours(), {
1044
- unit: 'hour'
1045
- });
1046
- }
1047
- return formatters$1.H(date, token);
1048
- },
1049
- // Hour [0-11]
1050
- K: function K(date, token, localize) {
1051
- var hours = date.getUTCHours() % 12;
1052
- if (token === 'Ko') {
1053
- return localize.ordinalNumber(hours, {
1054
- unit: 'hour'
1055
- });
1056
- }
1057
- return addLeadingZeros(hours, token.length);
1058
- },
1059
- // Hour [1-24]
1060
- k: function k(date, token, localize) {
1061
- var hours = date.getUTCHours();
1062
- if (hours === 0) hours = 24;
1063
- if (token === 'ko') {
1064
- return localize.ordinalNumber(hours, {
1065
- unit: 'hour'
1066
- });
1067
- }
1068
- return addLeadingZeros(hours, token.length);
1069
- },
1070
- // Minute
1071
- m: function m(date, token, localize) {
1072
- if (token === 'mo') {
1073
- return localize.ordinalNumber(date.getUTCMinutes(), {
1074
- unit: 'minute'
1075
- });
1076
- }
1077
- return formatters$1.m(date, token);
1078
- },
1079
- // Second
1080
- s: function s(date, token, localize) {
1081
- if (token === 'so') {
1082
- return localize.ordinalNumber(date.getUTCSeconds(), {
1083
- unit: 'second'
1084
- });
1085
- }
1086
- return formatters$1.s(date, token);
1087
- },
1088
- // Fraction of second
1089
- S: function S(date, token) {
1090
- return formatters$1.S(date, token);
1091
- },
1092
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1093
- X: function X(date, token, _localize, options) {
1094
- var originalDate = options._originalDate || date;
1095
- var timezoneOffset = originalDate.getTimezoneOffset();
1096
- if (timezoneOffset === 0) {
1097
- return 'Z';
1098
- }
1099
- switch (token) {
1100
- // Hours and optional minutes
1101
- case 'X':
1102
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1103
-
1104
- // Hours, minutes and optional seconds without `:` delimiter
1105
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1106
- // so this token always has the same output as `XX`
1107
- case 'XXXX':
1108
- case 'XX':
1109
- // Hours and minutes without `:` delimiter
1110
- return formatTimezone(timezoneOffset);
1111
-
1112
- // Hours, minutes and optional seconds with `:` delimiter
1113
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1114
- // so this token always has the same output as `XXX`
1115
- case 'XXXXX':
1116
- case 'XXX': // Hours and minutes with `:` delimiter
1117
- default:
1118
- return formatTimezone(timezoneOffset, ':');
1119
- }
1120
- },
1121
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1122
- x: function x(date, token, _localize, options) {
1123
- var originalDate = options._originalDate || date;
1124
- var timezoneOffset = originalDate.getTimezoneOffset();
1125
- switch (token) {
1126
- // Hours and optional minutes
1127
- case 'x':
1128
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1129
-
1130
- // Hours, minutes and optional seconds without `:` delimiter
1131
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1132
- // so this token always has the same output as `xx`
1133
- case 'xxxx':
1134
- case 'xx':
1135
- // Hours and minutes without `:` delimiter
1136
- return formatTimezone(timezoneOffset);
1137
-
1138
- // Hours, minutes and optional seconds with `:` delimiter
1139
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1140
- // so this token always has the same output as `xxx`
1141
- case 'xxxxx':
1142
- case 'xxx': // Hours and minutes with `:` delimiter
1143
- default:
1144
- return formatTimezone(timezoneOffset, ':');
1145
- }
1146
- },
1147
- // Timezone (GMT)
1148
- O: function O(date, token, _localize, options) {
1149
- var originalDate = options._originalDate || date;
1150
- var timezoneOffset = originalDate.getTimezoneOffset();
1151
- switch (token) {
1152
- // Short
1153
- case 'O':
1154
- case 'OO':
1155
- case 'OOO':
1156
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1157
- // Long
1158
- case 'OOOO':
1159
- default:
1160
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1161
- }
1162
- },
1163
- // Timezone (specific non-location)
1164
- z: function z(date, token, _localize, options) {
1165
- var originalDate = options._originalDate || date;
1166
- var timezoneOffset = originalDate.getTimezoneOffset();
1167
- switch (token) {
1168
- // Short
1169
- case 'z':
1170
- case 'zz':
1171
- case 'zzz':
1172
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1173
- // Long
1174
- case 'zzzz':
1175
- default:
1176
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1177
- }
1178
- },
1179
- // Seconds timestamp
1180
- t: function t(date, token, _localize, options) {
1181
- var originalDate = options._originalDate || date;
1182
- var timestamp = Math.floor(originalDate.getTime() / 1000);
1183
- return addLeadingZeros(timestamp, token.length);
1184
- },
1185
- // Milliseconds timestamp
1186
- T: function T(date, token, _localize, options) {
1187
- var originalDate = options._originalDate || date;
1188
- var timestamp = originalDate.getTime();
1189
- return addLeadingZeros(timestamp, token.length);
1190
- }
1191
- };
1192
- function formatTimezoneShort(offset, dirtyDelimiter) {
1193
- var sign = offset > 0 ? '-' : '+';
1194
- var absOffset = Math.abs(offset);
1195
- var hours = Math.floor(absOffset / 60);
1196
- var minutes = absOffset % 60;
1197
- if (minutes === 0) {
1198
- return sign + String(hours);
1199
- }
1200
- var delimiter = dirtyDelimiter || '';
1201
- return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1202
- }
1203
- function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1204
- if (offset % 60 === 0) {
1205
- var sign = offset > 0 ? '-' : '+';
1206
- return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1207
- }
1208
- return formatTimezone(offset, dirtyDelimiter);
1209
- }
1210
- function formatTimezone(offset, dirtyDelimiter) {
1211
- var delimiter = dirtyDelimiter || '';
1212
- var sign = offset > 0 ? '-' : '+';
1213
- var absOffset = Math.abs(offset);
1214
- var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1215
- var minutes = addLeadingZeros(absOffset % 60, 2);
1216
- return sign + hours + delimiter + minutes;
1217
- }
1218
-
1219
- var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1220
- switch (pattern) {
1221
- case 'P':
1222
- return formatLong.date({
1223
- width: 'short'
1224
- });
1225
- case 'PP':
1226
- return formatLong.date({
1227
- width: 'medium'
1228
- });
1229
- case 'PPP':
1230
- return formatLong.date({
1231
- width: 'long'
1232
- });
1233
- case 'PPPP':
1234
- default:
1235
- return formatLong.date({
1236
- width: 'full'
1237
- });
1238
- }
1239
- };
1240
- var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1241
- switch (pattern) {
1242
- case 'p':
1243
- return formatLong.time({
1244
- width: 'short'
1245
- });
1246
- case 'pp':
1247
- return formatLong.time({
1248
- width: 'medium'
1249
- });
1250
- case 'ppp':
1251
- return formatLong.time({
1252
- width: 'long'
1253
- });
1254
- case 'pppp':
1255
- default:
1256
- return formatLong.time({
1257
- width: 'full'
1258
- });
1259
- }
1260
- };
1261
- var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1262
- var matchResult = pattern.match(/(P+)(p+)?/) || [];
1263
- var datePattern = matchResult[1];
1264
- var timePattern = matchResult[2];
1265
- if (!timePattern) {
1266
- return dateLongFormatter(pattern, formatLong);
1267
- }
1268
- var dateTimeFormat;
1269
- switch (datePattern) {
1270
- case 'P':
1271
- dateTimeFormat = formatLong.dateTime({
1272
- width: 'short'
1273
- });
1274
- break;
1275
- case 'PP':
1276
- dateTimeFormat = formatLong.dateTime({
1277
- width: 'medium'
1278
- });
1279
- break;
1280
- case 'PPP':
1281
- dateTimeFormat = formatLong.dateTime({
1282
- width: 'long'
1283
- });
1284
- break;
1285
- case 'PPPP':
1286
- default:
1287
- dateTimeFormat = formatLong.dateTime({
1288
- width: 'full'
1289
- });
1290
- break;
1291
- }
1292
- return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1293
- };
1294
- var longFormatters = {
1295
- p: timeLongFormatter,
1296
- P: dateTimeLongFormatter
1297
- };
1298
-
1299
- var protectedDayOfYearTokens = ['D', 'DD'];
1300
- var protectedWeekYearTokens = ['YY', 'YYYY'];
1301
- function isProtectedDayOfYearToken(token) {
1302
- return protectedDayOfYearTokens.indexOf(token) !== -1;
1303
- }
1304
- function isProtectedWeekYearToken(token) {
1305
- return protectedWeekYearTokens.indexOf(token) !== -1;
1306
- }
1307
- function throwProtectedError(token, format, input) {
1308
- if (token === 'YYYY') {
1309
- throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1310
- } else if (token === 'YY') {
1311
- throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1312
- } else if (token === 'D') {
1313
- throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1314
- } else if (token === 'DD') {
1315
- throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1316
- }
1317
- }
1318
-
1319
- var formatDistanceLocale = {
1320
- lessThanXSeconds: {
1321
- one: 'less than a second',
1322
- other: 'less than {{count}} seconds'
1323
- },
1324
- xSeconds: {
1325
- one: '1 second',
1326
- other: '{{count}} seconds'
1327
- },
1328
- halfAMinute: 'half a minute',
1329
- lessThanXMinutes: {
1330
- one: 'less than a minute',
1331
- other: 'less than {{count}} minutes'
1332
- },
1333
- xMinutes: {
1334
- one: '1 minute',
1335
- other: '{{count}} minutes'
1336
- },
1337
- aboutXHours: {
1338
- one: 'about 1 hour',
1339
- other: 'about {{count}} hours'
1340
- },
1341
- xHours: {
1342
- one: '1 hour',
1343
- other: '{{count}} hours'
1344
- },
1345
- xDays: {
1346
- one: '1 day',
1347
- other: '{{count}} days'
1348
- },
1349
- aboutXWeeks: {
1350
- one: 'about 1 week',
1351
- other: 'about {{count}} weeks'
1352
- },
1353
- xWeeks: {
1354
- one: '1 week',
1355
- other: '{{count}} weeks'
1356
- },
1357
- aboutXMonths: {
1358
- one: 'about 1 month',
1359
- other: 'about {{count}} months'
1360
- },
1361
- xMonths: {
1362
- one: '1 month',
1363
- other: '{{count}} months'
1364
- },
1365
- aboutXYears: {
1366
- one: 'about 1 year',
1367
- other: 'about {{count}} years'
1368
- },
1369
- xYears: {
1370
- one: '1 year',
1371
- other: '{{count}} years'
1372
- },
1373
- overXYears: {
1374
- one: 'over 1 year',
1375
- other: 'over {{count}} years'
1376
- },
1377
- almostXYears: {
1378
- one: 'almost 1 year',
1379
- other: 'almost {{count}} years'
1380
- }
1381
- };
1382
- var formatDistance = function formatDistance(token, count, options) {
1383
- var result;
1384
- var tokenValue = formatDistanceLocale[token];
1385
- if (typeof tokenValue === 'string') {
1386
- result = tokenValue;
1387
- } else if (count === 1) {
1388
- result = tokenValue.one;
1389
- } else {
1390
- result = tokenValue.other.replace('{{count}}', count.toString());
1391
- }
1392
- if (options !== null && options !== void 0 && options.addSuffix) {
1393
- if (options.comparison && options.comparison > 0) {
1394
- return 'in ' + result;
1395
- } else {
1396
- return result + ' ago';
1397
- }
1398
- }
1399
- return result;
1400
- };
1401
-
1402
- function buildFormatLongFn(args) {
1403
- return function () {
1404
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1405
- // TODO: Remove String()
1406
- var width = options.width ? String(options.width) : args.defaultWidth;
1407
- var format = args.formats[width] || args.formats[args.defaultWidth];
1408
- return format;
1409
- };
1410
- }
1411
-
1412
- var dateFormats = {
1413
- full: 'EEEE, MMMM do, y',
1414
- long: 'MMMM do, y',
1415
- medium: 'MMM d, y',
1416
- short: 'MM/dd/yyyy'
1417
- };
1418
- var timeFormats = {
1419
- full: 'h:mm:ss a zzzz',
1420
- long: 'h:mm:ss a z',
1421
- medium: 'h:mm:ss a',
1422
- short: 'h:mm a'
1423
- };
1424
- var dateTimeFormats = {
1425
- full: "{{date}} 'at' {{time}}",
1426
- long: "{{date}} 'at' {{time}}",
1427
- medium: '{{date}}, {{time}}',
1428
- short: '{{date}}, {{time}}'
1429
- };
1430
- var formatLong = {
1431
- date: buildFormatLongFn({
1432
- formats: dateFormats,
1433
- defaultWidth: 'full'
1434
- }),
1435
- time: buildFormatLongFn({
1436
- formats: timeFormats,
1437
- defaultWidth: 'full'
1438
- }),
1439
- dateTime: buildFormatLongFn({
1440
- formats: dateTimeFormats,
1441
- defaultWidth: 'full'
1442
- })
1443
- };
1444
-
1445
- var formatRelativeLocale = {
1446
- lastWeek: "'last' eeee 'at' p",
1447
- yesterday: "'yesterday at' p",
1448
- today: "'today at' p",
1449
- tomorrow: "'tomorrow at' p",
1450
- nextWeek: "eeee 'at' p",
1451
- other: 'P'
1452
- };
1453
- var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1454
- return formatRelativeLocale[token];
1455
- };
1456
-
1457
- function buildLocalizeFn(args) {
1458
- return function (dirtyIndex, options) {
1459
- var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1460
- var valuesArray;
1461
- if (context === 'formatting' && args.formattingValues) {
1462
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1463
- var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1464
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1465
- } else {
1466
- var _defaultWidth = args.defaultWidth;
1467
- var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1468
- valuesArray = args.values[_width] || args.values[_defaultWidth];
1469
- }
1470
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1471
- // @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!
1472
- return valuesArray[index];
1473
- };
1474
- }
1475
-
1476
- var eraValues = {
1477
- narrow: ['B', 'A'],
1478
- abbreviated: ['BC', 'AD'],
1479
- wide: ['Before Christ', 'Anno Domini']
1480
- };
1481
- var quarterValues = {
1482
- narrow: ['1', '2', '3', '4'],
1483
- abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1484
- wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1485
- };
1486
-
1487
- // Note: in English, the names of days of the week and months are capitalized.
1488
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1489
- // Generally, formatted dates should look like they are in the middle of a sentence,
1490
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
1491
- var monthValues = {
1492
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1493
- abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1494
- wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1495
- };
1496
- var dayValues = {
1497
- narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1498
- short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1499
- abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1500
- wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1501
- };
1502
- var dayPeriodValues = {
1503
- narrow: {
1504
- am: 'a',
1505
- pm: 'p',
1506
- midnight: 'mi',
1507
- noon: 'n',
1508
- morning: 'morning',
1509
- afternoon: 'afternoon',
1510
- evening: 'evening',
1511
- night: 'night'
1512
- },
1513
- abbreviated: {
1514
- am: 'AM',
1515
- pm: 'PM',
1516
- midnight: 'midnight',
1517
- noon: 'noon',
1518
- morning: 'morning',
1519
- afternoon: 'afternoon',
1520
- evening: 'evening',
1521
- night: 'night'
1522
- },
1523
- wide: {
1524
- am: 'a.m.',
1525
- pm: 'p.m.',
1526
- midnight: 'midnight',
1527
- noon: 'noon',
1528
- morning: 'morning',
1529
- afternoon: 'afternoon',
1530
- evening: 'evening',
1531
- night: 'night'
1532
- }
1533
- };
1534
- var formattingDayPeriodValues = {
1535
- narrow: {
1536
- am: 'a',
1537
- pm: 'p',
1538
- midnight: 'mi',
1539
- noon: 'n',
1540
- morning: 'in the morning',
1541
- afternoon: 'in the afternoon',
1542
- evening: 'in the evening',
1543
- night: 'at night'
1544
- },
1545
- abbreviated: {
1546
- am: 'AM',
1547
- pm: 'PM',
1548
- midnight: 'midnight',
1549
- noon: 'noon',
1550
- morning: 'in the morning',
1551
- afternoon: 'in the afternoon',
1552
- evening: 'in the evening',
1553
- night: 'at night'
1554
- },
1555
- wide: {
1556
- am: 'a.m.',
1557
- pm: 'p.m.',
1558
- midnight: 'midnight',
1559
- noon: 'noon',
1560
- morning: 'in the morning',
1561
- afternoon: 'in the afternoon',
1562
- evening: 'in the evening',
1563
- night: 'at night'
1564
- }
1565
- };
1566
- var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1567
- var number = Number(dirtyNumber);
1568
-
1569
- // If ordinal numbers depend on context, for example,
1570
- // if they are different for different grammatical genders,
1571
- // use `options.unit`.
1572
- //
1573
- // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1574
- // 'day', 'hour', 'minute', 'second'.
1575
-
1576
- var rem100 = number % 100;
1577
- if (rem100 > 20 || rem100 < 10) {
1578
- switch (rem100 % 10) {
1579
- case 1:
1580
- return number + 'st';
1581
- case 2:
1582
- return number + 'nd';
1583
- case 3:
1584
- return number + 'rd';
1585
- }
1586
- }
1587
- return number + 'th';
1588
- };
1589
- var localize = {
1590
- ordinalNumber: ordinalNumber,
1591
- era: buildLocalizeFn({
1592
- values: eraValues,
1593
- defaultWidth: 'wide'
1594
- }),
1595
- quarter: buildLocalizeFn({
1596
- values: quarterValues,
1597
- defaultWidth: 'wide',
1598
- argumentCallback: function argumentCallback(quarter) {
1599
- return quarter - 1;
1600
- }
1601
- }),
1602
- month: buildLocalizeFn({
1603
- values: monthValues,
1604
- defaultWidth: 'wide'
1605
- }),
1606
- day: buildLocalizeFn({
1607
- values: dayValues,
1608
- defaultWidth: 'wide'
1609
- }),
1610
- dayPeriod: buildLocalizeFn({
1611
- values: dayPeriodValues,
1612
- defaultWidth: 'wide',
1613
- formattingValues: formattingDayPeriodValues,
1614
- defaultFormattingWidth: 'wide'
1615
- })
1616
- };
1617
-
1618
- function buildMatchFn(args) {
1619
- return function (string) {
1620
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1621
- var width = options.width;
1622
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1623
- var matchResult = string.match(matchPattern);
1624
- if (!matchResult) {
1625
- return null;
1626
- }
1627
- var matchedString = matchResult[0];
1628
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1629
- var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1630
- return pattern.test(matchedString);
1631
- }) : findKey(parsePatterns, function (pattern) {
1632
- return pattern.test(matchedString);
1633
- });
1634
- var value;
1635
- value = args.valueCallback ? args.valueCallback(key) : key;
1636
- value = options.valueCallback ? options.valueCallback(value) : value;
1637
- var rest = string.slice(matchedString.length);
1638
- return {
1639
- value: value,
1640
- rest: rest
1641
- };
1642
- };
1643
- }
1644
- function findKey(object, predicate) {
1645
- for (var key in object) {
1646
- if (object.hasOwnProperty(key) && predicate(object[key])) {
1647
- return key;
1648
- }
1649
- }
1650
- return undefined;
1651
- }
1652
- function findIndex(array, predicate) {
1653
- for (var key = 0; key < array.length; key++) {
1654
- if (predicate(array[key])) {
1655
- return key;
1656
- }
1657
- }
1658
- return undefined;
1659
- }
1660
-
1661
- function buildMatchPatternFn(args) {
1662
- return function (string) {
1663
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1664
- var matchResult = string.match(args.matchPattern);
1665
- if (!matchResult) return null;
1666
- var matchedString = matchResult[0];
1667
- var parseResult = string.match(args.parsePattern);
1668
- if (!parseResult) return null;
1669
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1670
- value = options.valueCallback ? options.valueCallback(value) : value;
1671
- var rest = string.slice(matchedString.length);
1672
- return {
1673
- value: value,
1674
- rest: rest
1675
- };
1676
- };
1677
- }
1678
-
1679
- var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1680
- var parseOrdinalNumberPattern = /\d+/i;
1681
- var matchEraPatterns = {
1682
- narrow: /^(b|a)/i,
1683
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1684
- wide: /^(before christ|before common era|anno domini|common era)/i
1685
- };
1686
- var parseEraPatterns = {
1687
- any: [/^b/i, /^(a|c)/i]
1688
- };
1689
- var matchQuarterPatterns = {
1690
- narrow: /^[1234]/i,
1691
- abbreviated: /^q[1234]/i,
1692
- wide: /^[1234](th|st|nd|rd)? quarter/i
1693
- };
1694
- var parseQuarterPatterns = {
1695
- any: [/1/i, /2/i, /3/i, /4/i]
1696
- };
1697
- var matchMonthPatterns = {
1698
- narrow: /^[jfmasond]/i,
1699
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1700
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1701
- };
1702
- var parseMonthPatterns = {
1703
- 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],
1704
- 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]
1705
- };
1706
- var matchDayPatterns = {
1707
- narrow: /^[smtwf]/i,
1708
- short: /^(su|mo|tu|we|th|fr|sa)/i,
1709
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1710
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1711
- };
1712
- var parseDayPatterns = {
1713
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1714
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1715
- };
1716
- var matchDayPeriodPatterns = {
1717
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1718
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1719
- };
1720
- var parseDayPeriodPatterns = {
1721
- any: {
1722
- am: /^a/i,
1723
- pm: /^p/i,
1724
- midnight: /^mi/i,
1725
- noon: /^no/i,
1726
- morning: /morning/i,
1727
- afternoon: /afternoon/i,
1728
- evening: /evening/i,
1729
- night: /night/i
1730
- }
1731
- };
1732
- var match = {
1733
- ordinalNumber: buildMatchPatternFn({
1734
- matchPattern: matchOrdinalNumberPattern,
1735
- parsePattern: parseOrdinalNumberPattern,
1736
- valueCallback: function valueCallback(value) {
1737
- return parseInt(value, 10);
1738
- }
1739
- }),
1740
- era: buildMatchFn({
1741
- matchPatterns: matchEraPatterns,
1742
- defaultMatchWidth: 'wide',
1743
- parsePatterns: parseEraPatterns,
1744
- defaultParseWidth: 'any'
1745
- }),
1746
- quarter: buildMatchFn({
1747
- matchPatterns: matchQuarterPatterns,
1748
- defaultMatchWidth: 'wide',
1749
- parsePatterns: parseQuarterPatterns,
1750
- defaultParseWidth: 'any',
1751
- valueCallback: function valueCallback(index) {
1752
- return index + 1;
1753
- }
1754
- }),
1755
- month: buildMatchFn({
1756
- matchPatterns: matchMonthPatterns,
1757
- defaultMatchWidth: 'wide',
1758
- parsePatterns: parseMonthPatterns,
1759
- defaultParseWidth: 'any'
1760
- }),
1761
- day: buildMatchFn({
1762
- matchPatterns: matchDayPatterns,
1763
- defaultMatchWidth: 'wide',
1764
- parsePatterns: parseDayPatterns,
1765
- defaultParseWidth: 'any'
1766
- }),
1767
- dayPeriod: buildMatchFn({
1768
- matchPatterns: matchDayPeriodPatterns,
1769
- defaultMatchWidth: 'any',
1770
- parsePatterns: parseDayPeriodPatterns,
1771
- defaultParseWidth: 'any'
1772
- })
1773
- };
1774
-
1775
- /**
1776
- * @type {Locale}
1777
- * @category Locales
1778
- * @summary English locale (United States).
1779
- * @language English
1780
- * @iso-639-2 eng
1781
- * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1782
- * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1783
- */
1784
- var locale = {
1785
- code: 'en-US',
1786
- formatDistance: formatDistance,
1787
- formatLong: formatLong,
1788
- formatRelative: formatRelative,
1789
- localize: localize,
1790
- match: match,
1791
- options: {
1792
- weekStartsOn: 0 /* Sunday */,
1793
- firstWeekContainsDate: 1
1794
- }
1795
- };
1796
-
1797
- // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1798
- // (one of the certain letters followed by `o`)
1799
- // - (\w)\1* matches any sequences of the same letter
1800
- // - '' matches two quote characters in a row
1801
- // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
1802
- // except a single quote symbol, which ends the sequence.
1803
- // Two quote characters do not end the sequence.
1804
- // If there is no matching single quote
1805
- // then the sequence will continue until the end of the string.
1806
- // - . matches any single character unmatched by previous parts of the RegExps
1807
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
1808
-
1809
- // This RegExp catches symbols escaped by quotes, and also
1810
- // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
1811
- var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
1812
- var escapedStringRegExp = /^'([^]*?)'?$/;
1813
- var doubleQuoteRegExp = /''/g;
1814
- var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1815
-
1816
- /**
1817
- * @name format
1818
- * @category Common Helpers
1819
- * @summary Format the date.
1820
- *
1821
- * @description
1822
- * Return the formatted date string in the given format. The result may vary by locale.
1823
- *
1824
- * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
1825
- * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
1826
- *
1827
- * The characters wrapped between two single quotes characters (') are escaped.
1828
- * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
1829
- * (see the last example)
1830
- *
1831
- * Format of the string is based on Unicode Technical Standard #35:
1832
- * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
1833
- * with a few additions (see note 7 below the table).
1834
- *
1835
- * Accepted patterns:
1836
- * | Unit | Pattern | Result examples | Notes |
1837
- * |---------------------------------|---------|-----------------------------------|-------|
1838
- * | Era | G..GGG | AD, BC | |
1839
- * | | GGGG | Anno Domini, Before Christ | 2 |
1840
- * | | GGGGG | A, B | |
1841
- * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
1842
- * | | yo | 44th, 1st, 0th, 17th | 5,7 |
1843
- * | | yy | 44, 01, 00, 17 | 5 |
1844
- * | | yyy | 044, 001, 1900, 2017 | 5 |
1845
- * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
1846
- * | | yyyyy | ... | 3,5 |
1847
- * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
1848
- * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
1849
- * | | YY | 44, 01, 00, 17 | 5,8 |
1850
- * | | YYY | 044, 001, 1900, 2017 | 5 |
1851
- * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
1852
- * | | YYYYY | ... | 3,5 |
1853
- * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
1854
- * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
1855
- * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
1856
- * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
1857
- * | | RRRRR | ... | 3,5,7 |
1858
- * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
1859
- * | | uu | -43, 01, 1900, 2017 | 5 |
1860
- * | | uuu | -043, 001, 1900, 2017 | 5 |
1861
- * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
1862
- * | | uuuuu | ... | 3,5 |
1863
- * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
1864
- * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
1865
- * | | QQ | 01, 02, 03, 04 | |
1866
- * | | QQQ | Q1, Q2, Q3, Q4 | |
1867
- * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
1868
- * | | QQQQQ | 1, 2, 3, 4 | 4 |
1869
- * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
1870
- * | | qo | 1st, 2nd, 3rd, 4th | 7 |
1871
- * | | qq | 01, 02, 03, 04 | |
1872
- * | | qqq | Q1, Q2, Q3, Q4 | |
1873
- * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
1874
- * | | qqqqq | 1, 2, 3, 4 | 4 |
1875
- * | Month (formatting) | M | 1, 2, ..., 12 | |
1876
- * | | Mo | 1st, 2nd, ..., 12th | 7 |
1877
- * | | MM | 01, 02, ..., 12 | |
1878
- * | | MMM | Jan, Feb, ..., Dec | |
1879
- * | | MMMM | January, February, ..., December | 2 |
1880
- * | | MMMMM | J, F, ..., D | |
1881
- * | Month (stand-alone) | L | 1, 2, ..., 12 | |
1882
- * | | Lo | 1st, 2nd, ..., 12th | 7 |
1883
- * | | LL | 01, 02, ..., 12 | |
1884
- * | | LLL | Jan, Feb, ..., Dec | |
1885
- * | | LLLL | January, February, ..., December | 2 |
1886
- * | | LLLLL | J, F, ..., D | |
1887
- * | Local week of year | w | 1, 2, ..., 53 | |
1888
- * | | wo | 1st, 2nd, ..., 53th | 7 |
1889
- * | | ww | 01, 02, ..., 53 | |
1890
- * | ISO week of year | I | 1, 2, ..., 53 | 7 |
1891
- * | | Io | 1st, 2nd, ..., 53th | 7 |
1892
- * | | II | 01, 02, ..., 53 | 7 |
1893
- * | Day of month | d | 1, 2, ..., 31 | |
1894
- * | | do | 1st, 2nd, ..., 31st | 7 |
1895
- * | | dd | 01, 02, ..., 31 | |
1896
- * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
1897
- * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
1898
- * | | DD | 01, 02, ..., 365, 366 | 9 |
1899
- * | | DDD | 001, 002, ..., 365, 366 | |
1900
- * | | DDDD | ... | 3 |
1901
- * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
1902
- * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
1903
- * | | EEEEE | M, T, W, T, F, S, S | |
1904
- * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
1905
- * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
1906
- * | | io | 1st, 2nd, ..., 7th | 7 |
1907
- * | | ii | 01, 02, ..., 07 | 7 |
1908
- * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
1909
- * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
1910
- * | | iiiii | M, T, W, T, F, S, S | 7 |
1911
- * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
1912
- * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
1913
- * | | eo | 2nd, 3rd, ..., 1st | 7 |
1914
- * | | ee | 02, 03, ..., 01 | |
1915
- * | | eee | Mon, Tue, Wed, ..., Sun | |
1916
- * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
1917
- * | | eeeee | M, T, W, T, F, S, S | |
1918
- * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
1919
- * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
1920
- * | | co | 2nd, 3rd, ..., 1st | 7 |
1921
- * | | cc | 02, 03, ..., 01 | |
1922
- * | | ccc | Mon, Tue, Wed, ..., Sun | |
1923
- * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
1924
- * | | ccccc | M, T, W, T, F, S, S | |
1925
- * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
1926
- * | AM, PM | a..aa | AM, PM | |
1927
- * | | aaa | am, pm | |
1928
- * | | aaaa | a.m., p.m. | 2 |
1929
- * | | aaaaa | a, p | |
1930
- * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
1931
- * | | bbb | am, pm, noon, midnight | |
1932
- * | | bbbb | a.m., p.m., noon, midnight | 2 |
1933
- * | | bbbbb | a, p, n, mi | |
1934
- * | Flexible day period | B..BBB | at night, in the morning, ... | |
1935
- * | | BBBB | at night, in the morning, ... | 2 |
1936
- * | | BBBBB | at night, in the morning, ... | |
1937
- * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
1938
- * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
1939
- * | | hh | 01, 02, ..., 11, 12 | |
1940
- * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
1941
- * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
1942
- * | | HH | 00, 01, 02, ..., 23 | |
1943
- * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
1944
- * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
1945
- * | | KK | 01, 02, ..., 11, 00 | |
1946
- * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
1947
- * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
1948
- * | | kk | 24, 01, 02, ..., 23 | |
1949
- * | Minute | m | 0, 1, ..., 59 | |
1950
- * | | mo | 0th, 1st, ..., 59th | 7 |
1951
- * | | mm | 00, 01, ..., 59 | |
1952
- * | Second | s | 0, 1, ..., 59 | |
1953
- * | | so | 0th, 1st, ..., 59th | 7 |
1954
- * | | ss | 00, 01, ..., 59 | |
1955
- * | Fraction of second | S | 0, 1, ..., 9 | |
1956
- * | | SS | 00, 01, ..., 99 | |
1957
- * | | SSS | 000, 001, ..., 999 | |
1958
- * | | SSSS | ... | 3 |
1959
- * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
1960
- * | | XX | -0800, +0530, Z | |
1961
- * | | XXX | -08:00, +05:30, Z | |
1962
- * | | XXXX | -0800, +0530, Z, +123456 | 2 |
1963
- * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
1964
- * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
1965
- * | | xx | -0800, +0530, +0000 | |
1966
- * | | xxx | -08:00, +05:30, +00:00 | 2 |
1967
- * | | xxxx | -0800, +0530, +0000, +123456 | |
1968
- * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
1969
- * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
1970
- * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
1971
- * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
1972
- * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
1973
- * | Seconds timestamp | t | 512969520 | 7 |
1974
- * | | tt | ... | 3,7 |
1975
- * | Milliseconds timestamp | T | 512969520900 | 7 |
1976
- * | | TT | ... | 3,7 |
1977
- * | Long localized date | P | 04/29/1453 | 7 |
1978
- * | | PP | Apr 29, 1453 | 7 |
1979
- * | | PPP | April 29th, 1453 | 7 |
1980
- * | | PPPP | Friday, April 29th, 1453 | 2,7 |
1981
- * | Long localized time | p | 12:00 AM | 7 |
1982
- * | | pp | 12:00:00 AM | 7 |
1983
- * | | ppp | 12:00:00 AM GMT+2 | 7 |
1984
- * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
1985
- * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
1986
- * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
1987
- * | | PPPppp | April 29th, 1453 at ... | 7 |
1988
- * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
1989
- * Notes:
1990
- * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
1991
- * are the same as "stand-alone" units, but are different in some languages.
1992
- * "Formatting" units are declined according to the rules of the language
1993
- * in the context of a date. "Stand-alone" units are always nominative singular:
1994
- *
1995
- * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
1996
- *
1997
- * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
1998
- *
1999
- * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2000
- * the single quote characters (see below).
2001
- * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2002
- * the output will be the same as default pattern for this unit, usually
2003
- * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2004
- * are marked with "2" in the last column of the table.
2005
- *
2006
- * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2007
- *
2008
- * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2009
- *
2010
- * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2011
- *
2012
- * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2013
- *
2014
- * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2015
- *
2016
- * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2017
- * The output will be padded with zeros to match the length of the pattern.
2018
- *
2019
- * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2020
- *
2021
- * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2022
- * These tokens represent the shortest form of the quarter.
2023
- *
2024
- * 5. The main difference between `y` and `u` patterns are B.C. years:
2025
- *
2026
- * | Year | `y` | `u` |
2027
- * |------|-----|-----|
2028
- * | AC 1 | 1 | 1 |
2029
- * | BC 1 | 1 | 0 |
2030
- * | BC 2 | 2 | -1 |
2031
- *
2032
- * Also `yy` always returns the last two digits of a year,
2033
- * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2034
- *
2035
- * | Year | `yy` | `uu` |
2036
- * |------|------|------|
2037
- * | 1 | 01 | 01 |
2038
- * | 14 | 14 | 14 |
2039
- * | 376 | 76 | 376 |
2040
- * | 1453 | 53 | 1453 |
2041
- *
2042
- * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2043
- * except local week-numbering years are dependent on `options.weekStartsOn`
2044
- * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2045
- * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2046
- *
2047
- * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2048
- * so right now these tokens fall back to GMT timezones.
2049
- *
2050
- * 7. These patterns are not in the Unicode Technical Standard #35:
2051
- * - `i`: ISO day of week
2052
- * - `I`: ISO week of year
2053
- * - `R`: ISO week-numbering year
2054
- * - `t`: seconds timestamp
2055
- * - `T`: milliseconds timestamp
2056
- * - `o`: ordinal number modifier
2057
- * - `P`: long localized date
2058
- * - `p`: long localized time
2059
- *
2060
- * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2061
- * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2062
- *
2063
- * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2064
- * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2065
- *
2066
- * @param {Date|Number} date - the original date
2067
- * @param {String} format - the string of tokens
2068
- * @param {Object} [options] - an object with options.
2069
- * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2070
- * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2071
- * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2072
- * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2073
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2074
- * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2075
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2076
- * @returns {String} the formatted date string
2077
- * @throws {TypeError} 2 arguments required
2078
- * @throws {RangeError} `date` must not be Invalid Date
2079
- * @throws {RangeError} `options.locale` must contain `localize` property
2080
- * @throws {RangeError} `options.locale` must contain `formatLong` property
2081
- * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2082
- * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2083
- * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2084
- * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2085
- * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2086
- * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2087
- * @throws {RangeError} format string contains an unescaped latin alphabet character
2088
- *
2089
- * @example
2090
- * // Represent 11 February 2014 in middle-endian format:
2091
- * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2092
- * //=> '02/11/2014'
2093
- *
2094
- * @example
2095
- * // Represent 2 July 2014 in Esperanto:
2096
- * import { eoLocale } from 'date-fns/locale/eo'
2097
- * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2098
- * locale: eoLocale
2099
- * })
2100
- * //=> '2-a de julio 2014'
2101
- *
2102
- * @example
2103
- * // Escape string by single quote characters:
2104
- * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2105
- * //=> "3 o'clock"
2106
- */
2107
-
2108
- function format(dirtyDate, dirtyFormatStr, options) {
2109
- var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
2110
- requiredArgs(2, arguments);
2111
- var formatStr = String(dirtyFormatStr);
2112
- var defaultOptions = getDefaultOptions();
2113
- var locale$1 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : locale;
2114
- var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);
2115
-
2116
- // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2117
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2118
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2119
- }
2120
- var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);
2121
-
2122
- // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2123
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2124
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2125
- }
2126
- if (!locale$1.localize) {
2127
- throw new RangeError('locale must contain localize property');
2128
- }
2129
- if (!locale$1.formatLong) {
2130
- throw new RangeError('locale must contain formatLong property');
2131
- }
2132
- var originalDate = toDate(dirtyDate);
2133
- if (!isValid(originalDate)) {
2134
- throw new RangeError('Invalid time value');
2135
- }
2136
-
2137
- // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2138
- // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2139
- // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2140
- var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2141
- var utcDate = subMilliseconds(originalDate, timezoneOffset);
2142
- var formatterOptions = {
2143
- firstWeekContainsDate: firstWeekContainsDate,
2144
- weekStartsOn: weekStartsOn,
2145
- locale: locale$1,
2146
- _originalDate: originalDate
2147
- };
2148
- var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2149
- var firstCharacter = substring[0];
2150
- if (firstCharacter === 'p' || firstCharacter === 'P') {
2151
- var longFormatter = longFormatters[firstCharacter];
2152
- return longFormatter(substring, locale$1.formatLong);
2153
- }
2154
- return substring;
2155
- }).join('').match(formattingTokensRegExp).map(function (substring) {
2156
- // Replace two single quote characters with one single quote character
2157
- if (substring === "''") {
2158
- return "'";
2159
- }
2160
- var firstCharacter = substring[0];
2161
- if (firstCharacter === "'") {
2162
- return cleanEscapedString(substring);
2163
- }
2164
- var formatter = formatters[firstCharacter];
2165
- if (formatter) {
2166
- if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2167
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2168
- }
2169
- if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2170
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2171
- }
2172
- return formatter(utcDate, substring, locale$1.localize, formatterOptions);
2173
- }
2174
- if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2175
- throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2176
- }
2177
- return substring;
2178
- }).join('');
2179
- return result;
2180
- }
2181
- function cleanEscapedString(input) {
2182
- var matched = input.match(escapedStringRegExp);
2183
- if (!matched) {
2184
- return input;
2185
- }
2186
- return matched[1].replace(doubleQuoteRegExp, "'");
2187
- }
2188
-
2189
- const TipsInfo = `<svg width="126" height="92" viewBox="0 0 126 92" fill="none" xmlns="http://www.w3.org/2000/svg">
2190
- <g filter="url(#filter0_d_242_4231)">
2191
- <rect x="24" y="20" width="78" height="36" rx="4" fill="white"/>
2192
- <path d="M24 24C24 21.7909 25.7909 20 28 20H64V56H28C25.7909 56 24 54.2091 24 52V24Z" fill="#464646"/>
2193
- <path d="M51 56H37L43.2474 63.1399C43.6458 63.5952 44.3542 63.5952 44.7526 63.1399L51 56Z" fill="#464646"/>
2194
- <circle cx="44" cy="38" r="7" fill="white"/>
2195
- <path d="M43.9405 34C44.5456 34 45.0362 34.4906 45.0362 35.0957C45.0362 35.7009 44.5456 36.1915 43.9405 36.1915C43.3353 36.1915 42.8447 35.7009 42.8447 35.0957C42.8447 34.4906 43.3353 34 43.9405 34Z" fill="#464646"/>
2196
- <path d="M45.8801 41.3737C45.8801 41.7617 45.5626 42.0791 45.1746 42.0791H44.3233H43.551H42.7055C42.3175 42.0791 42 41.7617 42 41.3737V41.3575C42 40.9695 42.3175 40.6521 42.7055 40.6521H42.8455V37.8714H42.3528C42.1588 37.8714 42 37.7127 42 37.5187V37.4936C42 37.2996 42.1588 37.1409 42.3528 37.1409H43.551H44.031H44.3233C44.7113 37.1409 45.0287 37.4583 45.0287 37.8463V40.6521H45.1746C45.5626 40.6521 45.8801 40.9696 45.8801 41.3576V41.3737Z" fill="#464646"/>
2197
- </g>
2198
- <defs>
2199
- <filter id="filter0_d_242_4231" x="0" y="0" width="126" height="91.4814" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
2200
- <feFlood flood-opacity="0" result="BackgroundImageFix"/>
2201
- <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
2202
- <feOffset dy="4"/>
2203
- <feGaussianBlur stdDeviation="12"/>
2204
- <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
2205
- <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_242_4231"/>
2206
- <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_242_4231" result="shape"/>
2207
- </filter>
2208
- </defs>
2209
- </svg>
2210
- `;
2211
-
2212
- const PlayerLoyaltyProcess = () => (h("span", { class: "LevelProgress", id: 'LevelProgress', innerHTML: LoyaltyProgress }));
2213
- const PlayerPoints = ({ loyaltyPoints, spendablePoints, pointExpireString, language, }) => (h("div", { class: "PointsInfo" },
2214
- loyaltyPoints &&
2215
- h("div", { class: 'Points' },
2216
- loyaltyPoints,
2217
- " ",
2218
- h("sub", { class: "XP" }, translate('xp', language))),
2219
- spendablePoints &&
2220
- h("div", { class: 'Points' },
2221
- spendablePoints,
2222
- " ",
2223
- h("sub", { class: "XP" }, translate('sp', language))),
2224
- pointExpireString && (h("div", { class: 'ExpirationPoints' },
2225
- pointExpireString,
2226
- " "))));
2227
- const PlayerElevateCardRedeem = ({ language, onRedeemClick }) => (h("div", { class: "CardCell Redeem" },
2228
- h("div", { class: "RedeemButton", onClick: () => {
2229
- onRedeemClick();
2230
- } },
2231
- h("span", null, translate('redeem', language)))));
2232
- const PlayerNameDiv = (props) => (h("div", { class: 'CardCell PlayerName Txt' }, props.playerName));
2233
- const PlayerElevateLoyaltyLevel = (props) => (h("div", { class: 'CardCell ElevateLevel' },
2234
- h("span", { class: "LevelName", title: props.level }, props.level),
2235
- props.expireTime && (h("div", { class: "CardCell ExpirationDate Txt" },
2236
- translate('expireOn', props.language),
2237
- h("span", { class: "ExpireTime" }, format(new Date(props.expireTime), props.dateFormat || 'yyyy-MM-dd')),
2238
- !props.hideInfo && (h("span", { class: "fa Info", style: { 'background': `url(${getAssetPath('../static/info.svg')})` } },
2239
- h("span", { class: "InfoTips", innerHTML: TipsInfo })))))));
2240
- const PlayerAvatar = (props) => {
2241
- const badge = props.loyaltyIconUrl
2242
- ? h("img", { class: "Badge", src: props.loyaltyIconUrl })
2243
- : props.hideIfNull ? '' : h("div", { class: "Badge" });
2244
- const avatarSrc = props.playerAvatarUrl || getAssetPath('../static/user.svg');
2245
- return h("div", { class: "PlayerAvatar", style: { 'position': `${props.onlyBadge ? '' : 'relative'}` } },
2246
- !props.onlyBadge && h("img", { class: "Avatar", src: avatarSrc }),
2247
- badge);
2248
- };
2249
-
2250
- export { PlayerAvatar as P, PlayerPoints as a, PlayerNameDiv as b, PlayerElevateLoyaltyLevel as c, PlayerLoyaltyProcess as d, PlayerElevateCardRedeem as e, format as f };