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