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