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