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