@mui/x-date-pickers 8.9.2 → 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.
Files changed (30) hide show
  1. package/AdapterDateFns/AdapterDateFns.js +194 -193
  2. package/AdapterDateFnsBase/AdapterDateFnsBase.js +57 -60
  3. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +197 -196
  4. package/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +195 -195
  5. package/AdapterDateFnsV2/AdapterDateFnsV2.js +192 -192
  6. package/AdapterDayjs/AdapterDayjs.js +378 -378
  7. package/AdapterLuxon/AdapterLuxon.js +324 -324
  8. package/AdapterMoment/AdapterMoment.js +297 -300
  9. package/AdapterMomentHijri/AdapterMomentHijri.js +78 -77
  10. package/AdapterMomentJalaali/AdapterMomentJalaali.js +78 -79
  11. package/CHANGELOG.md +303 -6
  12. package/PickersLayout/PickersLayout.js +12 -9
  13. package/PickersLayout/PickersLayout.types.d.ts +5 -0
  14. package/PickersLayout/usePickerLayout.js +6 -2
  15. package/esm/AdapterDateFns/AdapterDateFns.js +194 -193
  16. package/esm/AdapterDateFnsBase/AdapterDateFnsBase.js +57 -60
  17. package/esm/AdapterDateFnsJalali/AdapterDateFnsJalali.js +197 -196
  18. package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +195 -195
  19. package/esm/AdapterDateFnsV2/AdapterDateFnsV2.js +192 -192
  20. package/esm/AdapterDayjs/AdapterDayjs.js +378 -378
  21. package/esm/AdapterLuxon/AdapterLuxon.js +324 -324
  22. package/esm/AdapterMoment/AdapterMoment.js +297 -300
  23. package/esm/AdapterMomentHijri/AdapterMomentHijri.js +78 -77
  24. package/esm/AdapterMomentJalaali/AdapterMomentJalaali.js +78 -79
  25. package/esm/PickersLayout/PickersLayout.js +12 -9
  26. package/esm/PickersLayout/PickersLayout.types.d.ts +5 -0
  27. package/esm/PickersLayout/usePickerLayout.js +6 -2
  28. package/esm/index.js +1 -1
  29. package/index.js +1 -1
  30. package/package.json +7 -9
@@ -158,344 +158,344 @@ const defaultFormats = {
158
158
  * SOFTWARE.
159
159
  */
160
160
  export class AdapterLuxon {
161
+ isMUIAdapter = true;
162
+ isTimezoneCompatible = true;
163
+ lib = 'luxon';
164
+ escapedCharacters = {
165
+ start: "'",
166
+ end: "'"
167
+ };
168
+ formatTokenMap = (() => formatTokenMap)();
161
169
  constructor({
162
170
  locale,
163
171
  formats
164
172
  } = {}) {
165
- this.isMUIAdapter = true;
166
- this.isTimezoneCompatible = true;
167
- this.lib = 'luxon';
168
- this.locale = void 0;
169
- this.formats = void 0;
170
- this.escapedCharacters = {
171
- start: "'",
172
- end: "'"
173
- };
174
- this.formatTokenMap = formatTokenMap;
175
- this.setLocaleToValue = value => {
176
- const expectedLocale = this.getCurrentLocaleCode();
177
- if (expectedLocale === value.locale) {
178
- return value;
179
- }
180
- return value.setLocale(expectedLocale);
181
- };
182
- this.date = (value, timezone = 'default') => {
183
- if (value === null) {
184
- return null;
185
- }
186
- if (typeof value === 'undefined') {
187
- // @ts-ignore
188
- return DateTime.fromJSDate(new Date(), {
189
- locale: this.locale,
190
- zone: timezone
191
- });
192
- }
193
-
173
+ this.locale = locale || 'en-US';
174
+ this.formats = _extends({}, defaultFormats, formats);
175
+ }
176
+ setLocaleToValue = value => {
177
+ const expectedLocale = this.getCurrentLocaleCode();
178
+ if (expectedLocale === value.locale) {
179
+ return value;
180
+ }
181
+ return value.setLocale(expectedLocale);
182
+ };
183
+ date = (value, timezone = 'default') => {
184
+ if (value === null) {
185
+ return null;
186
+ }
187
+ if (typeof value === 'undefined') {
194
188
  // @ts-ignore
195
- return DateTime.fromISO(value, {
189
+ return DateTime.fromJSDate(new Date(), {
196
190
  locale: this.locale,
197
191
  zone: timezone
198
192
  });
199
- };
200
- this.getInvalidDate = () => DateTime.fromJSDate(new Date('Invalid Date'));
201
- this.getTimezone = value => {
202
- // When using the system zone, we want to return "system", not something like "Europe/Paris"
203
- if (value.zone.type === 'system') {
204
- return 'system';
205
- }
206
- return value.zoneName;
207
- };
208
- this.setTimezone = (value, timezone) => {
209
- if (!value.zone.equals(Info.normalizeZone(timezone))) {
210
- return value.setZone(timezone);
211
- }
212
- return value;
213
- };
214
- this.toJsDate = value => {
215
- return value.toJSDate();
216
- };
217
- this.parse = (value, formatString) => {
218
- if (value === '') {
219
- return null;
220
- }
221
- return DateTime.fromFormat(value, formatString, {
222
- locale: this.locale
223
- });
224
- };
225
- this.getCurrentLocaleCode = () => {
226
- return this.locale;
227
- };
228
- /* v8 ignore start */
229
- this.is12HourCycleInCurrentLocale = () => {
230
- if (typeof Intl === 'undefined' || typeof Intl.DateTimeFormat === 'undefined') {
231
- return true; // Luxon defaults to en-US if Intl not found
232
- }
233
- return Boolean(new Intl.DateTimeFormat(this.locale, {
234
- hour: 'numeric'
235
- })?.resolvedOptions()?.hour12);
236
- };
237
- /* v8 ignore stop */
238
- this.expandFormat = format => {
239
- // Extract escaped section to avoid extending them
240
- const catchEscapedSectionsRegexp = /''|'(''|[^'])+('|$)|[^']*/g;
193
+ }
241
194
 
242
- // This RegExp tests if a string is only mad of supported tokens
243
- const validTokens = [...Object.keys(this.formatTokenMap), 'yyyyy'];
244
- const isWordComposedOfTokens = new RegExp(`^(${validTokens.join('|')})+$`);
195
+ // @ts-ignore
196
+ return DateTime.fromISO(value, {
197
+ locale: this.locale,
198
+ zone: timezone
199
+ });
200
+ };
201
+ getInvalidDate = () => DateTime.fromJSDate(new Date('Invalid Date'));
202
+ getTimezone = value => {
203
+ // When using the system zone, we want to return "system", not something like "Europe/Paris"
204
+ if (value.zone.type === 'system') {
205
+ return 'system';
206
+ }
207
+ return value.zoneName;
208
+ };
209
+ setTimezone = (value, timezone) => {
210
+ if (!value.zone.equals(Info.normalizeZone(timezone))) {
211
+ return value.setZone(timezone);
212
+ }
213
+ return value;
214
+ };
215
+ toJsDate = value => {
216
+ return value.toJSDate();
217
+ };
218
+ parse = (value, formatString) => {
219
+ if (value === '') {
220
+ return null;
221
+ }
222
+ return DateTime.fromFormat(value, formatString, {
223
+ locale: this.locale
224
+ });
225
+ };
226
+ getCurrentLocaleCode = () => {
227
+ return this.locale;
228
+ };
245
229
 
246
- // Extract words to test if they are a token or a word to escape.
247
- const catchWordsRegexp = /(?:^|[^a-z])([a-z]+)(?:[^a-z]|$)|([a-z]+)/gi;
248
- return format.match(catchEscapedSectionsRegexp).map(token => {
249
- const firstCharacter = token[0];
250
- if (firstCharacter === "'") {
251
- return token;
252
- }
253
- const expandedToken = DateTime.expandFormat(token, {
254
- locale: this.locale
255
- });
256
- return expandedToken.replace(catchWordsRegexp, (substring, g1, g2) => {
257
- const word = g1 || g2; // words are either in group 1 or group 2
230
+ /* v8 ignore start */
231
+ is12HourCycleInCurrentLocale = () => {
232
+ if (typeof Intl === 'undefined' || typeof Intl.DateTimeFormat === 'undefined') {
233
+ return true; // Luxon defaults to en-US if Intl not found
234
+ }
235
+ return Boolean(new Intl.DateTimeFormat(this.locale, {
236
+ hour: 'numeric'
237
+ })?.resolvedOptions()?.hour12);
238
+ };
239
+ /* v8 ignore stop */
258
240
 
259
- if (isWordComposedOfTokens.test(word)) {
260
- return substring;
261
- }
262
- return `'${substring}'`;
263
- });
264
- }).join('')
265
- // The returned format can contain `yyyyy` which means year between 4 and 6 digits.
266
- // This value is supported by luxon parser but not luxon formatter.
267
- // To avoid conflicts, we replace it by 4 digits which is enough for most use-cases.
268
- .replace('yyyyy', 'yyyy');
269
- };
270
- this.isValid = value => {
271
- if (value === null) {
272
- return false;
273
- }
274
- return value.isValid;
275
- };
276
- this.format = (value, formatKey) => {
277
- return this.formatByString(value, this.formats[formatKey]);
278
- };
279
- this.formatByString = (value, format) => {
280
- return value.setLocale(this.locale).toFormat(format);
281
- };
282
- this.formatNumber = numberToFormat => {
283
- return numberToFormat;
284
- };
285
- this.isEqual = (value, comparing) => {
286
- if (value === null && comparing === null) {
287
- return true;
288
- }
289
- if (value === null || comparing === null) {
290
- return false;
241
+ expandFormat = format => {
242
+ // Extract escaped section to avoid extending them
243
+ const catchEscapedSectionsRegexp = /''|'(''|[^'])+('|$)|[^']*/g;
244
+
245
+ // This RegExp tests if a string is only mad of supported tokens
246
+ const validTokens = [...Object.keys(this.formatTokenMap), 'yyyyy'];
247
+ const isWordComposedOfTokens = new RegExp(`^(${validTokens.join('|')})+$`);
248
+
249
+ // Extract words to test if they are a token or a word to escape.
250
+ const catchWordsRegexp = /(?:^|[^a-z])([a-z]+)(?:[^a-z]|$)|([a-z]+)/gi;
251
+ return format.match(catchEscapedSectionsRegexp).map(token => {
252
+ const firstCharacter = token[0];
253
+ if (firstCharacter === "'") {
254
+ return token;
291
255
  }
292
- return +value === +comparing;
293
- };
294
- this.isSameYear = (value, comparing) => {
295
- const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
296
- return value.hasSame(comparingInValueTimezone, 'year');
297
- };
298
- this.isSameMonth = (value, comparing) => {
299
- const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
300
- return value.hasSame(comparingInValueTimezone, 'month');
301
- };
302
- this.isSameDay = (value, comparing) => {
303
- const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
304
- return value.hasSame(comparingInValueTimezone, 'day');
305
- };
306
- this.isSameHour = (value, comparing) => {
307
- const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
308
- return value.hasSame(comparingInValueTimezone, 'hour');
309
- };
310
- this.isAfter = (value, comparing) => {
311
- return value > comparing;
312
- };
313
- this.isAfterYear = (value, comparing) => {
314
- const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
315
- const diff = value.diff(this.endOfYear(comparingInValueTimezone), 'years').toObject();
316
- return diff.years > 0;
317
- };
318
- this.isAfterDay = (value, comparing) => {
319
- const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
320
- const diff = value.diff(this.endOfDay(comparingInValueTimezone), 'days').toObject();
321
- return diff.days > 0;
322
- };
323
- this.isBefore = (value, comparing) => {
324
- return value < comparing;
325
- };
326
- this.isBeforeYear = (value, comparing) => {
327
- const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
328
- const diff = value.diff(this.startOfYear(comparingInValueTimezone), 'years').toObject();
329
- return diff.years < 0;
330
- };
331
- this.isBeforeDay = (value, comparing) => {
332
- const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
333
- const diff = value.diff(this.startOfDay(comparingInValueTimezone), 'days').toObject();
334
- return diff.days < 0;
335
- };
336
- this.isWithinRange = (value, [start, end]) => {
337
- return this.isEqual(value, start) || this.isEqual(value, end) || this.isAfter(value, start) && this.isBefore(value, end);
338
- };
339
- this.startOfYear = value => {
340
- return value.startOf('year');
341
- };
342
- this.startOfMonth = value => {
343
- return value.startOf('month');
344
- };
345
- this.startOfWeek = value => {
346
- return this.setLocaleToValue(value).startOf('week', {
347
- useLocaleWeeks: true
348
- });
349
- };
350
- this.startOfDay = value => {
351
- return value.startOf('day');
352
- };
353
- this.endOfYear = value => {
354
- return value.endOf('year');
355
- };
356
- this.endOfMonth = value => {
357
- return value.endOf('month');
358
- };
359
- this.endOfWeek = value => {
360
- return this.setLocaleToValue(value).endOf('week', {
361
- useLocaleWeeks: true
362
- });
363
- };
364
- this.endOfDay = value => {
365
- return value.endOf('day');
366
- };
367
- this.addYears = (value, amount) => {
368
- return value.plus({
369
- years: amount
370
- });
371
- };
372
- this.addMonths = (value, amount) => {
373
- return value.plus({
374
- months: amount
375
- });
376
- };
377
- this.addWeeks = (value, amount) => {
378
- return value.plus({
379
- weeks: amount
380
- });
381
- };
382
- this.addDays = (value, amount) => {
383
- return value.plus({
384
- days: amount
385
- });
386
- };
387
- this.addHours = (value, amount) => {
388
- return value.plus({
389
- hours: amount
390
- });
391
- };
392
- this.addMinutes = (value, amount) => {
393
- return value.plus({
394
- minutes: amount
395
- });
396
- };
397
- this.addSeconds = (value, amount) => {
398
- return value.plus({
399
- seconds: amount
400
- });
401
- };
402
- this.getYear = value => {
403
- return value.get('year');
404
- };
405
- this.getMonth = value => {
406
- // See https://github.com/moment/luxon/blob/master/docs/moment.md#major-functional-differences
407
- return value.get('month') - 1;
408
- };
409
- this.getDate = value => {
410
- return value.get('day');
411
- };
412
- this.getHours = value => {
413
- return value.get('hour');
414
- };
415
- this.getMinutes = value => {
416
- return value.get('minute');
417
- };
418
- this.getSeconds = value => {
419
- return value.get('second');
420
- };
421
- this.getMilliseconds = value => {
422
- return value.get('millisecond');
423
- };
424
- this.setYear = (value, year) => {
425
- return value.set({
426
- year
427
- });
428
- };
429
- this.setMonth = (value, month) => {
430
- return value.set({
431
- month: month + 1
432
- });
433
- };
434
- this.setDate = (value, date) => {
435
- return value.set({
436
- day: date
437
- });
438
- };
439
- this.setHours = (value, hours) => {
440
- return value.set({
441
- hour: hours
442
- });
443
- };
444
- this.setMinutes = (value, minutes) => {
445
- return value.set({
446
- minute: minutes
447
- });
448
- };
449
- this.setSeconds = (value, seconds) => {
450
- return value.set({
451
- second: seconds
452
- });
453
- };
454
- this.setMilliseconds = (value, milliseconds) => {
455
- return value.set({
456
- millisecond: milliseconds
256
+ const expandedToken = DateTime.expandFormat(token, {
257
+ locale: this.locale
457
258
  });
458
- };
459
- this.getDaysInMonth = value => {
460
- return value.daysInMonth;
461
- };
462
- this.getWeekArray = value => {
463
- const firstDay = this.startOfWeek(this.startOfMonth(value));
464
- const lastDay = this.endOfWeek(this.endOfMonth(value));
465
- const {
466
- days
467
- } = lastDay.diff(firstDay, 'days').toObject();
468
- const weeks = [];
469
- new Array(Math.round(days)).fill(0).map((_, i) => i).map(day => firstDay.plus({
470
- days: day
471
- })).forEach((v, i) => {
472
- if (i === 0 || i % 7 === 0 && i > 6) {
473
- weeks.push([v]);
474
- return;
259
+ return expandedToken.replace(catchWordsRegexp, (substring, g1, g2) => {
260
+ const word = g1 || g2; // words are either in group 1 or group 2
261
+
262
+ if (isWordComposedOfTokens.test(word)) {
263
+ return substring;
475
264
  }
476
- weeks[weeks.length - 1].push(v);
265
+ return `'${substring}'`;
477
266
  });
478
- return weeks;
479
- };
480
- this.getWeekNumber = value => {
481
- /* v8 ignore next */
482
- return value.localWeekNumber ?? value.weekNumber;
483
- };
484
- this.getDayOfWeek = value => {
485
- return value.weekday;
486
- };
487
- this.getYearRange = ([start, end]) => {
488
- const startDate = this.startOfYear(start);
489
- const endDate = this.endOfYear(end);
490
- const years = [];
491
- let current = startDate;
492
- while (this.isBefore(current, endDate)) {
493
- years.push(current);
494
- current = this.addYears(current, 1);
267
+ }).join('')
268
+ // The returned format can contain `yyyyy` which means year between 4 and 6 digits.
269
+ // This value is supported by luxon parser but not luxon formatter.
270
+ // To avoid conflicts, we replace it by 4 digits which is enough for most use-cases.
271
+ .replace('yyyyy', 'yyyy');
272
+ };
273
+ isValid = value => {
274
+ if (value === null) {
275
+ return false;
276
+ }
277
+ return value.isValid;
278
+ };
279
+ format = (value, formatKey) => {
280
+ return this.formatByString(value, this.formats[formatKey]);
281
+ };
282
+ formatByString = (value, format) => {
283
+ return value.setLocale(this.locale).toFormat(format);
284
+ };
285
+ formatNumber = numberToFormat => {
286
+ return numberToFormat;
287
+ };
288
+ isEqual = (value, comparing) => {
289
+ if (value === null && comparing === null) {
290
+ return true;
291
+ }
292
+ if (value === null || comparing === null) {
293
+ return false;
294
+ }
295
+ return +value === +comparing;
296
+ };
297
+ isSameYear = (value, comparing) => {
298
+ const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
299
+ return value.hasSame(comparingInValueTimezone, 'year');
300
+ };
301
+ isSameMonth = (value, comparing) => {
302
+ const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
303
+ return value.hasSame(comparingInValueTimezone, 'month');
304
+ };
305
+ isSameDay = (value, comparing) => {
306
+ const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
307
+ return value.hasSame(comparingInValueTimezone, 'day');
308
+ };
309
+ isSameHour = (value, comparing) => {
310
+ const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
311
+ return value.hasSame(comparingInValueTimezone, 'hour');
312
+ };
313
+ isAfter = (value, comparing) => {
314
+ return value > comparing;
315
+ };
316
+ isAfterYear = (value, comparing) => {
317
+ const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
318
+ const diff = value.diff(this.endOfYear(comparingInValueTimezone), 'years').toObject();
319
+ return diff.years > 0;
320
+ };
321
+ isAfterDay = (value, comparing) => {
322
+ const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
323
+ const diff = value.diff(this.endOfDay(comparingInValueTimezone), 'days').toObject();
324
+ return diff.days > 0;
325
+ };
326
+ isBefore = (value, comparing) => {
327
+ return value < comparing;
328
+ };
329
+ isBeforeYear = (value, comparing) => {
330
+ const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
331
+ const diff = value.diff(this.startOfYear(comparingInValueTimezone), 'years').toObject();
332
+ return diff.years < 0;
333
+ };
334
+ isBeforeDay = (value, comparing) => {
335
+ const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
336
+ const diff = value.diff(this.startOfDay(comparingInValueTimezone), 'days').toObject();
337
+ return diff.days < 0;
338
+ };
339
+ isWithinRange = (value, [start, end]) => {
340
+ return this.isEqual(value, start) || this.isEqual(value, end) || this.isAfter(value, start) && this.isBefore(value, end);
341
+ };
342
+ startOfYear = value => {
343
+ return value.startOf('year');
344
+ };
345
+ startOfMonth = value => {
346
+ return value.startOf('month');
347
+ };
348
+ startOfWeek = value => {
349
+ return this.setLocaleToValue(value).startOf('week', {
350
+ useLocaleWeeks: true
351
+ });
352
+ };
353
+ startOfDay = value => {
354
+ return value.startOf('day');
355
+ };
356
+ endOfYear = value => {
357
+ return value.endOf('year');
358
+ };
359
+ endOfMonth = value => {
360
+ return value.endOf('month');
361
+ };
362
+ endOfWeek = value => {
363
+ return this.setLocaleToValue(value).endOf('week', {
364
+ useLocaleWeeks: true
365
+ });
366
+ };
367
+ endOfDay = value => {
368
+ return value.endOf('day');
369
+ };
370
+ addYears = (value, amount) => {
371
+ return value.plus({
372
+ years: amount
373
+ });
374
+ };
375
+ addMonths = (value, amount) => {
376
+ return value.plus({
377
+ months: amount
378
+ });
379
+ };
380
+ addWeeks = (value, amount) => {
381
+ return value.plus({
382
+ weeks: amount
383
+ });
384
+ };
385
+ addDays = (value, amount) => {
386
+ return value.plus({
387
+ days: amount
388
+ });
389
+ };
390
+ addHours = (value, amount) => {
391
+ return value.plus({
392
+ hours: amount
393
+ });
394
+ };
395
+ addMinutes = (value, amount) => {
396
+ return value.plus({
397
+ minutes: amount
398
+ });
399
+ };
400
+ addSeconds = (value, amount) => {
401
+ return value.plus({
402
+ seconds: amount
403
+ });
404
+ };
405
+ getYear = value => {
406
+ return value.get('year');
407
+ };
408
+ getMonth = value => {
409
+ // See https://github.com/moment/luxon/blob/master/docs/moment.md#major-functional-differences
410
+ return value.get('month') - 1;
411
+ };
412
+ getDate = value => {
413
+ return value.get('day');
414
+ };
415
+ getHours = value => {
416
+ return value.get('hour');
417
+ };
418
+ getMinutes = value => {
419
+ return value.get('minute');
420
+ };
421
+ getSeconds = value => {
422
+ return value.get('second');
423
+ };
424
+ getMilliseconds = value => {
425
+ return value.get('millisecond');
426
+ };
427
+ setYear = (value, year) => {
428
+ return value.set({
429
+ year
430
+ });
431
+ };
432
+ setMonth = (value, month) => {
433
+ return value.set({
434
+ month: month + 1
435
+ });
436
+ };
437
+ setDate = (value, date) => {
438
+ return value.set({
439
+ day: date
440
+ });
441
+ };
442
+ setHours = (value, hours) => {
443
+ return value.set({
444
+ hour: hours
445
+ });
446
+ };
447
+ setMinutes = (value, minutes) => {
448
+ return value.set({
449
+ minute: minutes
450
+ });
451
+ };
452
+ setSeconds = (value, seconds) => {
453
+ return value.set({
454
+ second: seconds
455
+ });
456
+ };
457
+ setMilliseconds = (value, milliseconds) => {
458
+ return value.set({
459
+ millisecond: milliseconds
460
+ });
461
+ };
462
+ getDaysInMonth = value => {
463
+ return value.daysInMonth;
464
+ };
465
+ getWeekArray = value => {
466
+ const firstDay = this.startOfWeek(this.startOfMonth(value));
467
+ const lastDay = this.endOfWeek(this.endOfMonth(value));
468
+ const {
469
+ days
470
+ } = lastDay.diff(firstDay, 'days').toObject();
471
+ const weeks = [];
472
+ new Array(Math.round(days)).fill(0).map((_, i) => i).map(day => firstDay.plus({
473
+ days: day
474
+ })).forEach((v, i) => {
475
+ if (i === 0 || i % 7 === 0 && i > 6) {
476
+ weeks.push([v]);
477
+ return;
495
478
  }
496
- return years;
497
- };
498
- this.locale = locale || 'en-US';
499
- this.formats = _extends({}, defaultFormats, formats);
500
- }
479
+ weeks[weeks.length - 1].push(v);
480
+ });
481
+ return weeks;
482
+ };
483
+ getWeekNumber = value => {
484
+ /* v8 ignore next */
485
+ return value.localWeekNumber ?? value.weekNumber;
486
+ };
487
+ getDayOfWeek = value => {
488
+ return value.weekday;
489
+ };
490
+ getYearRange = ([start, end]) => {
491
+ const startDate = this.startOfYear(start);
492
+ const endDate = this.endOfYear(end);
493
+ const years = [];
494
+ let current = startDate;
495
+ while (this.isBefore(current, endDate)) {
496
+ years.push(current);
497
+ current = this.addYears(current, 1);
498
+ }
499
+ return years;
500
+ };
501
501
  }