@mui/x-date-pickers 8.10.0 → 8.11.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/AdapterDateFns/AdapterDateFns.js +194 -195
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +57 -62
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +197 -198
- package/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +196 -196
- package/AdapterDateFnsV2/AdapterDateFnsV2.js +193 -193
- package/AdapterDayjs/AdapterDayjs.js +378 -379
- package/AdapterLuxon/AdapterLuxon.js +324 -326
- package/AdapterMoment/AdapterMoment.js +297 -302
- package/AdapterMomentHijri/AdapterMomentHijri.js +78 -78
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +78 -80
- package/CHANGELOG.md +309 -0
- package/PickersTextField/PickersInputBase/PickersInputBase.js +14 -1
- package/PickersTextField/PickersTextField.js +3 -2
- package/esm/AdapterDateFns/AdapterDateFns.js +194 -194
- package/esm/AdapterDateFnsBase/AdapterDateFnsBase.js +57 -62
- package/esm/AdapterDateFnsJalali/AdapterDateFnsJalali.js +197 -197
- package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +196 -196
- package/esm/AdapterDateFnsV2/AdapterDateFnsV2.js +193 -193
- package/esm/AdapterDayjs/AdapterDayjs.js +378 -379
- package/esm/AdapterLuxon/AdapterLuxon.js +324 -325
- package/esm/AdapterMoment/AdapterMoment.js +297 -301
- package/esm/AdapterMomentHijri/AdapterMomentHijri.js +78 -78
- package/esm/AdapterMomentJalaali/AdapterMomentJalaali.js +78 -80
- package/esm/PickersTextField/PickersInputBase/PickersInputBase.js +14 -1
- package/esm/PickersTextField/PickersTextField.js +3 -2
- package/esm/index.js +1 -1
- package/esm/internals/hooks/useField/syncSelectionToDOM.js +3 -1
- package/esm/internals/models/helpers.d.ts +1 -1
- package/esm/models/fields.d.ts +4 -0
- package/index.js +1 -1
- package/internals/hooks/useField/syncSelectionToDOM.js +3 -1
- package/internals/models/helpers.d.ts +1 -1
- package/models/fields.d.ts +4 -0
- package/package.json +15 -16
|
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.AdapterMoment = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _moment = _interopRequireDefault(require("moment"));
|
|
10
|
-
/* eslint-disable class-methods-use-this */
|
|
11
|
-
|
|
12
10
|
// From https://momentjs.com/docs/#/displaying/format/
|
|
13
11
|
const formatTokenMap = {
|
|
14
12
|
// Year
|
|
@@ -155,317 +153,314 @@ const MISSING_TIMEZONE_PLUGIN = ['Missing timezone plugin', 'To be able to use t
|
|
|
155
153
|
* SOFTWARE.
|
|
156
154
|
*/
|
|
157
155
|
class AdapterMoment {
|
|
156
|
+
isMUIAdapter = true;
|
|
157
|
+
isTimezoneCompatible = true;
|
|
158
|
+
lib = 'moment';
|
|
159
|
+
escapedCharacters = {
|
|
160
|
+
start: '[',
|
|
161
|
+
end: ']'
|
|
162
|
+
};
|
|
163
|
+
formatTokenMap = formatTokenMap;
|
|
158
164
|
constructor({
|
|
159
165
|
locale,
|
|
160
166
|
formats,
|
|
161
167
|
instance
|
|
162
168
|
} = {}) {
|
|
163
|
-
this.
|
|
164
|
-
this.
|
|
165
|
-
this.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
169
|
+
this.moment = instance || _moment.default;
|
|
170
|
+
this.locale = locale;
|
|
171
|
+
this.formats = (0, _extends2.default)({}, defaultFormats, formats);
|
|
172
|
+
}
|
|
173
|
+
setLocaleToValue = value => {
|
|
174
|
+
const expectedLocale = this.getCurrentLocaleCode();
|
|
175
|
+
if (expectedLocale === value.locale()) {
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
return value.locale(expectedLocale);
|
|
179
|
+
};
|
|
180
|
+
hasTimezonePlugin = () => typeof this.moment.tz !== 'undefined';
|
|
181
|
+
createSystemDate = value => {
|
|
182
|
+
const parsedValue = this.moment(value).local();
|
|
183
|
+
if (this.locale === undefined) {
|
|
184
|
+
return parsedValue;
|
|
185
|
+
}
|
|
186
|
+
return parsedValue.locale(this.locale);
|
|
187
|
+
};
|
|
188
|
+
createUTCDate = value => {
|
|
189
|
+
const parsedValue = this.moment.utc(value);
|
|
190
|
+
if (this.locale === undefined) {
|
|
191
|
+
return parsedValue;
|
|
192
|
+
}
|
|
193
|
+
return parsedValue.locale(this.locale);
|
|
194
|
+
};
|
|
195
|
+
createTZDate = (value, timezone) => {
|
|
196
|
+
/* v8 ignore next 3 */
|
|
197
|
+
if (!this.hasTimezonePlugin()) {
|
|
198
|
+
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
199
|
+
}
|
|
200
|
+
const parsedValue = timezone === 'default' ? this.moment(value) : this.moment.tz(value, timezone);
|
|
201
|
+
if (this.locale === undefined) {
|
|
202
|
+
return parsedValue;
|
|
203
|
+
}
|
|
204
|
+
return parsedValue.locale(this.locale);
|
|
205
|
+
};
|
|
206
|
+
date = (value, timezone = 'default') => {
|
|
207
|
+
if (value === null) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
if (timezone === 'UTC') {
|
|
211
|
+
return this.createUTCDate(value);
|
|
212
|
+
}
|
|
213
|
+
if (timezone === 'system' || timezone === 'default' && !this.hasTimezonePlugin()) {
|
|
214
|
+
return this.createSystemDate(value);
|
|
215
|
+
}
|
|
216
|
+
return this.createTZDate(value, timezone);
|
|
217
|
+
};
|
|
218
|
+
getInvalidDate = () => this.moment(new Date('Invalid Date'));
|
|
219
|
+
getTimezone = value => {
|
|
220
|
+
// @ts-ignore
|
|
221
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
222
|
+
const zone = value._z?.name;
|
|
223
|
+
const defaultZone = value.isUTC() ? 'UTC' : 'system';
|
|
224
|
+
|
|
225
|
+
// @ts-ignore
|
|
226
|
+
return zone ?? this.moment.defaultZone?.name ?? defaultZone;
|
|
227
|
+
};
|
|
228
|
+
setTimezone = (value, timezone) => {
|
|
229
|
+
if (this.getTimezone(value) === timezone) {
|
|
230
|
+
return value;
|
|
231
|
+
}
|
|
232
|
+
if (timezone === 'UTC') {
|
|
233
|
+
return value.clone().utc();
|
|
234
|
+
}
|
|
235
|
+
if (timezone === 'system') {
|
|
236
|
+
return value.clone().local();
|
|
237
|
+
}
|
|
238
|
+
if (!this.hasTimezonePlugin()) {
|
|
197
239
|
/* v8 ignore next 3 */
|
|
198
|
-
if (
|
|
240
|
+
if (timezone !== 'default') {
|
|
199
241
|
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
200
242
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
this.
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (
|
|
237
|
-
return
|
|
238
|
-
}
|
|
239
|
-
if (!this.hasTimezonePlugin()) {
|
|
240
|
-
/* v8 ignore next 3 */
|
|
241
|
-
if (timezone !== 'default') {
|
|
242
|
-
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
243
|
-
}
|
|
244
|
-
return value;
|
|
245
|
-
}
|
|
246
|
-
const cleanZone = timezone === 'default' ?
|
|
247
|
-
// @ts-ignore
|
|
248
|
-
this.moment.defaultZone?.name ?? 'system' : timezone;
|
|
249
|
-
if (cleanZone === 'system') {
|
|
250
|
-
return value.clone().local();
|
|
251
|
-
}
|
|
252
|
-
const newValue = value.clone();
|
|
253
|
-
newValue.tz(cleanZone);
|
|
254
|
-
return newValue;
|
|
255
|
-
};
|
|
256
|
-
this.toJsDate = value => {
|
|
257
|
-
return value.toDate();
|
|
258
|
-
};
|
|
259
|
-
this.parse = (value, format) => {
|
|
260
|
-
if (value === '') {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
if (this.locale) {
|
|
264
|
-
return this.moment(value, format, this.locale, true);
|
|
265
|
-
}
|
|
266
|
-
return this.moment(value, format, true);
|
|
267
|
-
};
|
|
268
|
-
this.getCurrentLocaleCode = () => {
|
|
269
|
-
return this.locale || _moment.default.locale();
|
|
270
|
-
};
|
|
271
|
-
this.is12HourCycleInCurrentLocale = () => {
|
|
272
|
-
return /A|a/.test(_moment.default.localeData(this.getCurrentLocaleCode()).longDateFormat('LT'));
|
|
273
|
-
};
|
|
274
|
-
this.expandFormat = format => {
|
|
275
|
-
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
|
|
276
|
-
const localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
|
|
277
|
-
return format.match(localFormattingTokens).map(token => {
|
|
278
|
-
const firstCharacter = token[0];
|
|
279
|
-
if (firstCharacter === 'L' || firstCharacter === ';') {
|
|
280
|
-
return _moment.default.localeData(this.getCurrentLocaleCode()).longDateFormat(token);
|
|
281
|
-
}
|
|
282
|
-
return token;
|
|
283
|
-
}).join('');
|
|
284
|
-
};
|
|
285
|
-
this.isValid = value => {
|
|
286
|
-
if (value == null) {
|
|
287
|
-
return false;
|
|
288
|
-
}
|
|
289
|
-
return value.isValid();
|
|
290
|
-
};
|
|
291
|
-
this.format = (value, formatKey) => {
|
|
292
|
-
return this.formatByString(value, this.formats[formatKey]);
|
|
293
|
-
};
|
|
294
|
-
this.formatByString = (value, formatString) => {
|
|
295
|
-
const clonedDate = value.clone();
|
|
296
|
-
clonedDate.locale(this.getCurrentLocaleCode());
|
|
297
|
-
return clonedDate.format(formatString);
|
|
298
|
-
};
|
|
299
|
-
this.formatNumber = numberToFormat => {
|
|
300
|
-
return numberToFormat;
|
|
301
|
-
};
|
|
302
|
-
this.isEqual = (value, comparing) => {
|
|
303
|
-
if (value === null && comparing === null) {
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
if (value === null || comparing === null) {
|
|
307
|
-
return false;
|
|
243
|
+
return value;
|
|
244
|
+
}
|
|
245
|
+
const cleanZone = timezone === 'default' ?
|
|
246
|
+
// @ts-ignore
|
|
247
|
+
this.moment.defaultZone?.name ?? 'system' : timezone;
|
|
248
|
+
if (cleanZone === 'system') {
|
|
249
|
+
return value.clone().local();
|
|
250
|
+
}
|
|
251
|
+
const newValue = value.clone();
|
|
252
|
+
newValue.tz(cleanZone);
|
|
253
|
+
return newValue;
|
|
254
|
+
};
|
|
255
|
+
toJsDate = value => {
|
|
256
|
+
return value.toDate();
|
|
257
|
+
};
|
|
258
|
+
parse = (value, format) => {
|
|
259
|
+
if (value === '') {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
if (this.locale) {
|
|
263
|
+
return this.moment(value, format, this.locale, true);
|
|
264
|
+
}
|
|
265
|
+
return this.moment(value, format, true);
|
|
266
|
+
};
|
|
267
|
+
getCurrentLocaleCode = () => {
|
|
268
|
+
return this.locale || _moment.default.locale();
|
|
269
|
+
};
|
|
270
|
+
is12HourCycleInCurrentLocale = () => {
|
|
271
|
+
return /A|a/.test(_moment.default.localeData(this.getCurrentLocaleCode()).longDateFormat('LT'));
|
|
272
|
+
};
|
|
273
|
+
expandFormat = format => {
|
|
274
|
+
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
|
|
275
|
+
const localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
|
|
276
|
+
return format.match(localFormattingTokens).map(token => {
|
|
277
|
+
const firstCharacter = token[0];
|
|
278
|
+
if (firstCharacter === 'L' || firstCharacter === ';') {
|
|
279
|
+
return _moment.default.localeData(this.getCurrentLocaleCode()).longDateFormat(token);
|
|
308
280
|
}
|
|
309
|
-
return
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
this.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
281
|
+
return token;
|
|
282
|
+
}).join('');
|
|
283
|
+
};
|
|
284
|
+
isValid = value => {
|
|
285
|
+
if (value == null) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
return value.isValid();
|
|
289
|
+
};
|
|
290
|
+
format = (value, formatKey) => {
|
|
291
|
+
return this.formatByString(value, this.formats[formatKey]);
|
|
292
|
+
};
|
|
293
|
+
formatByString = (value, formatString) => {
|
|
294
|
+
const clonedDate = value.clone();
|
|
295
|
+
clonedDate.locale(this.getCurrentLocaleCode());
|
|
296
|
+
return clonedDate.format(formatString);
|
|
297
|
+
};
|
|
298
|
+
formatNumber = numberToFormat => {
|
|
299
|
+
return numberToFormat;
|
|
300
|
+
};
|
|
301
|
+
isEqual = (value, comparing) => {
|
|
302
|
+
if (value === null && comparing === null) {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
if (value === null || comparing === null) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
return value.isSame(comparing);
|
|
309
|
+
};
|
|
310
|
+
isSameYear = (value, comparing) => {
|
|
311
|
+
return value.isSame(comparing, 'year');
|
|
312
|
+
};
|
|
313
|
+
isSameMonth = (value, comparing) => {
|
|
314
|
+
return value.isSame(comparing, 'month');
|
|
315
|
+
};
|
|
316
|
+
isSameDay = (value, comparing) => {
|
|
317
|
+
return value.isSame(comparing, 'day');
|
|
318
|
+
};
|
|
319
|
+
isSameHour = (value, comparing) => {
|
|
320
|
+
return value.isSame(comparing, 'hour');
|
|
321
|
+
};
|
|
322
|
+
isAfter = (value, comparing) => {
|
|
323
|
+
return value.isAfter(comparing);
|
|
324
|
+
};
|
|
325
|
+
isAfterYear = (value, comparing) => {
|
|
326
|
+
return value.isAfter(comparing, 'year');
|
|
327
|
+
};
|
|
328
|
+
isAfterDay = (value, comparing) => {
|
|
329
|
+
return value.isAfter(comparing, 'day');
|
|
330
|
+
};
|
|
331
|
+
isBefore = (value, comparing) => {
|
|
332
|
+
return value.isBefore(comparing);
|
|
333
|
+
};
|
|
334
|
+
isBeforeYear = (value, comparing) => {
|
|
335
|
+
return value.isBefore(comparing, 'year');
|
|
336
|
+
};
|
|
337
|
+
isBeforeDay = (value, comparing) => {
|
|
338
|
+
return value.isBefore(comparing, 'day');
|
|
339
|
+
};
|
|
340
|
+
isWithinRange = (value, [start, end]) => {
|
|
341
|
+
return value.isBetween(start, end, null, '[]');
|
|
342
|
+
};
|
|
343
|
+
startOfYear = value => {
|
|
344
|
+
return value.clone().startOf('year');
|
|
345
|
+
};
|
|
346
|
+
startOfMonth = value => {
|
|
347
|
+
return value.clone().startOf('month');
|
|
348
|
+
};
|
|
349
|
+
startOfWeek = value => {
|
|
350
|
+
return this.setLocaleToValue(value.clone()).startOf('week');
|
|
351
|
+
};
|
|
352
|
+
startOfDay = value => {
|
|
353
|
+
return value.clone().startOf('day');
|
|
354
|
+
};
|
|
355
|
+
endOfYear = value => {
|
|
356
|
+
return value.clone().endOf('year');
|
|
357
|
+
};
|
|
358
|
+
endOfMonth = value => {
|
|
359
|
+
return value.clone().endOf('month');
|
|
360
|
+
};
|
|
361
|
+
endOfWeek = value => {
|
|
362
|
+
return this.setLocaleToValue(value.clone()).endOf('week');
|
|
363
|
+
};
|
|
364
|
+
endOfDay = value => {
|
|
365
|
+
return value.clone().endOf('day');
|
|
366
|
+
};
|
|
367
|
+
addYears = (value, amount) => {
|
|
368
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'years') : value.clone().add(amount, 'years');
|
|
369
|
+
};
|
|
370
|
+
addMonths = (value, amount) => {
|
|
371
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'months') : value.clone().add(amount, 'months');
|
|
372
|
+
};
|
|
373
|
+
addWeeks = (value, amount) => {
|
|
374
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'weeks') : value.clone().add(amount, 'weeks');
|
|
375
|
+
};
|
|
376
|
+
addDays = (value, amount) => {
|
|
377
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'days') : value.clone().add(amount, 'days');
|
|
378
|
+
};
|
|
379
|
+
addHours = (value, amount) => {
|
|
380
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'hours') : value.clone().add(amount, 'hours');
|
|
381
|
+
};
|
|
382
|
+
addMinutes = (value, amount) => {
|
|
383
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'minutes') : value.clone().add(amount, 'minutes');
|
|
384
|
+
};
|
|
385
|
+
addSeconds = (value, amount) => {
|
|
386
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'seconds') : value.clone().add(amount, 'seconds');
|
|
387
|
+
};
|
|
388
|
+
getYear = value => {
|
|
389
|
+
return value.get('year');
|
|
390
|
+
};
|
|
391
|
+
getMonth = value => {
|
|
392
|
+
return value.get('month');
|
|
393
|
+
};
|
|
394
|
+
getDate = value => {
|
|
395
|
+
return value.get('date');
|
|
396
|
+
};
|
|
397
|
+
getHours = value => {
|
|
398
|
+
return value.get('hours');
|
|
399
|
+
};
|
|
400
|
+
getMinutes = value => {
|
|
401
|
+
return value.get('minutes');
|
|
402
|
+
};
|
|
403
|
+
getSeconds = value => {
|
|
404
|
+
return value.get('seconds');
|
|
405
|
+
};
|
|
406
|
+
getMilliseconds = value => {
|
|
407
|
+
return value.get('milliseconds');
|
|
408
|
+
};
|
|
409
|
+
setYear = (value, year) => {
|
|
410
|
+
return value.clone().year(year);
|
|
411
|
+
};
|
|
412
|
+
setMonth = (value, month) => {
|
|
413
|
+
return value.clone().month(month);
|
|
414
|
+
};
|
|
415
|
+
setDate = (value, date) => {
|
|
416
|
+
return value.clone().date(date);
|
|
417
|
+
};
|
|
418
|
+
setHours = (value, hours) => {
|
|
419
|
+
return value.clone().hours(hours);
|
|
420
|
+
};
|
|
421
|
+
setMinutes = (value, minutes) => {
|
|
422
|
+
return value.clone().minutes(minutes);
|
|
423
|
+
};
|
|
424
|
+
setSeconds = (value, seconds) => {
|
|
425
|
+
return value.clone().seconds(seconds);
|
|
426
|
+
};
|
|
427
|
+
setMilliseconds = (value, milliseconds) => {
|
|
428
|
+
return value.clone().milliseconds(milliseconds);
|
|
429
|
+
};
|
|
430
|
+
getDaysInMonth = value => {
|
|
431
|
+
return value.daysInMonth();
|
|
432
|
+
};
|
|
433
|
+
getWeekArray = value => {
|
|
434
|
+
const start = this.startOfWeek(this.startOfMonth(value));
|
|
435
|
+
const end = this.endOfWeek(this.endOfMonth(value));
|
|
436
|
+
let count = 0;
|
|
437
|
+
let current = start;
|
|
438
|
+
let currentDayOfYear = current.get('dayOfYear');
|
|
439
|
+
const nestedWeeks = [];
|
|
440
|
+
while (current.isBefore(end)) {
|
|
441
|
+
const weekNumber = Math.floor(count / 7);
|
|
442
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
443
|
+
nestedWeeks[weekNumber].push(current);
|
|
444
|
+
const prevDayOfYear = currentDayOfYear;
|
|
445
|
+
current = this.addDays(current, 1);
|
|
446
|
+
currentDayOfYear = current.get('dayOfYear');
|
|
448
447
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
count += 1;
|
|
448
|
+
// If there is a TZ change at midnight, adding 1 day may only increase the date by 23 hours to 11pm
|
|
449
|
+
// To fix, bump the date into the next day (add 12 hours) and then revert to the start of the day
|
|
450
|
+
// See https://github.com/moment/moment/issues/4743#issuecomment-811306874 for context.
|
|
451
|
+
if (prevDayOfYear === currentDayOfYear) {
|
|
452
|
+
current = current.add(12, 'h').startOf('day');
|
|
456
453
|
}
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
this.formats = (0, _extends2.default)({}, defaultFormats, formats);
|
|
468
|
-
}
|
|
454
|
+
count += 1;
|
|
455
|
+
}
|
|
456
|
+
return nestedWeeks;
|
|
457
|
+
};
|
|
458
|
+
getWeekNumber = value => {
|
|
459
|
+
return value.week();
|
|
460
|
+
};
|
|
461
|
+
getDayOfWeek = value => {
|
|
462
|
+
return value.day() + 1;
|
|
463
|
+
};
|
|
469
464
|
getYearRange([start, end]) {
|
|
470
465
|
const startDate = this.startOfYear(start);
|
|
471
466
|
const endDate = this.endOfYear(end);
|