@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.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.isMUIAdapter = true;
164
- this.isTimezoneCompatible = true;
165
- this.lib = 'moment';
166
- this.moment = void 0;
167
- this.locale = void 0;
168
- this.formats = void 0;
169
- this.escapedCharacters = {
170
- start: '[',
171
- end: ']'
172
- };
173
- this.formatTokenMap = formatTokenMap;
174
- this.setLocaleToValue = value => {
175
- const expectedLocale = this.getCurrentLocaleCode();
176
- if (expectedLocale === value.locale()) {
177
- return value;
178
- }
179
- return value.locale(expectedLocale);
180
- };
181
- this.hasTimezonePlugin = () => typeof this.moment.tz !== 'undefined';
182
- this.createSystemDate = value => {
183
- const parsedValue = this.moment(value).local();
184
- if (this.locale === undefined) {
185
- return parsedValue;
186
- }
187
- return parsedValue.locale(this.locale);
188
- };
189
- this.createUTCDate = value => {
190
- const parsedValue = this.moment.utc(value);
191
- if (this.locale === undefined) {
192
- return parsedValue;
193
- }
194
- return parsedValue.locale(this.locale);
195
- };
196
- this.createTZDate = (value, timezone) => {
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 (!this.hasTimezonePlugin()) {
240
+ if (timezone !== 'default') {
199
241
  throw new Error(MISSING_TIMEZONE_PLUGIN);
200
242
  }
201
- const parsedValue = timezone === 'default' ? this.moment(value) : this.moment.tz(value, timezone);
202
- if (this.locale === undefined) {
203
- return parsedValue;
204
- }
205
- return parsedValue.locale(this.locale);
206
- };
207
- this.date = (value, timezone = 'default') => {
208
- if (value === null) {
209
- return null;
210
- }
211
- if (timezone === 'UTC') {
212
- return this.createUTCDate(value);
213
- }
214
- if (timezone === 'system' || timezone === 'default' && !this.hasTimezonePlugin()) {
215
- return this.createSystemDate(value);
216
- }
217
- return this.createTZDate(value, timezone);
218
- };
219
- this.getInvalidDate = () => this.moment(new Date('Invalid Date'));
220
- this.getTimezone = value => {
221
- // @ts-ignore
222
- // eslint-disable-next-line no-underscore-dangle
223
- const zone = value._z?.name;
224
- const defaultZone = value.isUTC() ? 'UTC' : 'system';
225
-
226
- // @ts-ignore
227
- return zone ?? this.moment.defaultZone?.name ?? defaultZone;
228
- };
229
- this.setTimezone = (value, timezone) => {
230
- if (this.getTimezone(value) === timezone) {
231
- return value;
232
- }
233
- if (timezone === 'UTC') {
234
- return value.clone().utc();
235
- }
236
- if (timezone === 'system') {
237
- return value.clone().local();
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 value.isSame(comparing);
310
- };
311
- this.isSameYear = (value, comparing) => {
312
- return value.isSame(comparing, 'year');
313
- };
314
- this.isSameMonth = (value, comparing) => {
315
- return value.isSame(comparing, 'month');
316
- };
317
- this.isSameDay = (value, comparing) => {
318
- return value.isSame(comparing, 'day');
319
- };
320
- this.isSameHour = (value, comparing) => {
321
- return value.isSame(comparing, 'hour');
322
- };
323
- this.isAfter = (value, comparing) => {
324
- return value.isAfter(comparing);
325
- };
326
- this.isAfterYear = (value, comparing) => {
327
- return value.isAfter(comparing, 'year');
328
- };
329
- this.isAfterDay = (value, comparing) => {
330
- return value.isAfter(comparing, 'day');
331
- };
332
- this.isBefore = (value, comparing) => {
333
- return value.isBefore(comparing);
334
- };
335
- this.isBeforeYear = (value, comparing) => {
336
- return value.isBefore(comparing, 'year');
337
- };
338
- this.isBeforeDay = (value, comparing) => {
339
- return value.isBefore(comparing, 'day');
340
- };
341
- this.isWithinRange = (value, [start, end]) => {
342
- return value.isBetween(start, end, null, '[]');
343
- };
344
- this.startOfYear = value => {
345
- return value.clone().startOf('year');
346
- };
347
- this.startOfMonth = value => {
348
- return value.clone().startOf('month');
349
- };
350
- this.startOfWeek = value => {
351
- return this.setLocaleToValue(value.clone()).startOf('week');
352
- };
353
- this.startOfDay = value => {
354
- return value.clone().startOf('day');
355
- };
356
- this.endOfYear = value => {
357
- return value.clone().endOf('year');
358
- };
359
- this.endOfMonth = value => {
360
- return value.clone().endOf('month');
361
- };
362
- this.endOfWeek = value => {
363
- return this.setLocaleToValue(value.clone()).endOf('week');
364
- };
365
- this.endOfDay = value => {
366
- return value.clone().endOf('day');
367
- };
368
- this.addYears = (value, amount) => {
369
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'years') : value.clone().add(amount, 'years');
370
- };
371
- this.addMonths = (value, amount) => {
372
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'months') : value.clone().add(amount, 'months');
373
- };
374
- this.addWeeks = (value, amount) => {
375
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'weeks') : value.clone().add(amount, 'weeks');
376
- };
377
- this.addDays = (value, amount) => {
378
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'days') : value.clone().add(amount, 'days');
379
- };
380
- this.addHours = (value, amount) => {
381
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'hours') : value.clone().add(amount, 'hours');
382
- };
383
- this.addMinutes = (value, amount) => {
384
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'minutes') : value.clone().add(amount, 'minutes');
385
- };
386
- this.addSeconds = (value, amount) => {
387
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'seconds') : value.clone().add(amount, 'seconds');
388
- };
389
- this.getYear = value => {
390
- return value.get('year');
391
- };
392
- this.getMonth = value => {
393
- return value.get('month');
394
- };
395
- this.getDate = value => {
396
- return value.get('date');
397
- };
398
- this.getHours = value => {
399
- return value.get('hours');
400
- };
401
- this.getMinutes = value => {
402
- return value.get('minutes');
403
- };
404
- this.getSeconds = value => {
405
- return value.get('seconds');
406
- };
407
- this.getMilliseconds = value => {
408
- return value.get('milliseconds');
409
- };
410
- this.setYear = (value, year) => {
411
- return value.clone().year(year);
412
- };
413
- this.setMonth = (value, month) => {
414
- return value.clone().month(month);
415
- };
416
- this.setDate = (value, date) => {
417
- return value.clone().date(date);
418
- };
419
- this.setHours = (value, hours) => {
420
- return value.clone().hours(hours);
421
- };
422
- this.setMinutes = (value, minutes) => {
423
- return value.clone().minutes(minutes);
424
- };
425
- this.setSeconds = (value, seconds) => {
426
- return value.clone().seconds(seconds);
427
- };
428
- this.setMilliseconds = (value, milliseconds) => {
429
- return value.clone().milliseconds(milliseconds);
430
- };
431
- this.getDaysInMonth = value => {
432
- return value.daysInMonth();
433
- };
434
- this.getWeekArray = value => {
435
- const start = this.startOfWeek(this.startOfMonth(value));
436
- const end = this.endOfWeek(this.endOfMonth(value));
437
- let count = 0;
438
- let current = start;
439
- let currentDayOfYear = current.get('dayOfYear');
440
- const nestedWeeks = [];
441
- while (current.isBefore(end)) {
442
- const weekNumber = Math.floor(count / 7);
443
- nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
444
- nestedWeeks[weekNumber].push(current);
445
- const prevDayOfYear = currentDayOfYear;
446
- current = this.addDays(current, 1);
447
- currentDayOfYear = current.get('dayOfYear');
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
- // If there is a TZ change at midnight, adding 1 day may only increase the date by 23 hours to 11pm
450
- // To fix, bump the date into the next day (add 12 hours) and then revert to the start of the day
451
- // See https://github.com/moment/moment/issues/4743#issuecomment-811306874 for context.
452
- if (prevDayOfYear === currentDayOfYear) {
453
- current = current.add(12, 'h').startOf('day');
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
- return nestedWeeks;
458
- };
459
- this.getWeekNumber = value => {
460
- return value.week();
461
- };
462
- this.getDayOfWeek = value => {
463
- return value.day() + 1;
464
- };
465
- this.moment = instance || _moment.default;
466
- this.locale = locale;
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);