q2-tecton-elements 1.16.3 → 1.17.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.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/q2-avatar.cjs.entry.js +1 -1
- package/dist/cjs/q2-badge_2.cjs.entry.js +9 -3
- package/dist/cjs/q2-btn_2.cjs.entry.js +2 -2
- package/dist/cjs/q2-calendar.cjs.entry.js +1041 -1131
- package/dist/cjs/q2-card.cjs.entry.js +1 -1
- package/dist/cjs/q2-carousel-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-carousel.cjs.entry.js +1 -1
- package/dist/cjs/q2-chart-donut.cjs.entry.js +21 -3
- package/dist/cjs/q2-checkbox-group.cjs.entry.js +1 -1
- package/dist/cjs/q2-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/q2-dropdown-item.cjs.entry.js +1 -1
- package/dist/cjs/q2-dropdown.cjs.entry.js +1 -1
- package/dist/cjs/q2-editable-field.cjs.entry.js +1 -1
- package/dist/cjs/q2-icon.cjs.entry.js +1 -1
- package/dist/cjs/q2-loc.cjs.entry.js +1 -1
- package/dist/cjs/q2-message.cjs.entry.js +1 -1
- package/dist/cjs/q2-optgroup.cjs.entry.js +1 -1
- package/dist/cjs/q2-option-list.cjs.entry.js +1 -1
- package/dist/cjs/q2-option.cjs.entry.js +1 -1
- package/dist/cjs/q2-pagination.cjs.entry.js +1 -1
- package/dist/cjs/q2-pill.cjs.entry.js +1 -1
- package/dist/cjs/q2-radio-group.cjs.entry.js +2 -2
- package/dist/cjs/q2-radio.cjs.entry.js +1 -1
- package/dist/cjs/q2-section.cjs.entry.js +54 -80
- package/dist/cjs/q2-select.cjs.entry.js +1 -1
- package/dist/cjs/q2-stepper-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-stepper-vertical.cjs.entry.js +1 -1
- package/dist/cjs/q2-stepper.cjs.entry.js +1 -1
- package/dist/cjs/q2-tab-container.cjs.entry.js +1 -1
- package/dist/cjs/q2-tab-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-tag.cjs.entry.js +1 -1
- package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
- package/dist/cjs/q2-textarea.cjs.entry.js +1 -1
- package/dist/cjs/q2-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/tecton-tab-pane.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/q2-avatar/styles.css +1 -0
- package/dist/collection/components/q2-badge/styles.css +1 -0
- package/dist/collection/components/q2-btn/styles.css +1 -0
- package/dist/collection/components/q2-calendar/helpers.js +3 -3
- package/dist/collection/components/q2-calendar/index.js +11 -4
- package/dist/collection/components/q2-calendar/styles.css +1 -0
- package/dist/collection/components/q2-card/styles.css +1 -0
- package/dist/collection/components/q2-carousel/styles.css +1 -0
- package/dist/collection/components/q2-carousel-pane/styles.css +1 -0
- package/dist/collection/components/q2-chart-donut/index.js +47 -5
- package/dist/collection/components/q2-chart-donut/styles.css +1 -0
- package/dist/collection/components/q2-checkbox/styles.css +1 -0
- package/dist/collection/components/q2-checkbox-group/styles.css +1 -0
- package/dist/collection/components/q2-dropdown/styles.css +1 -0
- package/dist/collection/components/q2-dropdown-item/styles.css +1 -0
- package/dist/collection/components/q2-editable-field/styles.css +1 -0
- package/dist/collection/components/q2-icon/styles.css +1 -0
- package/dist/collection/components/q2-input/index.js +7 -1
- package/dist/collection/components/q2-input/styles.css +1 -0
- package/dist/collection/components/q2-loading/styles.css +1 -0
- package/dist/collection/components/q2-loc/styles.css +1 -0
- package/dist/collection/components/q2-message/styles.css +1 -0
- package/dist/collection/components/q2-optgroup/styles.css +1 -0
- package/dist/collection/components/q2-option/styles.css +1 -0
- package/dist/collection/components/q2-option-list/styles.css +1 -0
- package/dist/collection/components/q2-pagination/styles.css +1 -0
- package/dist/collection/components/q2-pill/styles.css +1 -0
- package/dist/collection/components/q2-radio/styles.css +1 -0
- package/dist/collection/components/q2-radio-group/index.js +1 -1
- package/dist/collection/components/q2-radio-group/styles.css +4 -0
- package/dist/collection/components/q2-section/index.js +63 -89
- package/dist/collection/components/q2-section/styles.css +39 -55
- package/dist/collection/components/q2-select/styles.css +1 -0
- package/dist/collection/components/q2-stepper/styles.css +1 -0
- package/dist/collection/components/q2-stepper-pane/styles.css +1 -0
- package/dist/collection/components/q2-stepper-vertical/styles.css +1 -0
- package/dist/collection/components/q2-tab-container/styles.css +1 -0
- package/dist/collection/components/q2-tab-pane/styles.css +1 -0
- package/dist/collection/components/q2-tag/styles.css +1 -0
- package/dist/collection/components/q2-textarea/styles.css +1 -0
- package/dist/collection/components/q2-tooltip/styles.css +1 -0
- package/dist/collection/components/tecton-tab-pane/styles.css +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/q2-avatar.entry.js +1 -1
- package/dist/esm/q2-badge_2.entry.js +9 -3
- package/dist/esm/q2-btn_2.entry.js +2 -2
- package/dist/esm/q2-calendar.entry.js +1041 -1131
- package/dist/esm/q2-card.entry.js +1 -1
- package/dist/esm/q2-carousel-pane.entry.js +1 -1
- package/dist/esm/q2-carousel.entry.js +1 -1
- package/dist/esm/q2-chart-donut.entry.js +21 -3
- package/dist/esm/q2-checkbox-group.entry.js +1 -1
- package/dist/esm/q2-checkbox.entry.js +1 -1
- package/dist/esm/q2-dropdown-item.entry.js +1 -1
- package/dist/esm/q2-dropdown.entry.js +1 -1
- package/dist/esm/q2-editable-field.entry.js +1 -1
- package/dist/esm/q2-icon.entry.js +1 -1
- package/dist/esm/q2-loc.entry.js +1 -1
- package/dist/esm/q2-message.entry.js +1 -1
- package/dist/esm/q2-optgroup.entry.js +1 -1
- package/dist/esm/q2-option-list.entry.js +1 -1
- package/dist/esm/q2-option.entry.js +1 -1
- package/dist/esm/q2-pagination.entry.js +1 -1
- package/dist/esm/q2-pill.entry.js +1 -1
- package/dist/esm/q2-radio-group.entry.js +2 -2
- package/dist/esm/q2-radio.entry.js +1 -1
- package/dist/esm/q2-section.entry.js +55 -81
- package/dist/esm/q2-select.entry.js +1 -1
- package/dist/esm/q2-stepper-pane.entry.js +1 -1
- package/dist/esm/q2-stepper-vertical.entry.js +1 -1
- package/dist/esm/q2-stepper.entry.js +1 -1
- package/dist/esm/q2-tab-container.entry.js +1 -1
- package/dist/esm/q2-tab-pane.entry.js +1 -1
- package/dist/esm/q2-tag.entry.js +1 -1
- package/dist/esm/q2-tecton-elements.js +1 -1
- package/dist/esm/q2-textarea.entry.js +1 -1
- package/dist/esm/q2-tooltip.entry.js +1 -1
- package/dist/esm/tecton-tab-pane.entry.js +1 -1
- package/dist/q2-tecton-elements/p-06865cf5.entry.js +1 -0
- package/dist/q2-tecton-elements/p-0d849ed4.entry.js +1 -0
- package/dist/q2-tecton-elements/p-2a217895.entry.js +1 -0
- package/dist/q2-tecton-elements/p-2b94ae62.entry.js +1 -0
- package/dist/q2-tecton-elements/p-2faed36b.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-f617c54a.entry.js → p-30a4fdfb.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-30f81b22.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-677faf2c.entry.js → p-31070ab8.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-318758d4.entry.js +1 -0
- package/dist/q2-tecton-elements/p-41c22a16.entry.js +1 -0
- package/dist/q2-tecton-elements/p-445e7c45.entry.js +1 -0
- package/dist/q2-tecton-elements/p-44bdaf52.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-60a7a11e.entry.js → p-4c53713d.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-b6c45ef6.entry.js → p-4da9b6b6.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-5acb7ec6.entry.js +1 -0
- package/dist/q2-tecton-elements/p-64605d17.entry.js +1 -0
- package/dist/q2-tecton-elements/p-64ca8c59.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-0e9c7220.entry.js → p-654fcd6b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-b7dc4e93.entry.js → p-661c2092.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-732dafd0.entry.js +1 -0
- package/dist/q2-tecton-elements/p-815c8a7d.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-822d3d6c.entry.js → p-824a1d7c.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-4b48fde6.entry.js → p-8543a0e1.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-916fd90b.entry.js +1 -0
- package/dist/q2-tecton-elements/p-94b3c534.entry.js +1 -0
- package/dist/q2-tecton-elements/p-a45c6b65.entry.js +1 -0
- package/dist/q2-tecton-elements/p-a659d112.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-879aa7ac.entry.js → p-b4b8f85c.entry.js} +3 -3
- package/dist/q2-tecton-elements/{p-92e9f290.entry.js → p-b595b415.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-5270b0ff.entry.js → p-cde0cdff.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-dd3f64a7.entry.js → p-d3e4cc5d.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-d781e2d9.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-dd792081.entry.js → p-d8d9e8eb.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-fbf23146.entry.js +1 -0
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
- package/dist/test/helpers.js +2 -2
- package/dist/types/components/q2-chart-donut/index.d.ts +12 -21
- package/dist/types/components/q2-input/index.d.ts +1 -0
- package/dist/types/components/q2-section/index.d.ts +11 -18
- package/dist/types/components.d.ts +5 -2
- package/dist/types/workspace/workspace/{tecton-production_release_1.16.x → Tecton_tecton-production_master}/packages/q2-tecton-elements/.stencil/test/elements/q2-tag-test.d.ts +0 -0
- package/dist/types/workspace/workspace/{tecton-production_release_1.16.x → Tecton_tecton-production_master}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +0 -0
- package/package.json +2 -2
- package/dist/q2-tecton-elements/p-0a8b8d14.entry.js +0 -1
- package/dist/q2-tecton-elements/p-0b5fbbe8.entry.js +0 -1
- package/dist/q2-tecton-elements/p-0d00030f.entry.js +0 -1
- package/dist/q2-tecton-elements/p-1b0f826e.entry.js +0 -1
- package/dist/q2-tecton-elements/p-1c430c2a.entry.js +0 -1
- package/dist/q2-tecton-elements/p-2d2008fd.entry.js +0 -1
- package/dist/q2-tecton-elements/p-34f99830.entry.js +0 -1
- package/dist/q2-tecton-elements/p-35bde69c.entry.js +0 -1
- package/dist/q2-tecton-elements/p-376988ef.entry.js +0 -1
- package/dist/q2-tecton-elements/p-49612230.entry.js +0 -1
- package/dist/q2-tecton-elements/p-4ec2cb69.entry.js +0 -1
- package/dist/q2-tecton-elements/p-5e990654.entry.js +0 -1
- package/dist/q2-tecton-elements/p-6e10db80.entry.js +0 -1
- package/dist/q2-tecton-elements/p-6f884c60.entry.js +0 -1
- package/dist/q2-tecton-elements/p-8584c6bc.entry.js +0 -1
- package/dist/q2-tecton-elements/p-87766054.entry.js +0 -1
- package/dist/q2-tecton-elements/p-c59d601e.entry.js +0 -1
- package/dist/q2-tecton-elements/p-d040bf99.entry.js +0 -1
- package/dist/q2-tecton-elements/p-d79386c6.entry.js +0 -1
- package/dist/q2-tecton-elements/p-ef2f68b2.entry.js +0 -1
- package/dist/q2-tecton-elements/p-f66adef0.entry.js +0 -1
|
@@ -68,7 +68,7 @@ function toDate(argument) {
|
|
|
68
68
|
} else {
|
|
69
69
|
if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
|
|
70
70
|
// eslint-disable-next-line no-console
|
|
71
|
-
console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://
|
|
71
|
+
console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"); // eslint-disable-next-line no-console
|
|
72
72
|
|
|
73
73
|
console.warn(new Error().stack);
|
|
74
74
|
}
|
|
@@ -85,10 +85,6 @@ function toDate(argument) {
|
|
|
85
85
|
* @description
|
|
86
86
|
* Add the specified number of days to the given date.
|
|
87
87
|
*
|
|
88
|
-
* ### v2.0.0 breaking changes:
|
|
89
|
-
*
|
|
90
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
91
|
-
*
|
|
92
88
|
* @param {Date|Number} date - the date to be changed
|
|
93
89
|
* @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
94
90
|
* @returns {Date} - the new date with the days added
|
|
@@ -126,10 +122,6 @@ function addDays(dirtyDate, dirtyAmount) {
|
|
|
126
122
|
* @description
|
|
127
123
|
* Add the specified number of milliseconds to the given date.
|
|
128
124
|
*
|
|
129
|
-
* ### v2.0.0 breaking changes:
|
|
130
|
-
*
|
|
131
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
132
|
-
*
|
|
133
125
|
* @param {Date|Number} date - the date to be changed
|
|
134
126
|
* @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`.
|
|
135
127
|
* @returns {Date} the new date with the milliseconds added
|
|
@@ -148,6 +140,11 @@ function addMilliseconds(dirtyDate, dirtyAmount) {
|
|
|
148
140
|
return new Date(timestamp + amount);
|
|
149
141
|
}
|
|
150
142
|
|
|
143
|
+
var defaultOptions = {};
|
|
144
|
+
function getDefaultOptions() {
|
|
145
|
+
return defaultOptions;
|
|
146
|
+
}
|
|
147
|
+
|
|
151
148
|
/**
|
|
152
149
|
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
|
|
153
150
|
* They usually appear for dates that denote time before the timezones were introduced
|
|
@@ -174,10 +171,6 @@ function getTimezoneOffsetInMilliseconds(date) {
|
|
|
174
171
|
* Return the start of a day for the given date.
|
|
175
172
|
* The result will be in the local timezone.
|
|
176
173
|
*
|
|
177
|
-
* ### v2.0.0 breaking changes:
|
|
178
|
-
*
|
|
179
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
180
|
-
*
|
|
181
174
|
* @param {Date|Number} date - the original date
|
|
182
175
|
* @returns {Date} the start of a day
|
|
183
176
|
* @throws {TypeError} 1 argument required
|
|
@@ -203,10 +196,6 @@ function startOfDay(dirtyDate) {
|
|
|
203
196
|
* @description
|
|
204
197
|
* Are the given dates in the same day (and year and month)?
|
|
205
198
|
*
|
|
206
|
-
* ### v2.0.0 breaking changes:
|
|
207
|
-
*
|
|
208
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
209
|
-
*
|
|
210
199
|
* @param {Date|Number} dateLeft - the first date to check
|
|
211
200
|
* @param {Date|Number} dateRight - the second date to check
|
|
212
201
|
* @returns {Boolean} the dates are in the same day (and year and month)
|
|
@@ -214,17 +203,17 @@ function startOfDay(dirtyDate) {
|
|
|
214
203
|
*
|
|
215
204
|
* @example
|
|
216
205
|
* // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
|
|
217
|
-
*
|
|
206
|
+
* const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
|
|
218
207
|
* //=> true
|
|
219
|
-
*
|
|
208
|
+
*
|
|
220
209
|
* @example
|
|
221
210
|
* // Are 4 September and 4 October in the same day?
|
|
222
|
-
*
|
|
211
|
+
* const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))
|
|
223
212
|
* //=> false
|
|
224
|
-
*
|
|
213
|
+
*
|
|
225
214
|
* @example
|
|
226
215
|
* // Are 4 September, 2014 and 4 September, 2015 in the same day?
|
|
227
|
-
*
|
|
216
|
+
* const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))
|
|
228
217
|
* //=> false
|
|
229
218
|
*/
|
|
230
219
|
|
|
@@ -243,10 +232,6 @@ function isSameDay(dirtyDateLeft, dirtyDateRight) {
|
|
|
243
232
|
* @description
|
|
244
233
|
* Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
|
|
245
234
|
*
|
|
246
|
-
* ### v2.0.0 breaking changes:
|
|
247
|
-
*
|
|
248
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
249
|
-
*
|
|
250
235
|
* @param {*} value - the value to check
|
|
251
236
|
* @returns {boolean} true if the given value is a date
|
|
252
237
|
* @throws {TypeError} 1 arguments required
|
|
@@ -289,32 +274,6 @@ function isDate(value) {
|
|
|
289
274
|
*
|
|
290
275
|
* Time value of Date: http://es5.github.io/#x15.9.1.1
|
|
291
276
|
*
|
|
292
|
-
* ### v2.0.0 breaking changes:
|
|
293
|
-
*
|
|
294
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
295
|
-
*
|
|
296
|
-
* - Now `isValid` doesn't throw an exception
|
|
297
|
-
* if the first argument is not an instance of Date.
|
|
298
|
-
* Instead, argument is converted beforehand using `toDate`.
|
|
299
|
-
*
|
|
300
|
-
* Examples:
|
|
301
|
-
*
|
|
302
|
-
* | `isValid` argument | Before v2.0.0 | v2.0.0 onward |
|
|
303
|
-
* |---------------------------|---------------|---------------|
|
|
304
|
-
* | `new Date()` | `true` | `true` |
|
|
305
|
-
* | `new Date('2016-01-01')` | `true` | `true` |
|
|
306
|
-
* | `new Date('')` | `false` | `false` |
|
|
307
|
-
* | `new Date(1488370835081)` | `true` | `true` |
|
|
308
|
-
* | `new Date(NaN)` | `false` | `false` |
|
|
309
|
-
* | `'2016-01-01'` | `TypeError` | `false` |
|
|
310
|
-
* | `''` | `TypeError` | `false` |
|
|
311
|
-
* | `1488370835081` | `TypeError` | `true` |
|
|
312
|
-
* | `NaN` | `TypeError` | `false` |
|
|
313
|
-
*
|
|
314
|
-
* We introduce this change to make *date-fns* consistent with ECMAScript behavior
|
|
315
|
-
* that try to coerce arguments to the expected type
|
|
316
|
-
* (which is also the case with other *date-fns* functions).
|
|
317
|
-
*
|
|
318
277
|
* @param {*} date - the date to check
|
|
319
278
|
* @returns {Boolean} the date is valid
|
|
320
279
|
* @throws {TypeError} 1 argument required
|
|
@@ -346,643 +305,124 @@ function isValid(dirtyDate) {
|
|
|
346
305
|
return !isNaN(Number(date));
|
|
347
306
|
}
|
|
348
307
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
aboutXHours: {
|
|
368
|
-
one: 'about 1 hour',
|
|
369
|
-
other: 'about {{count}} hours'
|
|
370
|
-
},
|
|
371
|
-
xHours: {
|
|
372
|
-
one: '1 hour',
|
|
373
|
-
other: '{{count}} hours'
|
|
374
|
-
},
|
|
375
|
-
xDays: {
|
|
376
|
-
one: '1 day',
|
|
377
|
-
other: '{{count}} days'
|
|
378
|
-
},
|
|
379
|
-
aboutXWeeks: {
|
|
380
|
-
one: 'about 1 week',
|
|
381
|
-
other: 'about {{count}} weeks'
|
|
382
|
-
},
|
|
383
|
-
xWeeks: {
|
|
384
|
-
one: '1 week',
|
|
385
|
-
other: '{{count}} weeks'
|
|
386
|
-
},
|
|
387
|
-
aboutXMonths: {
|
|
388
|
-
one: 'about 1 month',
|
|
389
|
-
other: 'about {{count}} months'
|
|
390
|
-
},
|
|
391
|
-
xMonths: {
|
|
392
|
-
one: '1 month',
|
|
393
|
-
other: '{{count}} months'
|
|
394
|
-
},
|
|
395
|
-
aboutXYears: {
|
|
396
|
-
one: 'about 1 year',
|
|
397
|
-
other: 'about {{count}} years'
|
|
398
|
-
},
|
|
399
|
-
xYears: {
|
|
400
|
-
one: '1 year',
|
|
401
|
-
other: '{{count}} years'
|
|
402
|
-
},
|
|
403
|
-
overXYears: {
|
|
404
|
-
one: 'over 1 year',
|
|
405
|
-
other: 'over {{count}} years'
|
|
406
|
-
},
|
|
407
|
-
almostXYears: {
|
|
408
|
-
one: 'almost 1 year',
|
|
409
|
-
other: 'almost {{count}} years'
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
var formatDistance = function (token, count, options) {
|
|
414
|
-
var result;
|
|
415
|
-
var tokenValue = formatDistanceLocale[token];
|
|
416
|
-
|
|
417
|
-
if (typeof tokenValue === 'string') {
|
|
418
|
-
result = tokenValue;
|
|
419
|
-
} else if (count === 1) {
|
|
420
|
-
result = tokenValue.one;
|
|
421
|
-
} else {
|
|
422
|
-
result = tokenValue.other.replace('{{count}}', count.toString());
|
|
423
|
-
}
|
|
308
|
+
/**
|
|
309
|
+
* @name subMilliseconds
|
|
310
|
+
* @category Millisecond Helpers
|
|
311
|
+
* @summary Subtract the specified number of milliseconds from the given date.
|
|
312
|
+
*
|
|
313
|
+
* @description
|
|
314
|
+
* Subtract the specified number of milliseconds from the given date.
|
|
315
|
+
*
|
|
316
|
+
* @param {Date|Number} date - the date to be changed
|
|
317
|
+
* @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`.
|
|
318
|
+
* @returns {Date} the new date with the milliseconds subtracted
|
|
319
|
+
* @throws {TypeError} 2 arguments required
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
|
|
323
|
+
* const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
|
|
324
|
+
* //=> Thu Jul 10 2014 12:45:29.250
|
|
325
|
+
*/
|
|
424
326
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
}
|
|
327
|
+
function subMilliseconds(dirtyDate, dirtyAmount) {
|
|
328
|
+
requiredArgs(2, arguments);
|
|
329
|
+
var amount = toInteger(dirtyAmount);
|
|
330
|
+
return addMilliseconds(dirtyDate, -amount);
|
|
331
|
+
}
|
|
432
332
|
|
|
433
|
-
|
|
434
|
-
|
|
333
|
+
var MILLISECONDS_IN_DAY = 86400000;
|
|
334
|
+
function getUTCDayOfYear(dirtyDate) {
|
|
335
|
+
requiredArgs(1, arguments);
|
|
336
|
+
var date = toDate(dirtyDate);
|
|
337
|
+
var timestamp = date.getTime();
|
|
338
|
+
date.setUTCMonth(0, 1);
|
|
339
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
340
|
+
var startOfYearTimestamp = date.getTime();
|
|
341
|
+
var difference = timestamp - startOfYearTimestamp;
|
|
342
|
+
return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
|
|
343
|
+
}
|
|
435
344
|
|
|
436
|
-
function
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
345
|
+
function startOfUTCISOWeek(dirtyDate) {
|
|
346
|
+
requiredArgs(1, arguments);
|
|
347
|
+
var weekStartsOn = 1;
|
|
348
|
+
var date = toDate(dirtyDate);
|
|
349
|
+
var day = date.getUTCDay();
|
|
350
|
+
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
351
|
+
date.setUTCDate(date.getUTCDate() - diff);
|
|
352
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
353
|
+
return date;
|
|
444
354
|
}
|
|
445
355
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
var dateTimeFormats = {
|
|
459
|
-
full: "{{date}} 'at' {{time}}",
|
|
460
|
-
long: "{{date}} 'at' {{time}}",
|
|
461
|
-
medium: '{{date}}, {{time}}',
|
|
462
|
-
short: '{{date}}, {{time}}'
|
|
463
|
-
};
|
|
464
|
-
var formatLong = {
|
|
465
|
-
date: buildFormatLongFn({
|
|
466
|
-
formats: dateFormats,
|
|
467
|
-
defaultWidth: 'full'
|
|
468
|
-
}),
|
|
469
|
-
time: buildFormatLongFn({
|
|
470
|
-
formats: timeFormats,
|
|
471
|
-
defaultWidth: 'full'
|
|
472
|
-
}),
|
|
473
|
-
dateTime: buildFormatLongFn({
|
|
474
|
-
formats: dateTimeFormats,
|
|
475
|
-
defaultWidth: 'full'
|
|
476
|
-
})
|
|
477
|
-
};
|
|
356
|
+
function getUTCISOWeekYear(dirtyDate) {
|
|
357
|
+
requiredArgs(1, arguments);
|
|
358
|
+
var date = toDate(dirtyDate);
|
|
359
|
+
var year = date.getUTCFullYear();
|
|
360
|
+
var fourthOfJanuaryOfNextYear = new Date(0);
|
|
361
|
+
fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
|
|
362
|
+
fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
|
|
363
|
+
var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
|
|
364
|
+
var fourthOfJanuaryOfThisYear = new Date(0);
|
|
365
|
+
fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
|
|
366
|
+
fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
|
|
367
|
+
var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
|
|
478
368
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
369
|
+
if (date.getTime() >= startOfNextYear.getTime()) {
|
|
370
|
+
return year + 1;
|
|
371
|
+
} else if (date.getTime() >= startOfThisYear.getTime()) {
|
|
372
|
+
return year;
|
|
373
|
+
} else {
|
|
374
|
+
return year - 1;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
487
377
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
378
|
+
function startOfUTCISOWeekYear(dirtyDate) {
|
|
379
|
+
requiredArgs(1, arguments);
|
|
380
|
+
var year = getUTCISOWeekYear(dirtyDate);
|
|
381
|
+
var fourthOfJanuary = new Date(0);
|
|
382
|
+
fourthOfJanuary.setUTCFullYear(year, 0, 4);
|
|
383
|
+
fourthOfJanuary.setUTCHours(0, 0, 0, 0);
|
|
384
|
+
var date = startOfUTCISOWeek(fourthOfJanuary);
|
|
385
|
+
return date;
|
|
386
|
+
}
|
|
491
387
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
388
|
+
var MILLISECONDS_IN_WEEK$1 = 604800000;
|
|
389
|
+
function getUTCISOWeek(dirtyDate) {
|
|
390
|
+
requiredArgs(1, arguments);
|
|
391
|
+
var date = toDate(dirtyDate);
|
|
392
|
+
var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); // Round the number of days to the nearest integer
|
|
393
|
+
// because the number of milliseconds in a week is not constant
|
|
394
|
+
// (e.g. it's different in the week of the daylight saving time clock shift)
|
|
497
395
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
var width = options.width ? String(options.width) : defaultWidth;
|
|
501
|
-
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
|
|
502
|
-
} else {
|
|
503
|
-
var _defaultWidth = args.defaultWidth;
|
|
396
|
+
return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
|
|
397
|
+
}
|
|
504
398
|
|
|
505
|
-
|
|
399
|
+
function startOfUTCWeek(dirtyDate, options) {
|
|
400
|
+
var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
506
401
|
|
|
507
|
-
|
|
508
|
-
|
|
402
|
+
requiredArgs(1, arguments);
|
|
403
|
+
var defaultOptions = getDefaultOptions();
|
|
404
|
+
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); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
|
|
509
405
|
|
|
510
|
-
|
|
406
|
+
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
|
|
407
|
+
throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
|
|
408
|
+
}
|
|
511
409
|
|
|
512
|
-
|
|
513
|
-
|
|
410
|
+
var date = toDate(dirtyDate);
|
|
411
|
+
var day = date.getUTCDay();
|
|
412
|
+
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
413
|
+
date.setUTCDate(date.getUTCDate() - diff);
|
|
414
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
415
|
+
return date;
|
|
514
416
|
}
|
|
515
417
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
abbreviated: ['BC', 'AD'],
|
|
519
|
-
wide: ['Before Christ', 'Anno Domini']
|
|
520
|
-
};
|
|
521
|
-
var quarterValues = {
|
|
522
|
-
narrow: ['1', '2', '3', '4'],
|
|
523
|
-
abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
|
|
524
|
-
wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
|
|
525
|
-
}; // Note: in English, the names of days of the week and months are capitalized.
|
|
526
|
-
// If you are making a new locale based on this one, check if the same is true for the language you're working on.
|
|
527
|
-
// Generally, formatted dates should look like they are in the middle of a sentence,
|
|
528
|
-
// e.g. in Spanish language the weekdays and months should be in the lowercase.
|
|
529
|
-
|
|
530
|
-
var monthValues = {
|
|
531
|
-
narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
|
|
532
|
-
abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
533
|
-
wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
|
534
|
-
};
|
|
535
|
-
var dayValues = {
|
|
536
|
-
narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
|
|
537
|
-
short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
|
538
|
-
abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
539
|
-
wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
|
|
540
|
-
};
|
|
541
|
-
var dayPeriodValues = {
|
|
542
|
-
narrow: {
|
|
543
|
-
am: 'a',
|
|
544
|
-
pm: 'p',
|
|
545
|
-
midnight: 'mi',
|
|
546
|
-
noon: 'n',
|
|
547
|
-
morning: 'morning',
|
|
548
|
-
afternoon: 'afternoon',
|
|
549
|
-
evening: 'evening',
|
|
550
|
-
night: 'night'
|
|
551
|
-
},
|
|
552
|
-
abbreviated: {
|
|
553
|
-
am: 'AM',
|
|
554
|
-
pm: 'PM',
|
|
555
|
-
midnight: 'midnight',
|
|
556
|
-
noon: 'noon',
|
|
557
|
-
morning: 'morning',
|
|
558
|
-
afternoon: 'afternoon',
|
|
559
|
-
evening: 'evening',
|
|
560
|
-
night: 'night'
|
|
561
|
-
},
|
|
562
|
-
wide: {
|
|
563
|
-
am: 'a.m.',
|
|
564
|
-
pm: 'p.m.',
|
|
565
|
-
midnight: 'midnight',
|
|
566
|
-
noon: 'noon',
|
|
567
|
-
morning: 'morning',
|
|
568
|
-
afternoon: 'afternoon',
|
|
569
|
-
evening: 'evening',
|
|
570
|
-
night: 'night'
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
var formattingDayPeriodValues = {
|
|
574
|
-
narrow: {
|
|
575
|
-
am: 'a',
|
|
576
|
-
pm: 'p',
|
|
577
|
-
midnight: 'mi',
|
|
578
|
-
noon: 'n',
|
|
579
|
-
morning: 'in the morning',
|
|
580
|
-
afternoon: 'in the afternoon',
|
|
581
|
-
evening: 'in the evening',
|
|
582
|
-
night: 'at night'
|
|
583
|
-
},
|
|
584
|
-
abbreviated: {
|
|
585
|
-
am: 'AM',
|
|
586
|
-
pm: 'PM',
|
|
587
|
-
midnight: 'midnight',
|
|
588
|
-
noon: 'noon',
|
|
589
|
-
morning: 'in the morning',
|
|
590
|
-
afternoon: 'in the afternoon',
|
|
591
|
-
evening: 'in the evening',
|
|
592
|
-
night: 'at night'
|
|
593
|
-
},
|
|
594
|
-
wide: {
|
|
595
|
-
am: 'a.m.',
|
|
596
|
-
pm: 'p.m.',
|
|
597
|
-
midnight: 'midnight',
|
|
598
|
-
noon: 'noon',
|
|
599
|
-
morning: 'in the morning',
|
|
600
|
-
afternoon: 'in the afternoon',
|
|
601
|
-
evening: 'in the evening',
|
|
602
|
-
night: 'at night'
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
|
|
606
|
-
var ordinalNumber = function (dirtyNumber, _options) {
|
|
607
|
-
var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
|
|
608
|
-
// if they are different for different grammatical genders,
|
|
609
|
-
// use `options.unit`.
|
|
610
|
-
//
|
|
611
|
-
// `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
|
|
612
|
-
// 'day', 'hour', 'minute', 'second'.
|
|
613
|
-
|
|
614
|
-
var rem100 = number % 100;
|
|
615
|
-
|
|
616
|
-
if (rem100 > 20 || rem100 < 10) {
|
|
617
|
-
switch (rem100 % 10) {
|
|
618
|
-
case 1:
|
|
619
|
-
return number + 'st';
|
|
620
|
-
|
|
621
|
-
case 2:
|
|
622
|
-
return number + 'nd';
|
|
623
|
-
|
|
624
|
-
case 3:
|
|
625
|
-
return number + 'rd';
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
return number + 'th';
|
|
630
|
-
};
|
|
631
|
-
|
|
632
|
-
var localize = {
|
|
633
|
-
ordinalNumber: ordinalNumber,
|
|
634
|
-
era: buildLocalizeFn({
|
|
635
|
-
values: eraValues,
|
|
636
|
-
defaultWidth: 'wide'
|
|
637
|
-
}),
|
|
638
|
-
quarter: buildLocalizeFn({
|
|
639
|
-
values: quarterValues,
|
|
640
|
-
defaultWidth: 'wide',
|
|
641
|
-
argumentCallback: function (quarter) {
|
|
642
|
-
return quarter - 1;
|
|
643
|
-
}
|
|
644
|
-
}),
|
|
645
|
-
month: buildLocalizeFn({
|
|
646
|
-
values: monthValues,
|
|
647
|
-
defaultWidth: 'wide'
|
|
648
|
-
}),
|
|
649
|
-
day: buildLocalizeFn({
|
|
650
|
-
values: dayValues,
|
|
651
|
-
defaultWidth: 'wide'
|
|
652
|
-
}),
|
|
653
|
-
dayPeriod: buildLocalizeFn({
|
|
654
|
-
values: dayPeriodValues,
|
|
655
|
-
defaultWidth: 'wide',
|
|
656
|
-
formattingValues: formattingDayPeriodValues,
|
|
657
|
-
defaultFormattingWidth: 'wide'
|
|
658
|
-
})
|
|
659
|
-
};
|
|
660
|
-
|
|
661
|
-
function buildMatchFn(args) {
|
|
662
|
-
return function (string) {
|
|
663
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
664
|
-
var width = options.width;
|
|
665
|
-
var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
|
|
666
|
-
var matchResult = string.match(matchPattern);
|
|
667
|
-
|
|
668
|
-
if (!matchResult) {
|
|
669
|
-
return null;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
var matchedString = matchResult[0];
|
|
673
|
-
var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
|
|
674
|
-
var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
|
|
675
|
-
return pattern.test(matchedString);
|
|
676
|
-
}) : findKey(parsePatterns, function (pattern) {
|
|
677
|
-
return pattern.test(matchedString);
|
|
678
|
-
});
|
|
679
|
-
var value;
|
|
680
|
-
value = args.valueCallback ? args.valueCallback(key) : key;
|
|
681
|
-
value = options.valueCallback ? options.valueCallback(value) : value;
|
|
682
|
-
var rest = string.slice(matchedString.length);
|
|
683
|
-
return {
|
|
684
|
-
value: value,
|
|
685
|
-
rest: rest
|
|
686
|
-
};
|
|
687
|
-
};
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
function findKey(object, predicate) {
|
|
691
|
-
for (var key in object) {
|
|
692
|
-
if (object.hasOwnProperty(key) && predicate(object[key])) {
|
|
693
|
-
return key;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
return undefined;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
function findIndex(array, predicate) {
|
|
701
|
-
for (var key = 0; key < array.length; key++) {
|
|
702
|
-
if (predicate(array[key])) {
|
|
703
|
-
return key;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
return undefined;
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
function buildMatchPatternFn(args) {
|
|
711
|
-
return function (string) {
|
|
712
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
713
|
-
var matchResult = string.match(args.matchPattern);
|
|
714
|
-
if (!matchResult) return null;
|
|
715
|
-
var matchedString = matchResult[0];
|
|
716
|
-
var parseResult = string.match(args.parsePattern);
|
|
717
|
-
if (!parseResult) return null;
|
|
718
|
-
var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
|
|
719
|
-
value = options.valueCallback ? options.valueCallback(value) : value;
|
|
720
|
-
var rest = string.slice(matchedString.length);
|
|
721
|
-
return {
|
|
722
|
-
value: value,
|
|
723
|
-
rest: rest
|
|
724
|
-
};
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
|
|
729
|
-
var parseOrdinalNumberPattern = /\d+/i;
|
|
730
|
-
var matchEraPatterns = {
|
|
731
|
-
narrow: /^(b|a)/i,
|
|
732
|
-
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
|
|
733
|
-
wide: /^(before christ|before common era|anno domini|common era)/i
|
|
734
|
-
};
|
|
735
|
-
var parseEraPatterns = {
|
|
736
|
-
any: [/^b/i, /^(a|c)/i]
|
|
737
|
-
};
|
|
738
|
-
var matchQuarterPatterns = {
|
|
739
|
-
narrow: /^[1234]/i,
|
|
740
|
-
abbreviated: /^q[1234]/i,
|
|
741
|
-
wide: /^[1234](th|st|nd|rd)? quarter/i
|
|
742
|
-
};
|
|
743
|
-
var parseQuarterPatterns = {
|
|
744
|
-
any: [/1/i, /2/i, /3/i, /4/i]
|
|
745
|
-
};
|
|
746
|
-
var matchMonthPatterns = {
|
|
747
|
-
narrow: /^[jfmasond]/i,
|
|
748
|
-
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
|
|
749
|
-
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
|
|
750
|
-
};
|
|
751
|
-
var parseMonthPatterns = {
|
|
752
|
-
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],
|
|
753
|
-
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]
|
|
754
|
-
};
|
|
755
|
-
var matchDayPatterns = {
|
|
756
|
-
narrow: /^[smtwf]/i,
|
|
757
|
-
short: /^(su|mo|tu|we|th|fr|sa)/i,
|
|
758
|
-
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
|
|
759
|
-
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
|
|
760
|
-
};
|
|
761
|
-
var parseDayPatterns = {
|
|
762
|
-
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
|
|
763
|
-
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
|
|
764
|
-
};
|
|
765
|
-
var matchDayPeriodPatterns = {
|
|
766
|
-
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
|
|
767
|
-
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
|
|
768
|
-
};
|
|
769
|
-
var parseDayPeriodPatterns = {
|
|
770
|
-
any: {
|
|
771
|
-
am: /^a/i,
|
|
772
|
-
pm: /^p/i,
|
|
773
|
-
midnight: /^mi/i,
|
|
774
|
-
noon: /^no/i,
|
|
775
|
-
morning: /morning/i,
|
|
776
|
-
afternoon: /afternoon/i,
|
|
777
|
-
evening: /evening/i,
|
|
778
|
-
night: /night/i
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
var match = {
|
|
782
|
-
ordinalNumber: buildMatchPatternFn({
|
|
783
|
-
matchPattern: matchOrdinalNumberPattern,
|
|
784
|
-
parsePattern: parseOrdinalNumberPattern,
|
|
785
|
-
valueCallback: function (value) {
|
|
786
|
-
return parseInt(value, 10);
|
|
787
|
-
}
|
|
788
|
-
}),
|
|
789
|
-
era: buildMatchFn({
|
|
790
|
-
matchPatterns: matchEraPatterns,
|
|
791
|
-
defaultMatchWidth: 'wide',
|
|
792
|
-
parsePatterns: parseEraPatterns,
|
|
793
|
-
defaultParseWidth: 'any'
|
|
794
|
-
}),
|
|
795
|
-
quarter: buildMatchFn({
|
|
796
|
-
matchPatterns: matchQuarterPatterns,
|
|
797
|
-
defaultMatchWidth: 'wide',
|
|
798
|
-
parsePatterns: parseQuarterPatterns,
|
|
799
|
-
defaultParseWidth: 'any',
|
|
800
|
-
valueCallback: function (index) {
|
|
801
|
-
return index + 1;
|
|
802
|
-
}
|
|
803
|
-
}),
|
|
804
|
-
month: buildMatchFn({
|
|
805
|
-
matchPatterns: matchMonthPatterns,
|
|
806
|
-
defaultMatchWidth: 'wide',
|
|
807
|
-
parsePatterns: parseMonthPatterns,
|
|
808
|
-
defaultParseWidth: 'any'
|
|
809
|
-
}),
|
|
810
|
-
day: buildMatchFn({
|
|
811
|
-
matchPatterns: matchDayPatterns,
|
|
812
|
-
defaultMatchWidth: 'wide',
|
|
813
|
-
parsePatterns: parseDayPatterns,
|
|
814
|
-
defaultParseWidth: 'any'
|
|
815
|
-
}),
|
|
816
|
-
dayPeriod: buildMatchFn({
|
|
817
|
-
matchPatterns: matchDayPeriodPatterns,
|
|
818
|
-
defaultMatchWidth: 'any',
|
|
819
|
-
parsePatterns: parseDayPeriodPatterns,
|
|
820
|
-
defaultParseWidth: 'any'
|
|
821
|
-
})
|
|
822
|
-
};
|
|
823
|
-
|
|
824
|
-
/**
|
|
825
|
-
* @type {Locale}
|
|
826
|
-
* @category Locales
|
|
827
|
-
* @summary English locale (United States).
|
|
828
|
-
* @language English
|
|
829
|
-
* @iso-639-2 eng
|
|
830
|
-
* @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
|
|
831
|
-
* @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
|
|
832
|
-
*/
|
|
833
|
-
var locale = {
|
|
834
|
-
code: 'en-US',
|
|
835
|
-
formatDistance: formatDistance,
|
|
836
|
-
formatLong: formatLong,
|
|
837
|
-
formatRelative: formatRelative,
|
|
838
|
-
localize: localize,
|
|
839
|
-
match: match,
|
|
840
|
-
options: {
|
|
841
|
-
weekStartsOn: 0
|
|
842
|
-
/* Sunday */
|
|
843
|
-
,
|
|
844
|
-
firstWeekContainsDate: 1
|
|
845
|
-
}
|
|
846
|
-
};
|
|
847
|
-
|
|
848
|
-
/**
|
|
849
|
-
* @name subMilliseconds
|
|
850
|
-
* @category Millisecond Helpers
|
|
851
|
-
* @summary Subtract the specified number of milliseconds from the given date.
|
|
852
|
-
*
|
|
853
|
-
* @description
|
|
854
|
-
* Subtract the specified number of milliseconds from the given date.
|
|
855
|
-
*
|
|
856
|
-
* ### v2.0.0 breaking changes:
|
|
857
|
-
*
|
|
858
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
859
|
-
*
|
|
860
|
-
* @param {Date|Number} date - the date to be changed
|
|
861
|
-
* @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`.
|
|
862
|
-
* @returns {Date} the new date with the milliseconds subtracted
|
|
863
|
-
* @throws {TypeError} 2 arguments required
|
|
864
|
-
*
|
|
865
|
-
* @example
|
|
866
|
-
* // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
|
|
867
|
-
* const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
|
|
868
|
-
* //=> Thu Jul 10 2014 12:45:29.250
|
|
869
|
-
*/
|
|
870
|
-
|
|
871
|
-
function subMilliseconds(dirtyDate, dirtyAmount) {
|
|
872
|
-
requiredArgs(2, arguments);
|
|
873
|
-
var amount = toInteger(dirtyAmount);
|
|
874
|
-
return addMilliseconds(dirtyDate, -amount);
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
var MILLISECONDS_IN_DAY = 86400000; // This function will be a part of public API when UTC function will be implemented.
|
|
878
|
-
// See issue: https://github.com/date-fns/date-fns/issues/376
|
|
879
|
-
|
|
880
|
-
function getUTCDayOfYear(dirtyDate) {
|
|
881
|
-
requiredArgs(1, arguments);
|
|
882
|
-
var date = toDate(dirtyDate);
|
|
883
|
-
var timestamp = date.getTime();
|
|
884
|
-
date.setUTCMonth(0, 1);
|
|
885
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
886
|
-
var startOfYearTimestamp = date.getTime();
|
|
887
|
-
var difference = timestamp - startOfYearTimestamp;
|
|
888
|
-
return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
// See issue: https://github.com/date-fns/date-fns/issues/376
|
|
892
|
-
|
|
893
|
-
function startOfUTCISOWeek(dirtyDate) {
|
|
894
|
-
requiredArgs(1, arguments);
|
|
895
|
-
var weekStartsOn = 1;
|
|
896
|
-
var date = toDate(dirtyDate);
|
|
897
|
-
var day = date.getUTCDay();
|
|
898
|
-
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
899
|
-
date.setUTCDate(date.getUTCDate() - diff);
|
|
900
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
901
|
-
return date;
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
// See issue: https://github.com/date-fns/date-fns/issues/376
|
|
905
|
-
|
|
906
|
-
function getUTCISOWeekYear(dirtyDate) {
|
|
907
|
-
requiredArgs(1, arguments);
|
|
908
|
-
var date = toDate(dirtyDate);
|
|
909
|
-
var year = date.getUTCFullYear();
|
|
910
|
-
var fourthOfJanuaryOfNextYear = new Date(0);
|
|
911
|
-
fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
|
|
912
|
-
fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
|
|
913
|
-
var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
|
|
914
|
-
var fourthOfJanuaryOfThisYear = new Date(0);
|
|
915
|
-
fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
|
|
916
|
-
fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
|
|
917
|
-
var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
|
|
918
|
-
|
|
919
|
-
if (date.getTime() >= startOfNextYear.getTime()) {
|
|
920
|
-
return year + 1;
|
|
921
|
-
} else if (date.getTime() >= startOfThisYear.getTime()) {
|
|
922
|
-
return year;
|
|
923
|
-
} else {
|
|
924
|
-
return year - 1;
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
// See issue: https://github.com/date-fns/date-fns/issues/376
|
|
929
|
-
|
|
930
|
-
function startOfUTCISOWeekYear(dirtyDate) {
|
|
931
|
-
requiredArgs(1, arguments);
|
|
932
|
-
var year = getUTCISOWeekYear(dirtyDate);
|
|
933
|
-
var fourthOfJanuary = new Date(0);
|
|
934
|
-
fourthOfJanuary.setUTCFullYear(year, 0, 4);
|
|
935
|
-
fourthOfJanuary.setUTCHours(0, 0, 0, 0);
|
|
936
|
-
var date = startOfUTCISOWeek(fourthOfJanuary);
|
|
937
|
-
return date;
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
var MILLISECONDS_IN_WEEK$1 = 604800000; // This function will be a part of public API when UTC function will be implemented.
|
|
941
|
-
// See issue: https://github.com/date-fns/date-fns/issues/376
|
|
942
|
-
|
|
943
|
-
function getUTCISOWeek(dirtyDate) {
|
|
944
|
-
requiredArgs(1, arguments);
|
|
945
|
-
var date = toDate(dirtyDate);
|
|
946
|
-
var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); // Round the number of days to the nearest integer
|
|
947
|
-
// because the number of milliseconds in a week is not constant
|
|
948
|
-
// (e.g. it's different in the week of the daylight saving time clock shift)
|
|
949
|
-
|
|
950
|
-
return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
// See issue: https://github.com/date-fns/date-fns/issues/376
|
|
954
|
-
|
|
955
|
-
function startOfUTCWeek(dirtyDate, dirtyOptions) {
|
|
956
|
-
requiredArgs(1, arguments);
|
|
957
|
-
var options = dirtyOptions || {};
|
|
958
|
-
var locale = options.locale;
|
|
959
|
-
var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn;
|
|
960
|
-
var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
|
|
961
|
-
var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
|
|
962
|
-
|
|
963
|
-
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
|
|
964
|
-
throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
var date = toDate(dirtyDate);
|
|
968
|
-
var day = date.getUTCDay();
|
|
969
|
-
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
970
|
-
date.setUTCDate(date.getUTCDate() - diff);
|
|
971
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
972
|
-
return date;
|
|
973
|
-
}
|
|
418
|
+
function getUTCWeekYear(dirtyDate, options) {
|
|
419
|
+
var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
974
420
|
|
|
975
|
-
// See issue: https://github.com/date-fns/date-fns/issues/376
|
|
976
|
-
|
|
977
|
-
function getUTCWeekYear(dirtyDate, dirtyOptions) {
|
|
978
421
|
requiredArgs(1, arguments);
|
|
979
422
|
var date = toDate(dirtyDate);
|
|
980
423
|
var year = date.getUTCFullYear();
|
|
981
|
-
var
|
|
982
|
-
var locale = options.locale;
|
|
983
|
-
var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
|
|
984
|
-
var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
|
|
985
|
-
var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
|
|
424
|
+
var defaultOptions = getDefaultOptions();
|
|
425
|
+
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); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
|
|
986
426
|
|
|
987
427
|
if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
|
|
988
428
|
throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
|
|
@@ -991,11 +431,11 @@ function getUTCWeekYear(dirtyDate, dirtyOptions) {
|
|
|
991
431
|
var firstWeekOfNextYear = new Date(0);
|
|
992
432
|
firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
|
|
993
433
|
firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
|
|
994
|
-
var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear,
|
|
434
|
+
var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
|
|
995
435
|
var firstWeekOfThisYear = new Date(0);
|
|
996
436
|
firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
|
|
997
437
|
firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
|
|
998
|
-
var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear,
|
|
438
|
+
var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
|
|
999
439
|
|
|
1000
440
|
if (date.getTime() >= startOfNextYear.getTime()) {
|
|
1001
441
|
return year + 1;
|
|
@@ -1006,26 +446,21 @@ function getUTCWeekYear(dirtyDate, dirtyOptions) {
|
|
|
1006
446
|
}
|
|
1007
447
|
}
|
|
1008
448
|
|
|
1009
|
-
|
|
449
|
+
function startOfUTCWeekYear(dirtyDate, options) {
|
|
450
|
+
var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
1010
451
|
|
|
1011
|
-
function startOfUTCWeekYear(dirtyDate, dirtyOptions) {
|
|
1012
452
|
requiredArgs(1, arguments);
|
|
1013
|
-
var
|
|
1014
|
-
var locale = options.locale;
|
|
1015
|
-
var
|
|
1016
|
-
var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
|
|
1017
|
-
var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
|
|
1018
|
-
var year = getUTCWeekYear(dirtyDate, dirtyOptions);
|
|
453
|
+
var defaultOptions = getDefaultOptions();
|
|
454
|
+
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);
|
|
455
|
+
var year = getUTCWeekYear(dirtyDate, options);
|
|
1019
456
|
var firstWeek = new Date(0);
|
|
1020
457
|
firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
|
|
1021
458
|
firstWeek.setUTCHours(0, 0, 0, 0);
|
|
1022
|
-
var date = startOfUTCWeek(firstWeek,
|
|
459
|
+
var date = startOfUTCWeek(firstWeek, options);
|
|
1023
460
|
return date;
|
|
1024
461
|
}
|
|
1025
462
|
|
|
1026
|
-
var MILLISECONDS_IN_WEEK = 604800000;
|
|
1027
|
-
// See issue: https://github.com/date-fns/date-fns/issues/376
|
|
1028
|
-
|
|
463
|
+
var MILLISECONDS_IN_WEEK = 604800000;
|
|
1029
464
|
function getUTCWeek(dirtyDate, options) {
|
|
1030
465
|
requiredArgs(1, arguments);
|
|
1031
466
|
var date = toDate(dirtyDate);
|
|
@@ -1140,6 +575,7 @@ var dayPeriodEnum = {
|
|
|
1140
575
|
evening: 'evening',
|
|
1141
576
|
night: 'night'
|
|
1142
577
|
};
|
|
578
|
+
|
|
1143
579
|
/*
|
|
1144
580
|
* | | Unit | | Unit |
|
|
1145
581
|
* |-----|--------------------------------|-----|--------------------------------|
|
|
@@ -1185,7 +621,6 @@ var dayPeriodEnum = {
|
|
|
1185
621
|
* - `P` is long localized date format
|
|
1186
622
|
* - `p` is long localized time format
|
|
1187
623
|
*/
|
|
1188
|
-
|
|
1189
624
|
var formatters = {
|
|
1190
625
|
// Era
|
|
1191
626
|
G: function (date, token, localize) {
|
|
@@ -1655,454 +1090,952 @@ var formatters = {
|
|
|
1655
1090
|
});
|
|
1656
1091
|
// Tuesday
|
|
1657
1092
|
|
|
1658
|
-
case 'iiii':
|
|
1093
|
+
case 'iiii':
|
|
1094
|
+
default:
|
|
1095
|
+
return localize.day(dayOfWeek, {
|
|
1096
|
+
width: 'wide',
|
|
1097
|
+
context: 'formatting'
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
},
|
|
1101
|
+
// AM or PM
|
|
1102
|
+
a: function (date, token, localize) {
|
|
1103
|
+
var hours = date.getUTCHours();
|
|
1104
|
+
var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
|
|
1105
|
+
|
|
1106
|
+
switch (token) {
|
|
1107
|
+
case 'a':
|
|
1108
|
+
case 'aa':
|
|
1109
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1110
|
+
width: 'abbreviated',
|
|
1111
|
+
context: 'formatting'
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
case 'aaa':
|
|
1115
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1116
|
+
width: 'abbreviated',
|
|
1117
|
+
context: 'formatting'
|
|
1118
|
+
}).toLowerCase();
|
|
1119
|
+
|
|
1120
|
+
case 'aaaaa':
|
|
1121
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1122
|
+
width: 'narrow',
|
|
1123
|
+
context: 'formatting'
|
|
1124
|
+
});
|
|
1125
|
+
|
|
1126
|
+
case 'aaaa':
|
|
1127
|
+
default:
|
|
1128
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1129
|
+
width: 'wide',
|
|
1130
|
+
context: 'formatting'
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
},
|
|
1134
|
+
// AM, PM, midnight, noon
|
|
1135
|
+
b: function (date, token, localize) {
|
|
1136
|
+
var hours = date.getUTCHours();
|
|
1137
|
+
var dayPeriodEnumValue;
|
|
1138
|
+
|
|
1139
|
+
if (hours === 12) {
|
|
1140
|
+
dayPeriodEnumValue = dayPeriodEnum.noon;
|
|
1141
|
+
} else if (hours === 0) {
|
|
1142
|
+
dayPeriodEnumValue = dayPeriodEnum.midnight;
|
|
1143
|
+
} else {
|
|
1144
|
+
dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
switch (token) {
|
|
1148
|
+
case 'b':
|
|
1149
|
+
case 'bb':
|
|
1150
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1151
|
+
width: 'abbreviated',
|
|
1152
|
+
context: 'formatting'
|
|
1153
|
+
});
|
|
1154
|
+
|
|
1155
|
+
case 'bbb':
|
|
1156
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1157
|
+
width: 'abbreviated',
|
|
1158
|
+
context: 'formatting'
|
|
1159
|
+
}).toLowerCase();
|
|
1160
|
+
|
|
1161
|
+
case 'bbbbb':
|
|
1162
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1163
|
+
width: 'narrow',
|
|
1164
|
+
context: 'formatting'
|
|
1165
|
+
});
|
|
1166
|
+
|
|
1167
|
+
case 'bbbb':
|
|
1168
|
+
default:
|
|
1169
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1170
|
+
width: 'wide',
|
|
1171
|
+
context: 'formatting'
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
},
|
|
1175
|
+
// in the morning, in the afternoon, in the evening, at night
|
|
1176
|
+
B: function (date, token, localize) {
|
|
1177
|
+
var hours = date.getUTCHours();
|
|
1178
|
+
var dayPeriodEnumValue;
|
|
1179
|
+
|
|
1180
|
+
if (hours >= 17) {
|
|
1181
|
+
dayPeriodEnumValue = dayPeriodEnum.evening;
|
|
1182
|
+
} else if (hours >= 12) {
|
|
1183
|
+
dayPeriodEnumValue = dayPeriodEnum.afternoon;
|
|
1184
|
+
} else if (hours >= 4) {
|
|
1185
|
+
dayPeriodEnumValue = dayPeriodEnum.morning;
|
|
1186
|
+
} else {
|
|
1187
|
+
dayPeriodEnumValue = dayPeriodEnum.night;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
switch (token) {
|
|
1191
|
+
case 'B':
|
|
1192
|
+
case 'BB':
|
|
1193
|
+
case 'BBB':
|
|
1194
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1195
|
+
width: 'abbreviated',
|
|
1196
|
+
context: 'formatting'
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
case 'BBBBB':
|
|
1200
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1201
|
+
width: 'narrow',
|
|
1202
|
+
context: 'formatting'
|
|
1203
|
+
});
|
|
1204
|
+
|
|
1205
|
+
case 'BBBB':
|
|
1206
|
+
default:
|
|
1207
|
+
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1208
|
+
width: 'wide',
|
|
1209
|
+
context: 'formatting'
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
},
|
|
1213
|
+
// Hour [1-12]
|
|
1214
|
+
h: function (date, token, localize) {
|
|
1215
|
+
if (token === 'ho') {
|
|
1216
|
+
var hours = date.getUTCHours() % 12;
|
|
1217
|
+
if (hours === 0) hours = 12;
|
|
1218
|
+
return localize.ordinalNumber(hours, {
|
|
1219
|
+
unit: 'hour'
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
return formatters$1.h(date, token);
|
|
1224
|
+
},
|
|
1225
|
+
// Hour [0-23]
|
|
1226
|
+
H: function (date, token, localize) {
|
|
1227
|
+
if (token === 'Ho') {
|
|
1228
|
+
return localize.ordinalNumber(date.getUTCHours(), {
|
|
1229
|
+
unit: 'hour'
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
return formatters$1.H(date, token);
|
|
1234
|
+
},
|
|
1235
|
+
// Hour [0-11]
|
|
1236
|
+
K: function (date, token, localize) {
|
|
1237
|
+
var hours = date.getUTCHours() % 12;
|
|
1238
|
+
|
|
1239
|
+
if (token === 'Ko') {
|
|
1240
|
+
return localize.ordinalNumber(hours, {
|
|
1241
|
+
unit: 'hour'
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
return addLeadingZeros(hours, token.length);
|
|
1246
|
+
},
|
|
1247
|
+
// Hour [1-24]
|
|
1248
|
+
k: function (date, token, localize) {
|
|
1249
|
+
var hours = date.getUTCHours();
|
|
1250
|
+
if (hours === 0) hours = 24;
|
|
1251
|
+
|
|
1252
|
+
if (token === 'ko') {
|
|
1253
|
+
return localize.ordinalNumber(hours, {
|
|
1254
|
+
unit: 'hour'
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
return addLeadingZeros(hours, token.length);
|
|
1259
|
+
},
|
|
1260
|
+
// Minute
|
|
1261
|
+
m: function (date, token, localize) {
|
|
1262
|
+
if (token === 'mo') {
|
|
1263
|
+
return localize.ordinalNumber(date.getUTCMinutes(), {
|
|
1264
|
+
unit: 'minute'
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
return formatters$1.m(date, token);
|
|
1269
|
+
},
|
|
1270
|
+
// Second
|
|
1271
|
+
s: function (date, token, localize) {
|
|
1272
|
+
if (token === 'so') {
|
|
1273
|
+
return localize.ordinalNumber(date.getUTCSeconds(), {
|
|
1274
|
+
unit: 'second'
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
return formatters$1.s(date, token);
|
|
1279
|
+
},
|
|
1280
|
+
// Fraction of second
|
|
1281
|
+
S: function (date, token) {
|
|
1282
|
+
return formatters$1.S(date, token);
|
|
1283
|
+
},
|
|
1284
|
+
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
|
|
1285
|
+
X: function (date, token, _localize, options) {
|
|
1286
|
+
var originalDate = options._originalDate || date;
|
|
1287
|
+
var timezoneOffset = originalDate.getTimezoneOffset();
|
|
1288
|
+
|
|
1289
|
+
if (timezoneOffset === 0) {
|
|
1290
|
+
return 'Z';
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
switch (token) {
|
|
1294
|
+
// Hours and optional minutes
|
|
1295
|
+
case 'X':
|
|
1296
|
+
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
|
1297
|
+
// Hours, minutes and optional seconds without `:` delimiter
|
|
1298
|
+
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
1299
|
+
// so this token always has the same output as `XX`
|
|
1300
|
+
|
|
1301
|
+
case 'XXXX':
|
|
1302
|
+
case 'XX':
|
|
1303
|
+
// Hours and minutes without `:` delimiter
|
|
1304
|
+
return formatTimezone(timezoneOffset);
|
|
1305
|
+
// Hours, minutes and optional seconds with `:` delimiter
|
|
1306
|
+
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
1307
|
+
// so this token always has the same output as `XXX`
|
|
1308
|
+
|
|
1309
|
+
case 'XXXXX':
|
|
1310
|
+
case 'XXX': // Hours and minutes with `:` delimiter
|
|
1311
|
+
|
|
1659
1312
|
default:
|
|
1660
|
-
return
|
|
1661
|
-
width: 'wide',
|
|
1662
|
-
context: 'formatting'
|
|
1663
|
-
});
|
|
1313
|
+
return formatTimezone(timezoneOffset, ':');
|
|
1664
1314
|
}
|
|
1665
1315
|
},
|
|
1666
|
-
//
|
|
1667
|
-
|
|
1668
|
-
var
|
|
1669
|
-
var
|
|
1316
|
+
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
|
|
1317
|
+
x: function (date, token, _localize, options) {
|
|
1318
|
+
var originalDate = options._originalDate || date;
|
|
1319
|
+
var timezoneOffset = originalDate.getTimezoneOffset();
|
|
1670
1320
|
|
|
1671
1321
|
switch (token) {
|
|
1672
|
-
|
|
1673
|
-
case '
|
|
1674
|
-
return
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1322
|
+
// Hours and optional minutes
|
|
1323
|
+
case 'x':
|
|
1324
|
+
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
|
1325
|
+
// Hours, minutes and optional seconds without `:` delimiter
|
|
1326
|
+
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
1327
|
+
// so this token always has the same output as `xx`
|
|
1678
1328
|
|
|
1679
|
-
case '
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1329
|
+
case 'xxxx':
|
|
1330
|
+
case 'xx':
|
|
1331
|
+
// Hours and minutes without `:` delimiter
|
|
1332
|
+
return formatTimezone(timezoneOffset);
|
|
1333
|
+
// Hours, minutes and optional seconds with `:` delimiter
|
|
1334
|
+
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
1335
|
+
// so this token always has the same output as `xxx`
|
|
1684
1336
|
|
|
1685
|
-
case '
|
|
1686
|
-
|
|
1687
|
-
width: 'narrow',
|
|
1688
|
-
context: 'formatting'
|
|
1689
|
-
});
|
|
1337
|
+
case 'xxxxx':
|
|
1338
|
+
case 'xxx': // Hours and minutes with `:` delimiter
|
|
1690
1339
|
|
|
1691
|
-
case 'aaaa':
|
|
1692
1340
|
default:
|
|
1693
|
-
return
|
|
1694
|
-
width: 'wide',
|
|
1695
|
-
context: 'formatting'
|
|
1696
|
-
});
|
|
1341
|
+
return formatTimezone(timezoneOffset, ':');
|
|
1697
1342
|
}
|
|
1698
1343
|
},
|
|
1699
|
-
//
|
|
1700
|
-
|
|
1701
|
-
var
|
|
1702
|
-
var
|
|
1703
|
-
|
|
1704
|
-
if (hours === 12) {
|
|
1705
|
-
dayPeriodEnumValue = dayPeriodEnum.noon;
|
|
1706
|
-
} else if (hours === 0) {
|
|
1707
|
-
dayPeriodEnumValue = dayPeriodEnum.midnight;
|
|
1708
|
-
} else {
|
|
1709
|
-
dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
|
|
1710
|
-
}
|
|
1344
|
+
// Timezone (GMT)
|
|
1345
|
+
O: function (date, token, _localize, options) {
|
|
1346
|
+
var originalDate = options._originalDate || date;
|
|
1347
|
+
var timezoneOffset = originalDate.getTimezoneOffset();
|
|
1711
1348
|
|
|
1712
1349
|
switch (token) {
|
|
1713
|
-
|
|
1714
|
-
case '
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
case 'bbb':
|
|
1721
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1722
|
-
width: 'abbreviated',
|
|
1723
|
-
context: 'formatting'
|
|
1724
|
-
}).toLowerCase();
|
|
1725
|
-
|
|
1726
|
-
case 'bbbbb':
|
|
1727
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1728
|
-
width: 'narrow',
|
|
1729
|
-
context: 'formatting'
|
|
1730
|
-
});
|
|
1350
|
+
// Short
|
|
1351
|
+
case 'O':
|
|
1352
|
+
case 'OO':
|
|
1353
|
+
case 'OOO':
|
|
1354
|
+
return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
|
|
1355
|
+
// Long
|
|
1731
1356
|
|
|
1732
|
-
case '
|
|
1357
|
+
case 'OOOO':
|
|
1733
1358
|
default:
|
|
1734
|
-
return
|
|
1735
|
-
width: 'wide',
|
|
1736
|
-
context: 'formatting'
|
|
1737
|
-
});
|
|
1359
|
+
return 'GMT' + formatTimezone(timezoneOffset, ':');
|
|
1738
1360
|
}
|
|
1739
1361
|
},
|
|
1740
|
-
//
|
|
1741
|
-
|
|
1742
|
-
var
|
|
1743
|
-
var
|
|
1744
|
-
|
|
1745
|
-
if (hours >= 17) {
|
|
1746
|
-
dayPeriodEnumValue = dayPeriodEnum.evening;
|
|
1747
|
-
} else if (hours >= 12) {
|
|
1748
|
-
dayPeriodEnumValue = dayPeriodEnum.afternoon;
|
|
1749
|
-
} else if (hours >= 4) {
|
|
1750
|
-
dayPeriodEnumValue = dayPeriodEnum.morning;
|
|
1751
|
-
} else {
|
|
1752
|
-
dayPeriodEnumValue = dayPeriodEnum.night;
|
|
1753
|
-
}
|
|
1362
|
+
// Timezone (specific non-location)
|
|
1363
|
+
z: function (date, token, _localize, options) {
|
|
1364
|
+
var originalDate = options._originalDate || date;
|
|
1365
|
+
var timezoneOffset = originalDate.getTimezoneOffset();
|
|
1754
1366
|
|
|
1755
1367
|
switch (token) {
|
|
1756
|
-
|
|
1757
|
-
case '
|
|
1758
|
-
case '
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
});
|
|
1763
|
-
|
|
1764
|
-
case 'BBBBB':
|
|
1765
|
-
return localize.dayPeriod(dayPeriodEnumValue, {
|
|
1766
|
-
width: 'narrow',
|
|
1767
|
-
context: 'formatting'
|
|
1768
|
-
});
|
|
1368
|
+
// Short
|
|
1369
|
+
case 'z':
|
|
1370
|
+
case 'zz':
|
|
1371
|
+
case 'zzz':
|
|
1372
|
+
return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
|
|
1373
|
+
// Long
|
|
1769
1374
|
|
|
1770
|
-
case '
|
|
1375
|
+
case 'zzzz':
|
|
1771
1376
|
default:
|
|
1772
|
-
return
|
|
1773
|
-
width: 'wide',
|
|
1774
|
-
context: 'formatting'
|
|
1775
|
-
});
|
|
1377
|
+
return 'GMT' + formatTimezone(timezoneOffset, ':');
|
|
1776
1378
|
}
|
|
1777
1379
|
},
|
|
1778
|
-
//
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1380
|
+
// Seconds timestamp
|
|
1381
|
+
t: function (date, token, _localize, options) {
|
|
1382
|
+
var originalDate = options._originalDate || date;
|
|
1383
|
+
var timestamp = Math.floor(originalDate.getTime() / 1000);
|
|
1384
|
+
return addLeadingZeros(timestamp, token.length);
|
|
1385
|
+
},
|
|
1386
|
+
// Milliseconds timestamp
|
|
1387
|
+
T: function (date, token, _localize, options) {
|
|
1388
|
+
var originalDate = options._originalDate || date;
|
|
1389
|
+
var timestamp = originalDate.getTime();
|
|
1390
|
+
return addLeadingZeros(timestamp, token.length);
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
|
|
1394
|
+
function formatTimezoneShort(offset, dirtyDelimiter) {
|
|
1395
|
+
var sign = offset > 0 ? '-' : '+';
|
|
1396
|
+
var absOffset = Math.abs(offset);
|
|
1397
|
+
var hours = Math.floor(absOffset / 60);
|
|
1398
|
+
var minutes = absOffset % 60;
|
|
1399
|
+
|
|
1400
|
+
if (minutes === 0) {
|
|
1401
|
+
return sign + String(hours);
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
var delimiter = dirtyDelimiter || '';
|
|
1405
|
+
return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
|
|
1409
|
+
if (offset % 60 === 0) {
|
|
1410
|
+
var sign = offset > 0 ? '-' : '+';
|
|
1411
|
+
return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
return formatTimezone(offset, dirtyDelimiter);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
function formatTimezone(offset, dirtyDelimiter) {
|
|
1418
|
+
var delimiter = dirtyDelimiter || '';
|
|
1419
|
+
var sign = offset > 0 ? '-' : '+';
|
|
1420
|
+
var absOffset = Math.abs(offset);
|
|
1421
|
+
var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
|
|
1422
|
+
var minutes = addLeadingZeros(absOffset % 60, 2);
|
|
1423
|
+
return sign + hours + delimiter + minutes;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
var dateLongFormatter = function (pattern, formatLong) {
|
|
1427
|
+
switch (pattern) {
|
|
1428
|
+
case 'P':
|
|
1429
|
+
return formatLong.date({
|
|
1430
|
+
width: 'short'
|
|
1431
|
+
});
|
|
1432
|
+
|
|
1433
|
+
case 'PP':
|
|
1434
|
+
return formatLong.date({
|
|
1435
|
+
width: 'medium'
|
|
1436
|
+
});
|
|
1437
|
+
|
|
1438
|
+
case 'PPP':
|
|
1439
|
+
return formatLong.date({
|
|
1440
|
+
width: 'long'
|
|
1441
|
+
});
|
|
1442
|
+
|
|
1443
|
+
case 'PPPP':
|
|
1444
|
+
default:
|
|
1445
|
+
return formatLong.date({
|
|
1446
|
+
width: 'full'
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
|
|
1451
|
+
var timeLongFormatter = function (pattern, formatLong) {
|
|
1452
|
+
switch (pattern) {
|
|
1453
|
+
case 'p':
|
|
1454
|
+
return formatLong.time({
|
|
1455
|
+
width: 'short'
|
|
1456
|
+
});
|
|
1457
|
+
|
|
1458
|
+
case 'pp':
|
|
1459
|
+
return formatLong.time({
|
|
1460
|
+
width: 'medium'
|
|
1461
|
+
});
|
|
1462
|
+
|
|
1463
|
+
case 'ppp':
|
|
1464
|
+
return formatLong.time({
|
|
1465
|
+
width: 'long'
|
|
1466
|
+
});
|
|
1467
|
+
|
|
1468
|
+
case 'pppp':
|
|
1469
|
+
default:
|
|
1470
|
+
return formatLong.time({
|
|
1471
|
+
width: 'full'
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
var dateTimeLongFormatter = function (pattern, formatLong) {
|
|
1477
|
+
var matchResult = pattern.match(/(P+)(p+)?/) || [];
|
|
1478
|
+
var datePattern = matchResult[1];
|
|
1479
|
+
var timePattern = matchResult[2];
|
|
1480
|
+
|
|
1481
|
+
if (!timePattern) {
|
|
1482
|
+
return dateLongFormatter(pattern, formatLong);
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
var dateTimeFormat;
|
|
1486
|
+
|
|
1487
|
+
switch (datePattern) {
|
|
1488
|
+
case 'P':
|
|
1489
|
+
dateTimeFormat = formatLong.dateTime({
|
|
1490
|
+
width: 'short'
|
|
1785
1491
|
});
|
|
1786
|
-
|
|
1492
|
+
break;
|
|
1787
1493
|
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
H: function (date, token, localize) {
|
|
1792
|
-
if (token === 'Ho') {
|
|
1793
|
-
return localize.ordinalNumber(date.getUTCHours(), {
|
|
1794
|
-
unit: 'hour'
|
|
1494
|
+
case 'PP':
|
|
1495
|
+
dateTimeFormat = formatLong.dateTime({
|
|
1496
|
+
width: 'medium'
|
|
1795
1497
|
});
|
|
1796
|
-
|
|
1498
|
+
break;
|
|
1797
1499
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1500
|
+
case 'PPP':
|
|
1501
|
+
dateTimeFormat = formatLong.dateTime({
|
|
1502
|
+
width: 'long'
|
|
1503
|
+
});
|
|
1504
|
+
break;
|
|
1803
1505
|
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1506
|
+
case 'PPPP':
|
|
1507
|
+
default:
|
|
1508
|
+
dateTimeFormat = formatLong.dateTime({
|
|
1509
|
+
width: 'full'
|
|
1807
1510
|
});
|
|
1808
|
-
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1809
1513
|
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
// Hour [1-24]
|
|
1813
|
-
k: function (date, token, localize) {
|
|
1814
|
-
var hours = date.getUTCHours();
|
|
1815
|
-
if (hours === 0) hours = 24;
|
|
1514
|
+
return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
|
|
1515
|
+
};
|
|
1816
1516
|
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
}
|
|
1517
|
+
var longFormatters = {
|
|
1518
|
+
p: timeLongFormatter,
|
|
1519
|
+
P: dateTimeLongFormatter
|
|
1520
|
+
};
|
|
1822
1521
|
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1522
|
+
var protectedDayOfYearTokens = ['D', 'DD'];
|
|
1523
|
+
var protectedWeekYearTokens = ['YY', 'YYYY'];
|
|
1524
|
+
function isProtectedDayOfYearToken(token) {
|
|
1525
|
+
return protectedDayOfYearTokens.indexOf(token) !== -1;
|
|
1526
|
+
}
|
|
1527
|
+
function isProtectedWeekYearToken(token) {
|
|
1528
|
+
return protectedWeekYearTokens.indexOf(token) !== -1;
|
|
1529
|
+
}
|
|
1530
|
+
function throwProtectedError(token, format, input) {
|
|
1531
|
+
if (token === 'YYYY') {
|
|
1532
|
+
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"));
|
|
1533
|
+
} else if (token === 'YY') {
|
|
1534
|
+
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"));
|
|
1535
|
+
} else if (token === 'D') {
|
|
1536
|
+
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"));
|
|
1537
|
+
} else if (token === 'DD') {
|
|
1538
|
+
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"));
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1832
1541
|
|
|
1833
|
-
|
|
1542
|
+
var formatDistanceLocale = {
|
|
1543
|
+
lessThanXSeconds: {
|
|
1544
|
+
one: 'less than a second',
|
|
1545
|
+
other: 'less than {{count}} seconds'
|
|
1834
1546
|
},
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
return localize.ordinalNumber(date.getUTCSeconds(), {
|
|
1839
|
-
unit: 'second'
|
|
1840
|
-
});
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
|
-
return formatters$1.s(date, token);
|
|
1547
|
+
xSeconds: {
|
|
1548
|
+
one: '1 second',
|
|
1549
|
+
other: '{{count}} seconds'
|
|
1844
1550
|
},
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1551
|
+
halfAMinute: 'half a minute',
|
|
1552
|
+
lessThanXMinutes: {
|
|
1553
|
+
one: 'less than a minute',
|
|
1554
|
+
other: 'less than {{count}} minutes'
|
|
1848
1555
|
},
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1556
|
+
xMinutes: {
|
|
1557
|
+
one: '1 minute',
|
|
1558
|
+
other: '{{count}} minutes'
|
|
1559
|
+
},
|
|
1560
|
+
aboutXHours: {
|
|
1561
|
+
one: 'about 1 hour',
|
|
1562
|
+
other: 'about {{count}} hours'
|
|
1563
|
+
},
|
|
1564
|
+
xHours: {
|
|
1565
|
+
one: '1 hour',
|
|
1566
|
+
other: '{{count}} hours'
|
|
1567
|
+
},
|
|
1568
|
+
xDays: {
|
|
1569
|
+
one: '1 day',
|
|
1570
|
+
other: '{{count}} days'
|
|
1571
|
+
},
|
|
1572
|
+
aboutXWeeks: {
|
|
1573
|
+
one: 'about 1 week',
|
|
1574
|
+
other: 'about {{count}} weeks'
|
|
1575
|
+
},
|
|
1576
|
+
xWeeks: {
|
|
1577
|
+
one: '1 week',
|
|
1578
|
+
other: '{{count}} weeks'
|
|
1579
|
+
},
|
|
1580
|
+
aboutXMonths: {
|
|
1581
|
+
one: 'about 1 month',
|
|
1582
|
+
other: 'about {{count}} months'
|
|
1583
|
+
},
|
|
1584
|
+
xMonths: {
|
|
1585
|
+
one: '1 month',
|
|
1586
|
+
other: '{{count}} months'
|
|
1587
|
+
},
|
|
1588
|
+
aboutXYears: {
|
|
1589
|
+
one: 'about 1 year',
|
|
1590
|
+
other: 'about {{count}} years'
|
|
1591
|
+
},
|
|
1592
|
+
xYears: {
|
|
1593
|
+
one: '1 year',
|
|
1594
|
+
other: '{{count}} years'
|
|
1595
|
+
},
|
|
1596
|
+
overXYears: {
|
|
1597
|
+
one: 'over 1 year',
|
|
1598
|
+
other: 'over {{count}} years'
|
|
1599
|
+
},
|
|
1600
|
+
almostXYears: {
|
|
1601
|
+
one: 'almost 1 year',
|
|
1602
|
+
other: 'almost {{count}} years'
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1853
1605
|
|
|
1854
|
-
|
|
1855
|
-
|
|
1606
|
+
var formatDistance = function (token, count, options) {
|
|
1607
|
+
var result;
|
|
1608
|
+
var tokenValue = formatDistanceLocale[token];
|
|
1609
|
+
|
|
1610
|
+
if (typeof tokenValue === 'string') {
|
|
1611
|
+
result = tokenValue;
|
|
1612
|
+
} else if (count === 1) {
|
|
1613
|
+
result = tokenValue.one;
|
|
1614
|
+
} else {
|
|
1615
|
+
result = tokenValue.other.replace('{{count}}', count.toString());
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
if (options !== null && options !== void 0 && options.addSuffix) {
|
|
1619
|
+
if (options.comparison && options.comparison > 0) {
|
|
1620
|
+
return 'in ' + result;
|
|
1621
|
+
} else {
|
|
1622
|
+
return result + ' ago';
|
|
1856
1623
|
}
|
|
1624
|
+
}
|
|
1857
1625
|
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
case 'X':
|
|
1861
|
-
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
|
1862
|
-
// Hours, minutes and optional seconds without `:` delimiter
|
|
1863
|
-
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
1864
|
-
// so this token always has the same output as `XX`
|
|
1626
|
+
return result;
|
|
1627
|
+
};
|
|
1865
1628
|
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1629
|
+
function buildFormatLongFn(args) {
|
|
1630
|
+
return function () {
|
|
1631
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1632
|
+
// TODO: Remove String()
|
|
1633
|
+
var width = options.width ? String(options.width) : args.defaultWidth;
|
|
1634
|
+
var format = args.formats[width] || args.formats[args.defaultWidth];
|
|
1635
|
+
return format;
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1873
1638
|
|
|
1874
|
-
|
|
1875
|
-
|
|
1639
|
+
var dateFormats = {
|
|
1640
|
+
full: 'EEEE, MMMM do, y',
|
|
1641
|
+
long: 'MMMM do, y',
|
|
1642
|
+
medium: 'MMM d, y',
|
|
1643
|
+
short: 'MM/dd/yyyy'
|
|
1644
|
+
};
|
|
1645
|
+
var timeFormats = {
|
|
1646
|
+
full: 'h:mm:ss a zzzz',
|
|
1647
|
+
long: 'h:mm:ss a z',
|
|
1648
|
+
medium: 'h:mm:ss a',
|
|
1649
|
+
short: 'h:mm a'
|
|
1650
|
+
};
|
|
1651
|
+
var dateTimeFormats = {
|
|
1652
|
+
full: "{{date}} 'at' {{time}}",
|
|
1653
|
+
long: "{{date}} 'at' {{time}}",
|
|
1654
|
+
medium: '{{date}}, {{time}}',
|
|
1655
|
+
short: '{{date}}, {{time}}'
|
|
1656
|
+
};
|
|
1657
|
+
var formatLong = {
|
|
1658
|
+
date: buildFormatLongFn({
|
|
1659
|
+
formats: dateFormats,
|
|
1660
|
+
defaultWidth: 'full'
|
|
1661
|
+
}),
|
|
1662
|
+
time: buildFormatLongFn({
|
|
1663
|
+
formats: timeFormats,
|
|
1664
|
+
defaultWidth: 'full'
|
|
1665
|
+
}),
|
|
1666
|
+
dateTime: buildFormatLongFn({
|
|
1667
|
+
formats: dateTimeFormats,
|
|
1668
|
+
defaultWidth: 'full'
|
|
1669
|
+
})
|
|
1670
|
+
};
|
|
1876
1671
|
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1672
|
+
var formatRelativeLocale = {
|
|
1673
|
+
lastWeek: "'last' eeee 'at' p",
|
|
1674
|
+
yesterday: "'yesterday at' p",
|
|
1675
|
+
today: "'today at' p",
|
|
1676
|
+
tomorrow: "'tomorrow at' p",
|
|
1677
|
+
nextWeek: "eeee 'at' p",
|
|
1678
|
+
other: 'P'
|
|
1679
|
+
};
|
|
1885
1680
|
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
|
1890
|
-
// Hours, minutes and optional seconds without `:` delimiter
|
|
1891
|
-
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
1892
|
-
// so this token always has the same output as `xx`
|
|
1681
|
+
var formatRelative = function (token, _date, _baseDate, _options) {
|
|
1682
|
+
return formatRelativeLocale[token];
|
|
1683
|
+
};
|
|
1893
1684
|
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
// Hours, minutes and optional seconds with `:` delimiter
|
|
1899
|
-
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
1900
|
-
// so this token always has the same output as `xxx`
|
|
1685
|
+
function buildLocalizeFn(args) {
|
|
1686
|
+
return function (dirtyIndex, options) {
|
|
1687
|
+
var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
|
|
1688
|
+
var valuesArray;
|
|
1901
1689
|
|
|
1902
|
-
|
|
1903
|
-
|
|
1690
|
+
if (context === 'formatting' && args.formattingValues) {
|
|
1691
|
+
var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
|
|
1692
|
+
var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
|
|
1693
|
+
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
|
|
1694
|
+
} else {
|
|
1695
|
+
var _defaultWidth = args.defaultWidth;
|
|
1904
1696
|
|
|
1905
|
-
|
|
1906
|
-
|
|
1697
|
+
var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
|
|
1698
|
+
|
|
1699
|
+
valuesArray = args.values[_width] || args.values[_defaultWidth];
|
|
1907
1700
|
}
|
|
1908
|
-
},
|
|
1909
|
-
// Timezone (GMT)
|
|
1910
|
-
O: function (date, token, _localize, options) {
|
|
1911
|
-
var originalDate = options._originalDate || date;
|
|
1912
|
-
var timezoneOffset = originalDate.getTimezoneOffset();
|
|
1913
1701
|
|
|
1914
|
-
|
|
1915
|
-
// Short
|
|
1916
|
-
case 'O':
|
|
1917
|
-
case 'OO':
|
|
1918
|
-
case 'OOO':
|
|
1919
|
-
return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
|
|
1920
|
-
// Long
|
|
1702
|
+
var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
|
|
1921
1703
|
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
}
|
|
1926
|
-
},
|
|
1927
|
-
// Timezone (specific non-location)
|
|
1928
|
-
z: function (date, token, _localize, options) {
|
|
1929
|
-
var originalDate = options._originalDate || date;
|
|
1930
|
-
var timezoneOffset = originalDate.getTimezoneOffset();
|
|
1704
|
+
return valuesArray[index];
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1931
1707
|
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1708
|
+
var eraValues = {
|
|
1709
|
+
narrow: ['B', 'A'],
|
|
1710
|
+
abbreviated: ['BC', 'AD'],
|
|
1711
|
+
wide: ['Before Christ', 'Anno Domini']
|
|
1712
|
+
};
|
|
1713
|
+
var quarterValues = {
|
|
1714
|
+
narrow: ['1', '2', '3', '4'],
|
|
1715
|
+
abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
|
|
1716
|
+
wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
|
|
1717
|
+
}; // Note: in English, the names of days of the week and months are capitalized.
|
|
1718
|
+
// If you are making a new locale based on this one, check if the same is true for the language you're working on.
|
|
1719
|
+
// Generally, formatted dates should look like they are in the middle of a sentence,
|
|
1720
|
+
// e.g. in Spanish language the weekdays and months should be in the lowercase.
|
|
1939
1721
|
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1722
|
+
var monthValues = {
|
|
1723
|
+
narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
|
|
1724
|
+
abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
1725
|
+
wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
|
1726
|
+
};
|
|
1727
|
+
var dayValues = {
|
|
1728
|
+
narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
|
|
1729
|
+
short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
|
1730
|
+
abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
1731
|
+
wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
|
|
1732
|
+
};
|
|
1733
|
+
var dayPeriodValues = {
|
|
1734
|
+
narrow: {
|
|
1735
|
+
am: 'a',
|
|
1736
|
+
pm: 'p',
|
|
1737
|
+
midnight: 'mi',
|
|
1738
|
+
noon: 'n',
|
|
1739
|
+
morning: 'morning',
|
|
1740
|
+
afternoon: 'afternoon',
|
|
1741
|
+
evening: 'evening',
|
|
1742
|
+
night: 'night'
|
|
1944
1743
|
},
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1744
|
+
abbreviated: {
|
|
1745
|
+
am: 'AM',
|
|
1746
|
+
pm: 'PM',
|
|
1747
|
+
midnight: 'midnight',
|
|
1748
|
+
noon: 'noon',
|
|
1749
|
+
morning: 'morning',
|
|
1750
|
+
afternoon: 'afternoon',
|
|
1751
|
+
evening: 'evening',
|
|
1752
|
+
night: 'night'
|
|
1950
1753
|
},
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1754
|
+
wide: {
|
|
1755
|
+
am: 'a.m.',
|
|
1756
|
+
pm: 'p.m.',
|
|
1757
|
+
midnight: 'midnight',
|
|
1758
|
+
noon: 'noon',
|
|
1759
|
+
morning: 'morning',
|
|
1760
|
+
afternoon: 'afternoon',
|
|
1761
|
+
evening: 'evening',
|
|
1762
|
+
night: 'night'
|
|
1956
1763
|
}
|
|
1957
1764
|
};
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1765
|
+
var formattingDayPeriodValues = {
|
|
1766
|
+
narrow: {
|
|
1767
|
+
am: 'a',
|
|
1768
|
+
pm: 'p',
|
|
1769
|
+
midnight: 'mi',
|
|
1770
|
+
noon: 'n',
|
|
1771
|
+
morning: 'in the morning',
|
|
1772
|
+
afternoon: 'in the afternoon',
|
|
1773
|
+
evening: 'in the evening',
|
|
1774
|
+
night: 'at night'
|
|
1775
|
+
},
|
|
1776
|
+
abbreviated: {
|
|
1777
|
+
am: 'AM',
|
|
1778
|
+
pm: 'PM',
|
|
1779
|
+
midnight: 'midnight',
|
|
1780
|
+
noon: 'noon',
|
|
1781
|
+
morning: 'in the morning',
|
|
1782
|
+
afternoon: 'in the afternoon',
|
|
1783
|
+
evening: 'in the evening',
|
|
1784
|
+
night: 'at night'
|
|
1785
|
+
},
|
|
1786
|
+
wide: {
|
|
1787
|
+
am: 'a.m.',
|
|
1788
|
+
pm: 'p.m.',
|
|
1789
|
+
midnight: 'midnight',
|
|
1790
|
+
noon: 'noon',
|
|
1791
|
+
morning: 'in the morning',
|
|
1792
|
+
afternoon: 'in the afternoon',
|
|
1793
|
+
evening: 'in the evening',
|
|
1794
|
+
night: 'at night'
|
|
1977
1795
|
}
|
|
1796
|
+
};
|
|
1978
1797
|
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
|
|
1987
|
-
var minutes = addLeadingZeros(absOffset % 60, 2);
|
|
1988
|
-
return sign + hours + delimiter + minutes;
|
|
1989
|
-
}
|
|
1798
|
+
var ordinalNumber = function (dirtyNumber, _options) {
|
|
1799
|
+
var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
|
|
1800
|
+
// if they are different for different grammatical genders,
|
|
1801
|
+
// use `options.unit`.
|
|
1802
|
+
//
|
|
1803
|
+
// `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
|
|
1804
|
+
// 'day', 'hour', 'minute', 'second'.
|
|
1990
1805
|
|
|
1991
|
-
|
|
1992
|
-
switch (pattern) {
|
|
1993
|
-
case 'P':
|
|
1994
|
-
return formatLong.date({
|
|
1995
|
-
width: 'short'
|
|
1996
|
-
});
|
|
1806
|
+
var rem100 = number % 100;
|
|
1997
1807
|
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
1808
|
+
if (rem100 > 20 || rem100 < 10) {
|
|
1809
|
+
switch (rem100 % 10) {
|
|
1810
|
+
case 1:
|
|
1811
|
+
return number + 'st';
|
|
2002
1812
|
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
width: 'long'
|
|
2006
|
-
});
|
|
1813
|
+
case 2:
|
|
1814
|
+
return number + 'nd';
|
|
2007
1815
|
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
width: 'full'
|
|
2012
|
-
});
|
|
1816
|
+
case 3:
|
|
1817
|
+
return number + 'rd';
|
|
1818
|
+
}
|
|
2013
1819
|
}
|
|
2014
|
-
}
|
|
2015
1820
|
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
case 'p':
|
|
2019
|
-
return formatLong.time({
|
|
2020
|
-
width: 'short'
|
|
2021
|
-
});
|
|
1821
|
+
return number + 'th';
|
|
1822
|
+
};
|
|
2022
1823
|
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
1824
|
+
var localize = {
|
|
1825
|
+
ordinalNumber: ordinalNumber,
|
|
1826
|
+
era: buildLocalizeFn({
|
|
1827
|
+
values: eraValues,
|
|
1828
|
+
defaultWidth: 'wide'
|
|
1829
|
+
}),
|
|
1830
|
+
quarter: buildLocalizeFn({
|
|
1831
|
+
values: quarterValues,
|
|
1832
|
+
defaultWidth: 'wide',
|
|
1833
|
+
argumentCallback: function (quarter) {
|
|
1834
|
+
return quarter - 1;
|
|
1835
|
+
}
|
|
1836
|
+
}),
|
|
1837
|
+
month: buildLocalizeFn({
|
|
1838
|
+
values: monthValues,
|
|
1839
|
+
defaultWidth: 'wide'
|
|
1840
|
+
}),
|
|
1841
|
+
day: buildLocalizeFn({
|
|
1842
|
+
values: dayValues,
|
|
1843
|
+
defaultWidth: 'wide'
|
|
1844
|
+
}),
|
|
1845
|
+
dayPeriod: buildLocalizeFn({
|
|
1846
|
+
values: dayPeriodValues,
|
|
1847
|
+
defaultWidth: 'wide',
|
|
1848
|
+
formattingValues: formattingDayPeriodValues,
|
|
1849
|
+
defaultFormattingWidth: 'wide'
|
|
1850
|
+
})
|
|
1851
|
+
};
|
|
2027
1852
|
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
1853
|
+
function buildMatchFn(args) {
|
|
1854
|
+
return function (string) {
|
|
1855
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1856
|
+
var width = options.width;
|
|
1857
|
+
var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
|
|
1858
|
+
var matchResult = string.match(matchPattern);
|
|
2032
1859
|
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
width: 'full'
|
|
2037
|
-
});
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
1860
|
+
if (!matchResult) {
|
|
1861
|
+
return null;
|
|
1862
|
+
}
|
|
2040
1863
|
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
1864
|
+
var matchedString = matchResult[0];
|
|
1865
|
+
var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
|
|
1866
|
+
var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
|
|
1867
|
+
return pattern.test(matchedString);
|
|
1868
|
+
}) : findKey(parsePatterns, function (pattern) {
|
|
1869
|
+
return pattern.test(matchedString);
|
|
1870
|
+
});
|
|
1871
|
+
var value;
|
|
1872
|
+
value = args.valueCallback ? args.valueCallback(key) : key;
|
|
1873
|
+
value = options.valueCallback ? options.valueCallback(value) : value;
|
|
1874
|
+
var rest = string.slice(matchedString.length);
|
|
1875
|
+
return {
|
|
1876
|
+
value: value,
|
|
1877
|
+
rest: rest
|
|
1878
|
+
};
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
2045
1881
|
|
|
2046
|
-
|
|
2047
|
-
|
|
1882
|
+
function findKey(object, predicate) {
|
|
1883
|
+
for (var key in object) {
|
|
1884
|
+
if (object.hasOwnProperty(key) && predicate(object[key])) {
|
|
1885
|
+
return key;
|
|
1886
|
+
}
|
|
2048
1887
|
}
|
|
2049
1888
|
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
switch (datePattern) {
|
|
2053
|
-
case 'P':
|
|
2054
|
-
dateTimeFormat = formatLong.dateTime({
|
|
2055
|
-
width: 'short'
|
|
2056
|
-
});
|
|
2057
|
-
break;
|
|
2058
|
-
|
|
2059
|
-
case 'PP':
|
|
2060
|
-
dateTimeFormat = formatLong.dateTime({
|
|
2061
|
-
width: 'medium'
|
|
2062
|
-
});
|
|
2063
|
-
break;
|
|
2064
|
-
|
|
2065
|
-
case 'PPP':
|
|
2066
|
-
dateTimeFormat = formatLong.dateTime({
|
|
2067
|
-
width: 'long'
|
|
2068
|
-
});
|
|
2069
|
-
break;
|
|
1889
|
+
return undefined;
|
|
1890
|
+
}
|
|
2070
1891
|
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
break;
|
|
1892
|
+
function findIndex(array, predicate) {
|
|
1893
|
+
for (var key = 0; key < array.length; key++) {
|
|
1894
|
+
if (predicate(array[key])) {
|
|
1895
|
+
return key;
|
|
1896
|
+
}
|
|
2077
1897
|
}
|
|
2078
1898
|
|
|
2079
|
-
return
|
|
1899
|
+
return undefined;
|
|
2080
1900
|
}
|
|
2081
1901
|
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
1902
|
+
function buildMatchPatternFn(args) {
|
|
1903
|
+
return function (string) {
|
|
1904
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1905
|
+
var matchResult = string.match(args.matchPattern);
|
|
1906
|
+
if (!matchResult) return null;
|
|
1907
|
+
var matchedString = matchResult[0];
|
|
1908
|
+
var parseResult = string.match(args.parsePattern);
|
|
1909
|
+
if (!parseResult) return null;
|
|
1910
|
+
var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
|
|
1911
|
+
value = options.valueCallback ? options.valueCallback(value) : value;
|
|
1912
|
+
var rest = string.slice(matchedString.length);
|
|
1913
|
+
return {
|
|
1914
|
+
value: value,
|
|
1915
|
+
rest: rest
|
|
1916
|
+
};
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
|
|
1921
|
+
var parseOrdinalNumberPattern = /\d+/i;
|
|
1922
|
+
var matchEraPatterns = {
|
|
1923
|
+
narrow: /^(b|a)/i,
|
|
1924
|
+
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
|
|
1925
|
+
wide: /^(before christ|before common era|anno domini|common era)/i
|
|
1926
|
+
};
|
|
1927
|
+
var parseEraPatterns = {
|
|
1928
|
+
any: [/^b/i, /^(a|c)/i]
|
|
1929
|
+
};
|
|
1930
|
+
var matchQuarterPatterns = {
|
|
1931
|
+
narrow: /^[1234]/i,
|
|
1932
|
+
abbreviated: /^q[1234]/i,
|
|
1933
|
+
wide: /^[1234](th|st|nd|rd)? quarter/i
|
|
1934
|
+
};
|
|
1935
|
+
var parseQuarterPatterns = {
|
|
1936
|
+
any: [/1/i, /2/i, /3/i, /4/i]
|
|
1937
|
+
};
|
|
1938
|
+
var matchMonthPatterns = {
|
|
1939
|
+
narrow: /^[jfmasond]/i,
|
|
1940
|
+
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
|
|
1941
|
+
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
|
|
1942
|
+
};
|
|
1943
|
+
var parseMonthPatterns = {
|
|
1944
|
+
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],
|
|
1945
|
+
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]
|
|
1946
|
+
};
|
|
1947
|
+
var matchDayPatterns = {
|
|
1948
|
+
narrow: /^[smtwf]/i,
|
|
1949
|
+
short: /^(su|mo|tu|we|th|fr|sa)/i,
|
|
1950
|
+
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
|
|
1951
|
+
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
|
|
1952
|
+
};
|
|
1953
|
+
var parseDayPatterns = {
|
|
1954
|
+
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
|
|
1955
|
+
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
|
|
1956
|
+
};
|
|
1957
|
+
var matchDayPeriodPatterns = {
|
|
1958
|
+
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
|
|
1959
|
+
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
|
|
1960
|
+
};
|
|
1961
|
+
var parseDayPeriodPatterns = {
|
|
1962
|
+
any: {
|
|
1963
|
+
am: /^a/i,
|
|
1964
|
+
pm: /^p/i,
|
|
1965
|
+
midnight: /^mi/i,
|
|
1966
|
+
noon: /^no/i,
|
|
1967
|
+
morning: /morning/i,
|
|
1968
|
+
afternoon: /afternoon/i,
|
|
1969
|
+
evening: /evening/i,
|
|
1970
|
+
night: /night/i
|
|
1971
|
+
}
|
|
1972
|
+
};
|
|
1973
|
+
var match = {
|
|
1974
|
+
ordinalNumber: buildMatchPatternFn({
|
|
1975
|
+
matchPattern: matchOrdinalNumberPattern,
|
|
1976
|
+
parsePattern: parseOrdinalNumberPattern,
|
|
1977
|
+
valueCallback: function (value) {
|
|
1978
|
+
return parseInt(value, 10);
|
|
1979
|
+
}
|
|
1980
|
+
}),
|
|
1981
|
+
era: buildMatchFn({
|
|
1982
|
+
matchPatterns: matchEraPatterns,
|
|
1983
|
+
defaultMatchWidth: 'wide',
|
|
1984
|
+
parsePatterns: parseEraPatterns,
|
|
1985
|
+
defaultParseWidth: 'any'
|
|
1986
|
+
}),
|
|
1987
|
+
quarter: buildMatchFn({
|
|
1988
|
+
matchPatterns: matchQuarterPatterns,
|
|
1989
|
+
defaultMatchWidth: 'wide',
|
|
1990
|
+
parsePatterns: parseQuarterPatterns,
|
|
1991
|
+
defaultParseWidth: 'any',
|
|
1992
|
+
valueCallback: function (index) {
|
|
1993
|
+
return index + 1;
|
|
1994
|
+
}
|
|
1995
|
+
}),
|
|
1996
|
+
month: buildMatchFn({
|
|
1997
|
+
matchPatterns: matchMonthPatterns,
|
|
1998
|
+
defaultMatchWidth: 'wide',
|
|
1999
|
+
parsePatterns: parseMonthPatterns,
|
|
2000
|
+
defaultParseWidth: 'any'
|
|
2001
|
+
}),
|
|
2002
|
+
day: buildMatchFn({
|
|
2003
|
+
matchPatterns: matchDayPatterns,
|
|
2004
|
+
defaultMatchWidth: 'wide',
|
|
2005
|
+
parsePatterns: parseDayPatterns,
|
|
2006
|
+
defaultParseWidth: 'any'
|
|
2007
|
+
}),
|
|
2008
|
+
dayPeriod: buildMatchFn({
|
|
2009
|
+
matchPatterns: matchDayPeriodPatterns,
|
|
2010
|
+
defaultMatchWidth: 'any',
|
|
2011
|
+
parsePatterns: parseDayPeriodPatterns,
|
|
2012
|
+
defaultParseWidth: 'any'
|
|
2013
|
+
})
|
|
2085
2014
|
};
|
|
2086
2015
|
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2016
|
+
/**
|
|
2017
|
+
* @type {Locale}
|
|
2018
|
+
* @category Locales
|
|
2019
|
+
* @summary English locale (United States).
|
|
2020
|
+
* @language English
|
|
2021
|
+
* @iso-639-2 eng
|
|
2022
|
+
* @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
|
|
2023
|
+
* @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
|
|
2024
|
+
*/
|
|
2025
|
+
var locale = {
|
|
2026
|
+
code: 'en-US',
|
|
2027
|
+
formatDistance: formatDistance,
|
|
2028
|
+
formatLong: formatLong,
|
|
2029
|
+
formatRelative: formatRelative,
|
|
2030
|
+
localize: localize,
|
|
2031
|
+
match: match,
|
|
2032
|
+
options: {
|
|
2033
|
+
weekStartsOn: 0
|
|
2034
|
+
/* Sunday */
|
|
2035
|
+
,
|
|
2036
|
+
firstWeekContainsDate: 1
|
|
2104
2037
|
}
|
|
2105
|
-
}
|
|
2038
|
+
};
|
|
2106
2039
|
|
|
2107
2040
|
// - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
|
|
2108
2041
|
// (one of the certain letters followed by `o`)
|
|
@@ -2131,7 +2064,7 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
|
|
2131
2064
|
* Return the formatted date string in the given format. The result may vary by locale.
|
|
2132
2065
|
*
|
|
2133
2066
|
* > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
|
|
2134
|
-
* > See: https://
|
|
2067
|
+
* > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
|
2135
2068
|
*
|
|
2136
2069
|
* The characters wrapped between two single quotes characters (') are escaped.
|
|
2137
2070
|
* Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
|
|
@@ -2367,30 +2300,10 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
|
|
2367
2300
|
* - `p`: long localized time
|
|
2368
2301
|
*
|
|
2369
2302
|
* 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
|
|
2370
|
-
* You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://
|
|
2303
|
+
* You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
|
2371
2304
|
*
|
|
2372
2305
|
* 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
|
|
2373
|
-
* You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://
|
|
2374
|
-
*
|
|
2375
|
-
* ### v2.0.0 breaking changes:
|
|
2376
|
-
*
|
|
2377
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
2378
|
-
*
|
|
2379
|
-
* - The second argument is now required for the sake of explicitness.
|
|
2380
|
-
*
|
|
2381
|
-
* ```javascript
|
|
2382
|
-
* // Before v2.0.0
|
|
2383
|
-
* format(new Date(2016, 0, 1))
|
|
2384
|
-
*
|
|
2385
|
-
* // v2.0.0 onward
|
|
2386
|
-
* format(new Date(2016, 0, 1), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
|
|
2387
|
-
* ```
|
|
2388
|
-
*
|
|
2389
|
-
* - New format string API for `format` function
|
|
2390
|
-
* which is based on [Unicode Technical Standard #35](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table).
|
|
2391
|
-
* See [this post](https://blog.date-fns.org/post/unicode-tokens-in-date-fns-v2-sreatyki91jg) for more details.
|
|
2392
|
-
*
|
|
2393
|
-
* - Characters are now escaped using single quote symbols (`'`) instead of square brackets.
|
|
2306
|
+
* You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
|
2394
2307
|
*
|
|
2395
2308
|
* @param {Date|Number} date - the original date
|
|
2396
2309
|
* @param {String} format - the string of tokens
|
|
@@ -2399,9 +2312,9 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
|
|
2399
2312
|
* @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
|
|
2400
2313
|
* @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
|
|
2401
2314
|
* @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
|
|
2402
|
-
* see: https://
|
|
2315
|
+
* see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
|
2403
2316
|
* @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
|
|
2404
|
-
* see: https://
|
|
2317
|
+
* see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
|
2405
2318
|
* @returns {String} the formatted date string
|
|
2406
2319
|
* @throws {TypeError} 2 arguments required
|
|
2407
2320
|
* @throws {RangeError} `date` must not be Invalid Date
|
|
@@ -2409,47 +2322,45 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
|
|
2409
2322
|
* @throws {RangeError} `options.locale` must contain `formatLong` property
|
|
2410
2323
|
* @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
|
|
2411
2324
|
* @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
|
|
2412
|
-
* @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://
|
|
2413
|
-
* @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://
|
|
2414
|
-
* @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://
|
|
2415
|
-
* @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://
|
|
2325
|
+
* @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
|
|
2326
|
+
* @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
|
|
2327
|
+
* @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
|
|
2328
|
+
* @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
|
|
2416
2329
|
* @throws {RangeError} format string contains an unescaped latin alphabet character
|
|
2417
2330
|
*
|
|
2418
2331
|
* @example
|
|
2419
2332
|
* // Represent 11 February 2014 in middle-endian format:
|
|
2420
|
-
*
|
|
2333
|
+
* const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
|
|
2421
2334
|
* //=> '02/11/2014'
|
|
2422
2335
|
*
|
|
2423
2336
|
* @example
|
|
2424
2337
|
* // Represent 2 July 2014 in Esperanto:
|
|
2425
2338
|
* import { eoLocale } from 'date-fns/locale/eo'
|
|
2426
|
-
*
|
|
2339
|
+
* const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
|
|
2427
2340
|
* locale: eoLocale
|
|
2428
2341
|
* })
|
|
2429
2342
|
* //=> '2-a de julio 2014'
|
|
2430
2343
|
*
|
|
2431
2344
|
* @example
|
|
2432
2345
|
* // Escape string by single quote characters:
|
|
2433
|
-
*
|
|
2346
|
+
* const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
|
|
2434
2347
|
* //=> "3 o'clock"
|
|
2435
2348
|
*/
|
|
2436
2349
|
|
|
2437
|
-
function format(dirtyDate, dirtyFormatStr,
|
|
2350
|
+
function format(dirtyDate, dirtyFormatStr, options) {
|
|
2351
|
+
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;
|
|
2352
|
+
|
|
2438
2353
|
requiredArgs(2, arguments);
|
|
2439
2354
|
var formatStr = String(dirtyFormatStr);
|
|
2440
|
-
var
|
|
2441
|
-
var locale$1 = options.locale
|
|
2442
|
-
var
|
|
2443
|
-
var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
|
|
2444
|
-
var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
|
|
2355
|
+
var defaultOptions = getDefaultOptions();
|
|
2356
|
+
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;
|
|
2357
|
+
var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
|
|
2445
2358
|
|
|
2446
2359
|
if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
|
|
2447
2360
|
throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
|
|
2448
2361
|
}
|
|
2449
2362
|
|
|
2450
|
-
var
|
|
2451
|
-
var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
|
|
2452
|
-
var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
|
|
2363
|
+
var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
|
|
2453
2364
|
|
|
2454
2365
|
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
|
|
2455
2366
|
throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
|
|
@@ -2485,7 +2396,7 @@ function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
|
|
|
2485
2396
|
|
|
2486
2397
|
if (firstCharacter === 'p' || firstCharacter === 'P') {
|
|
2487
2398
|
var longFormatter = longFormatters[firstCharacter];
|
|
2488
|
-
return longFormatter(substring, locale$1.formatLong
|
|
2399
|
+
return longFormatter(substring, locale$1.formatLong);
|
|
2489
2400
|
}
|
|
2490
2401
|
|
|
2491
2402
|
return substring;
|
|
@@ -2504,12 +2415,12 @@ function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
|
|
|
2504
2415
|
var formatter = formatters[firstCharacter];
|
|
2505
2416
|
|
|
2506
2417
|
if (formatter) {
|
|
2507
|
-
if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
|
|
2508
|
-
throwProtectedError(substring, dirtyFormatStr, dirtyDate);
|
|
2418
|
+
if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
|
|
2419
|
+
throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
|
|
2509
2420
|
}
|
|
2510
2421
|
|
|
2511
|
-
if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
|
|
2512
|
-
throwProtectedError(substring, dirtyFormatStr, dirtyDate);
|
|
2422
|
+
if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
|
|
2423
|
+
throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
|
|
2513
2424
|
}
|
|
2514
2425
|
|
|
2515
2426
|
return formatter(utcDate, substring, locale$1.localize, formatterOptions);
|
|
@@ -2525,7 +2436,13 @@ function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
|
|
|
2525
2436
|
}
|
|
2526
2437
|
|
|
2527
2438
|
function cleanEscapedString(input) {
|
|
2528
|
-
|
|
2439
|
+
var matched = input.match(escapedStringRegExp);
|
|
2440
|
+
|
|
2441
|
+
if (!matched) {
|
|
2442
|
+
return input;
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
return matched[1].replace(doubleQuoteRegExp, "'");
|
|
2529
2446
|
}
|
|
2530
2447
|
|
|
2531
2448
|
/**
|
|
@@ -2544,7 +2461,7 @@ function cleanEscapedString(input) {
|
|
|
2544
2461
|
* @throws {TypeError} 1 argument required
|
|
2545
2462
|
* @throws {RangeError} `date` must not be Invalid Date
|
|
2546
2463
|
* @throws {RangeError} `options.format` must be 'extended' or 'basic'
|
|
2547
|
-
* @throws {RangeError} `options.
|
|
2464
|
+
* @throws {RangeError} `options.representation` must be 'date', 'time' or 'complete'
|
|
2548
2465
|
*
|
|
2549
2466
|
* @example
|
|
2550
2467
|
* // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):
|
|
@@ -2568,6 +2485,8 @@ function cleanEscapedString(input) {
|
|
|
2568
2485
|
*/
|
|
2569
2486
|
|
|
2570
2487
|
function formatISO(date, options) {
|
|
2488
|
+
var _options$format, _options$representati;
|
|
2489
|
+
|
|
2571
2490
|
requiredArgs(1, arguments);
|
|
2572
2491
|
var originalDate = toDate(date);
|
|
2573
2492
|
|
|
@@ -2575,8 +2494,8 @@ function formatISO(date, options) {
|
|
|
2575
2494
|
throw new RangeError('Invalid time value');
|
|
2576
2495
|
}
|
|
2577
2496
|
|
|
2578
|
-
var format =
|
|
2579
|
-
var representation =
|
|
2497
|
+
var format = String((_options$format = options === null || options === void 0 ? void 0 : options.format) !== null && _options$format !== void 0 ? _options$format : 'extended');
|
|
2498
|
+
var representation = String((_options$representati = options === null || options === void 0 ? void 0 : options.representation) !== null && _options$representati !== void 0 ? _options$representati : 'complete');
|
|
2580
2499
|
|
|
2581
2500
|
if (format !== 'extended' && format !== 'basic') {
|
|
2582
2501
|
throw new RangeError("format must be 'extended' or 'basic'");
|
|
@@ -2637,10 +2556,6 @@ function formatISO(date, options) {
|
|
|
2637
2556
|
* @description
|
|
2638
2557
|
* Get the number of days in a month of the given date.
|
|
2639
2558
|
*
|
|
2640
|
-
* ### v2.0.0 breaking changes:
|
|
2641
|
-
*
|
|
2642
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
2643
|
-
*
|
|
2644
2559
|
* @param {Date|Number} date - the given date
|
|
2645
2560
|
* @returns {Number} the number of days in a month
|
|
2646
2561
|
* @throws {TypeError} 1 argument required
|
|
@@ -2670,10 +2585,6 @@ function getDaysInMonth(dirtyDate) {
|
|
|
2670
2585
|
* @description
|
|
2671
2586
|
* Is the first date after the second one?
|
|
2672
2587
|
*
|
|
2673
|
-
* ### v2.0.0 breaking changes:
|
|
2674
|
-
*
|
|
2675
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
2676
|
-
*
|
|
2677
2588
|
* @param {Date|Number} date - the date that should be after the other one to return true
|
|
2678
2589
|
* @param {Date|Number} dateToCompare - the date to compare with
|
|
2679
2590
|
* @returns {Boolean} the first date is after the second date
|
|
@@ -2681,7 +2592,7 @@ function getDaysInMonth(dirtyDate) {
|
|
|
2681
2592
|
*
|
|
2682
2593
|
* @example
|
|
2683
2594
|
* // Is 10 July 1989 after 11 February 1987?
|
|
2684
|
-
*
|
|
2595
|
+
* const result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))
|
|
2685
2596
|
* //=> true
|
|
2686
2597
|
*/
|
|
2687
2598
|
|
|
@@ -2700,10 +2611,6 @@ function isAfter(dirtyDate, dirtyDateToCompare) {
|
|
|
2700
2611
|
* @description
|
|
2701
2612
|
* Is the first date before the second one?
|
|
2702
2613
|
*
|
|
2703
|
-
* ### v2.0.0 breaking changes:
|
|
2704
|
-
*
|
|
2705
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
2706
|
-
*
|
|
2707
2614
|
* @param {Date|Number} date - the date that should be before the other one to return true
|
|
2708
2615
|
* @param {Date|Number} dateToCompare - the date to compare with
|
|
2709
2616
|
* @returns {Boolean} the first date is before the second date
|
|
@@ -2711,7 +2618,7 @@ function isAfter(dirtyDate, dirtyDateToCompare) {
|
|
|
2711
2618
|
*
|
|
2712
2619
|
* @example
|
|
2713
2620
|
* // Is 10 July 1989 before 11 February 1987?
|
|
2714
|
-
*
|
|
2621
|
+
* const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
|
|
2715
2622
|
* //=> false
|
|
2716
2623
|
*/
|
|
2717
2624
|
|
|
@@ -2730,10 +2637,6 @@ function isBefore(dirtyDate, dirtyDateToCompare) {
|
|
|
2730
2637
|
* @description
|
|
2731
2638
|
* Set the minutes to the given date.
|
|
2732
2639
|
*
|
|
2733
|
-
* ### v2.0.0 breaking changes:
|
|
2734
|
-
*
|
|
2735
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
2736
|
-
*
|
|
2737
2640
|
* @param {Date|Number} date - the date to be changed
|
|
2738
2641
|
* @param {Number} minutes - the minutes of the new date
|
|
2739
2642
|
* @returns {Date} the new date with the minutes set
|
|
@@ -2841,7 +2744,8 @@ function stringToDate(date) {
|
|
|
2841
2744
|
}
|
|
2842
2745
|
function removeTimezoneOffset(date) {
|
|
2843
2746
|
const timeZoneOffset = date.getTimezoneOffset();
|
|
2844
|
-
|
|
2747
|
+
// Minutes compensation for some timezones like India, Central Australia and etc use GMT+5:30, GMT+9:30
|
|
2748
|
+
return setMinutes(date, timeZoneOffset + Math.abs(timeZoneOffset % 60));
|
|
2845
2749
|
}
|
|
2846
2750
|
function stringArrayToDate(dateArray) {
|
|
2847
2751
|
if (!Array.isArray(dateArray) || dateArray.length === 0) {
|
|
@@ -2850,9 +2754,8 @@ function stringArrayToDate(dateArray) {
|
|
|
2850
2754
|
return dateArray.map(date => stringToDate(date));
|
|
2851
2755
|
}
|
|
2852
2756
|
function setupMonthYear(value = new Date()) {
|
|
2853
|
-
const monthIndex = Number(value.toISOString().split('-')[1]) - 1;
|
|
2854
2757
|
return {
|
|
2855
|
-
monthIndex,
|
|
2758
|
+
monthIndex: value.getMonth(),
|
|
2856
2759
|
selectedYear: value.getFullYear(),
|
|
2857
2760
|
};
|
|
2858
2761
|
}
|
|
@@ -3137,7 +3040,7 @@ function addEmptyDates(from, to) {
|
|
|
3137
3040
|
return [...Array(to - from).keys()].map(() => (Object.assign({}, emptyDate)));
|
|
3138
3041
|
}
|
|
3139
3042
|
|
|
3140
|
-
const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-global-focus, 0 0 0 2px #33b4ff)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}.q2-element-dropdown{display:none;position:absolute;background-color:var(--app-white, #ffffff);color:var(--t-text, #4d4d4d);left:0;width:100%;z-index:100;margin-top:1px;box-shadow:var(--app-shadow-1, 0 2px 4px rgba(0, 0, 0, 0.3));height:0;overflow:hidden;opacity:0;visibility:hidden;transition:opacity var(--app-tween-1, 0.2s ease);border-radius:var(--tct-dropdown-border-radius, --t-dropdown-border-radius, 0);--comp-scrollbar-size:var(--tct-scrollbar-size, var(--t-scrollbar-size, var(--app-scale-1x, 5px)));--comp-scrollbar-border-radius:var(--tct-scrollbar-border-radius, var(--t-scrollbar-border-radius, var(--app-border-radius-1, 3px)));--comp-scrollbar-color:var(--tct-scrollbar-color, var(--t-scrollbar-color, var(--t-a11y-gray-color, #747474)));scrollbar-width:thin;scrollbar-color:var(--comp-scrollbar-color) transparent}.q2-element-dropdown::-webkit-scrollbar{width:var(--comp-scrollbar-size);height:var(--comp-scrollbar-size);margin:5px}.q2-element-dropdown::-webkit-scrollbar-thumb{background:var(--comp-scrollbar-color);border-radius:var(--comp-scrollbar-border-radius)}.q2-element-dropdown::-webkit-scrollbar-track{background:transparent;border-radius:var(--comp-scrollbar-border-radius)}.q2-element-dropdown.sizable{display:block;height:auto}.dropdown-open .q2-element-dropdown{display:block;height:auto;overflow:auto;opacity:1;visibility:visible}:host([alignment=right]) .q2-element-dropdown{left:auto;right:0}:host([block]) q2-btn,:host([block]){display:block}:host{display:block}:host[hidden]{display:none}.calendar-container{position:relative;display:block}q2-input{margin:0;cursor:pointer}.q2-element-dropdown{text-align:center;min-width:308px}.q2-element-dropdown.dropup{bottom:var(--comp-input-min-height, 44px);margin-bottom:0px}.calendar-label{font-size:var(--tct-calendar-label-font-size, var(--t-calendar-label-font-size, 16px));flex:1 1;flex-basis:calc(100% - var(--tct-btn-icon-width, 44px));margin:0;padding:var(--tct-calendar-label-vertical-padding, var(--t-calendar-label-vertical-padding, var(--tct-scale-2, var(--app-scale-2x, 10px)))) 0}.calendar-hint{text-align:left;margin:0}.cal-month-heading{padding:0 0 0.75rem;display:flex;justify-content:center;align-items:center;font-size:var(--tct-calendar-month-font-size, var(--t-calendar-month-font-size, 16px));font-weight:var(--tct-calendar-month-font-weight, var(--t-calendar-month-font-weight, 600))}.cal-month-text{min-width:82px;display:inline-block}.cal-year-text{min-width:50px;display:inline-block}table{width:100%;margin-bottom:2px}th{font-size:var(--tct-calendar-day-heading-font-size, var(--t-calendar-day-heading-font-size, inherit));font-weight:var(--tct-calendar-day-heading-font-weight, var(--t-calendar-day-heading-font-weight, 600));width:14.285714%}td{height:44px;cursor:pointer}td.is-unavailable{border:1px solid var(--tct-input-error-border-color, var(--const-stoplight-alert, #c30000))}td.is-valid:hover{background-color:var(--tct-calendar-day-hover-bg, var(--t-calendar-day-hover-bg, var(--tct-gray-14, var(--app-gray14, var(--tct-gray-l4, var(--app-gray-l4, #f2f2f2))))));color:var(--tct-calendar-day-hover-font-color, var(--t-calendar-day-hover-font-color, inherit))}td[aria-hidden],td[aria-disabled]{pointer-events:none;cursor:not-allowed}td[aria-disabled]{opacity:var(--tct-calendar-day-disabled-opacity, var(--t-calendar-day-disabled-opacity, var(--app-disabled-opacity, 0.4)))}td[aria-selected]{background-color:var(--tct-calendar-day-selected-bg, var(--t-calendar-day-selected-bg, var(--tct-calendar-day-hover-bg, var(--t-calendar-day-hover-bg, var(--tct-gray-14, var(--t-gray-14, var(--tct-gray-l4, var(--app-gray-l4, #f2f2f2))))))));color:var(--tct-calendar-day-selected-font-color, var(--t-calendar-day-selected-font-color, var(--tct-calendar-day-hover-font-color, var(--t-calendar-day-hover-font-color, inherit))));box-shadow:inset 2px 2px var(--tct-calendar-day-selected-outline-color, var(--t-calendar-day-selected-outline-color, var(--tct-stoplight-info, var(--const-stoplight-info, #0079c1)))), inset -2px -2px var(--tct-calendar-day-selected-outline-color, var(--t-calendar-day-selected-outline-color, var(--tct-stoplight-info, var(--const-stoplight-info, #0079c1))))}.today-decorator{text-transform:uppercase;font-weight:700;font-size:10px;height:12px}.calendar-disclaimer{font-size:var(--tct-calendar-disclaimer-font-size, var(--t-calendar-disclaimer-font-size, var(--tct-font-size-small, var(--app-font-size-small, 12px))));border-top:1px solid var(--tct-calendar-disclaimer-border-color, var(--t-calendar-disclaimer-border-color, var(--tct-gray-13, var(--t-gray-13, var(--tct-gray-l3, var(--app-gray-l3, #e6e6e6))))));padding:var(--tct-calendar-disclaimer-padding, var(--tct-scale-2, var(--app-scale-2x, 10px)));text-align:left}";
|
|
3043
|
+
const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-global-focus, 0 0 0 2px #33b4ff)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit;font-stretch:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}.q2-element-dropdown{display:none;position:absolute;background-color:var(--app-white, #ffffff);color:var(--t-text, #4d4d4d);left:0;width:100%;z-index:100;margin-top:1px;box-shadow:var(--app-shadow-1, 0 2px 4px rgba(0, 0, 0, 0.3));height:0;overflow:hidden;opacity:0;visibility:hidden;transition:opacity var(--app-tween-1, 0.2s ease);border-radius:var(--tct-dropdown-border-radius, --t-dropdown-border-radius, 0);--comp-scrollbar-size:var(--tct-scrollbar-size, var(--t-scrollbar-size, var(--app-scale-1x, 5px)));--comp-scrollbar-border-radius:var(--tct-scrollbar-border-radius, var(--t-scrollbar-border-radius, var(--app-border-radius-1, 3px)));--comp-scrollbar-color:var(--tct-scrollbar-color, var(--t-scrollbar-color, var(--t-a11y-gray-color, #747474)));scrollbar-width:thin;scrollbar-color:var(--comp-scrollbar-color) transparent}.q2-element-dropdown::-webkit-scrollbar{width:var(--comp-scrollbar-size);height:var(--comp-scrollbar-size);margin:5px}.q2-element-dropdown::-webkit-scrollbar-thumb{background:var(--comp-scrollbar-color);border-radius:var(--comp-scrollbar-border-radius)}.q2-element-dropdown::-webkit-scrollbar-track{background:transparent;border-radius:var(--comp-scrollbar-border-radius)}.q2-element-dropdown.sizable{display:block;height:auto}.dropdown-open .q2-element-dropdown{display:block;height:auto;overflow:auto;opacity:1;visibility:visible}:host([alignment=right]) .q2-element-dropdown{left:auto;right:0}:host([block]) q2-btn,:host([block]){display:block}:host{display:block}:host[hidden]{display:none}.calendar-container{position:relative;display:block}q2-input{margin:0;cursor:pointer}.q2-element-dropdown{text-align:center;min-width:308px}.q2-element-dropdown.dropup{bottom:var(--comp-input-min-height, 44px);margin-bottom:0px}.calendar-label{font-size:var(--tct-calendar-label-font-size, var(--t-calendar-label-font-size, 16px));flex:1 1;flex-basis:calc(100% - var(--tct-btn-icon-width, 44px));margin:0;padding:var(--tct-calendar-label-vertical-padding, var(--t-calendar-label-vertical-padding, var(--tct-scale-2, var(--app-scale-2x, 10px)))) 0}.calendar-hint{text-align:left;margin:0}.cal-month-heading{padding:0 0 0.75rem;display:flex;justify-content:center;align-items:center;font-size:var(--tct-calendar-month-font-size, var(--t-calendar-month-font-size, 16px));font-weight:var(--tct-calendar-month-font-weight, var(--t-calendar-month-font-weight, 600))}.cal-month-text{min-width:82px;display:inline-block}.cal-year-text{min-width:50px;display:inline-block}table{width:100%;margin-bottom:2px}th{font-size:var(--tct-calendar-day-heading-font-size, var(--t-calendar-day-heading-font-size, inherit));font-weight:var(--tct-calendar-day-heading-font-weight, var(--t-calendar-day-heading-font-weight, 600));width:14.285714%}td{height:44px;cursor:pointer}td.is-unavailable{border:1px solid var(--tct-input-error-border-color, var(--const-stoplight-alert, #c30000))}td.is-valid:hover{background-color:var(--tct-calendar-day-hover-bg, var(--t-calendar-day-hover-bg, var(--tct-gray-14, var(--app-gray14, var(--tct-gray-l4, var(--app-gray-l4, #f2f2f2))))));color:var(--tct-calendar-day-hover-font-color, var(--t-calendar-day-hover-font-color, inherit))}td[aria-hidden],td[aria-disabled]{pointer-events:none;cursor:not-allowed}td[aria-disabled]{opacity:var(--tct-calendar-day-disabled-opacity, var(--t-calendar-day-disabled-opacity, var(--app-disabled-opacity, 0.4)))}td[aria-selected]{background-color:var(--tct-calendar-day-selected-bg, var(--t-calendar-day-selected-bg, var(--tct-calendar-day-hover-bg, var(--t-calendar-day-hover-bg, var(--tct-gray-14, var(--t-gray-14, var(--tct-gray-l4, var(--app-gray-l4, #f2f2f2))))))));color:var(--tct-calendar-day-selected-font-color, var(--t-calendar-day-selected-font-color, var(--tct-calendar-day-hover-font-color, var(--t-calendar-day-hover-font-color, inherit))));box-shadow:inset 2px 2px var(--tct-calendar-day-selected-outline-color, var(--t-calendar-day-selected-outline-color, var(--tct-stoplight-info, var(--const-stoplight-info, #0079c1)))), inset -2px -2px var(--tct-calendar-day-selected-outline-color, var(--t-calendar-day-selected-outline-color, var(--tct-stoplight-info, var(--const-stoplight-info, #0079c1))))}.today-decorator{text-transform:uppercase;font-weight:700;font-size:10px;height:12px}.calendar-disclaimer{font-size:var(--tct-calendar-disclaimer-font-size, var(--t-calendar-disclaimer-font-size, var(--tct-font-size-small, var(--app-font-size-small, 12px))));border-top:1px solid var(--tct-calendar-disclaimer-border-color, var(--t-calendar-disclaimer-border-color, var(--tct-gray-13, var(--t-gray-13, var(--tct-gray-l3, var(--app-gray-l3, #e6e6e6))))));padding:var(--tct-calendar-disclaimer-padding, var(--tct-scale-2, var(--app-scale-2x, 10px)));text-align:left}";
|
|
3141
3044
|
|
|
3142
3045
|
const Q2Calendar = class {
|
|
3143
3046
|
constructor(hostRef) {
|
|
@@ -3301,10 +3204,17 @@ const Q2Calendar = class {
|
|
|
3301
3204
|
(_a = this.btnPrevMonth) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new FocusEvent('focus'));
|
|
3302
3205
|
};
|
|
3303
3206
|
this.goToMonthYear = (monthIndex, year) => {
|
|
3304
|
-
|
|
3207
|
+
if (monthIndex < 0) {
|
|
3208
|
+
monthIndex = 11;
|
|
3209
|
+
year--;
|
|
3210
|
+
}
|
|
3211
|
+
else if (monthIndex > 11) {
|
|
3212
|
+
monthIndex = 0;
|
|
3213
|
+
year++;
|
|
3214
|
+
}
|
|
3305
3215
|
this.selectedMonthYear = {
|
|
3306
|
-
monthIndex
|
|
3307
|
-
selectedYear:
|
|
3216
|
+
monthIndex,
|
|
3217
|
+
selectedYear: year,
|
|
3308
3218
|
};
|
|
3309
3219
|
this.dateList = this.buildDateList(this.selectedMonthYear);
|
|
3310
3220
|
this.scheduledAfterRender.push(() => this.checkActiveCellForBlankness());
|
|
@@ -3628,7 +3538,7 @@ const Q2Calendar = class {
|
|
|
3628
3538
|
}
|
|
3629
3539
|
generateDateFromDay(day) {
|
|
3630
3540
|
const { monthIndex, selectedYear } = this.selectedMonthYear;
|
|
3631
|
-
return
|
|
3541
|
+
return new Date(selectedYear, monthIndex, day);
|
|
3632
3542
|
}
|
|
3633
3543
|
activateDay(date) {
|
|
3634
3544
|
this.goToMonthYear(date.getMonth(), date.getFullYear());
|