@mui/x-date-pickers 6.18.6 → 6.19.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.
- package/AdapterDateFns/AdapterDateFns.d.ts +3 -24
- package/AdapterDateFns/AdapterDateFns.js +11 -272
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +65 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
- package/AdapterDateFnsBase/index.d.ts +1 -0
- package/AdapterDateFnsBase/index.js +1 -0
- package/AdapterDateFnsBase/package.json +6 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +88 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
- package/AdapterDateFnsV3/index.d.ts +1 -0
- package/AdapterDateFnsV3/index.js +1 -0
- package/AdapterDateFnsV3/package.json +6 -0
- package/AdapterLuxon/AdapterLuxon.d.ts +32 -32
- package/CHANGELOG.md +85 -1
- package/DateCalendar/DateCalendar.js +6 -4
- package/DateCalendar/DateCalendar.types.d.ts +0 -8
- package/DigitalClock/DigitalClock.js +3 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/TimeClock/TimeClock.js +3 -2
- package/hooks/useClearableField.d.ts +1 -1
- package/hooks/useClearableField.js +3 -3
- package/index.js +1 -1
- package/internals/hooks/useViews.d.ts +4 -4
- package/internals/hooks/useViews.js +13 -13
- package/internals/models/helpers.d.ts +1 -0
- package/internals/models/props/clock.d.ts +0 -9
- package/legacy/AdapterDateFns/AdapterDateFns.js +278 -528
- package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
- package/legacy/AdapterDateFnsBase/index.js +1 -0
- package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +376 -0
- package/legacy/AdapterDateFnsV3/index.js +1 -0
- package/legacy/DateCalendar/DateCalendar.js +6 -4
- package/legacy/DigitalClock/DigitalClock.js +3 -2
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/legacy/TimeClock/TimeClock.js +3 -2
- package/legacy/hooks/useClearableField.js +3 -3
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/useViews.js +13 -13
- package/legacy/locales/index.js +1 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/modern/AdapterDateFns/AdapterDateFns.js +11 -271
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +307 -0
- package/modern/AdapterDateFnsBase/index.js +1 -0
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
- package/modern/AdapterDateFnsV3/index.js +1 -0
- package/modern/DateCalendar/DateCalendar.js +6 -4
- package/modern/DigitalClock/DigitalClock.js +3 -2
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/modern/TimeClock/TimeClock.js +3 -2
- package/modern/hooks/useClearableField.js +3 -3
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useViews.js +13 -13
- package/modern/locales/index.js +1 -0
- package/node/AdapterDateFns/AdapterDateFns.js +11 -271
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +315 -0
- package/node/AdapterDateFnsBase/index.js +12 -0
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +366 -0
- package/node/AdapterDateFnsV3/index.js +12 -0
- package/node/DateCalendar/DateCalendar.js +6 -4
- package/node/DigitalClock/DigitalClock.js +3 -2
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/node/TimeClock/TimeClock.js +3 -2
- package/node/hooks/useClearableField.js +3 -3
- package/node/index.js +1 -1
- package/node/internals/hooks/useViews.js +13 -13
- package/node/locales/index.js +11 -0
- package/package.json +2 -2
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
5
9
|
/* eslint-disable class-methods-use-this */
|
|
6
10
|
import addDays from 'date-fns/addDays';
|
|
7
11
|
import addSeconds from 'date-fns/addSeconds';
|
|
@@ -60,202 +64,7 @@ import isWithinInterval from 'date-fns/isWithinInterval';
|
|
|
60
64
|
import defaultLocale from 'date-fns/locale/en-US';
|
|
61
65
|
// @ts-ignore
|
|
62
66
|
import longFormatters from 'date-fns/_lib/format/longFormatters';
|
|
63
|
-
|
|
64
|
-
// Year
|
|
65
|
-
y: {
|
|
66
|
-
sectionType: 'year',
|
|
67
|
-
contentType: 'digit',
|
|
68
|
-
maxLength: 4
|
|
69
|
-
},
|
|
70
|
-
yy: 'year',
|
|
71
|
-
yyy: {
|
|
72
|
-
sectionType: 'year',
|
|
73
|
-
contentType: 'digit',
|
|
74
|
-
maxLength: 4
|
|
75
|
-
},
|
|
76
|
-
yyyy: 'year',
|
|
77
|
-
// Month
|
|
78
|
-
M: {
|
|
79
|
-
sectionType: 'month',
|
|
80
|
-
contentType: 'digit',
|
|
81
|
-
maxLength: 2
|
|
82
|
-
},
|
|
83
|
-
MM: 'month',
|
|
84
|
-
MMMM: {
|
|
85
|
-
sectionType: 'month',
|
|
86
|
-
contentType: 'letter'
|
|
87
|
-
},
|
|
88
|
-
MMM: {
|
|
89
|
-
sectionType: 'month',
|
|
90
|
-
contentType: 'letter'
|
|
91
|
-
},
|
|
92
|
-
L: {
|
|
93
|
-
sectionType: 'month',
|
|
94
|
-
contentType: 'digit',
|
|
95
|
-
maxLength: 2
|
|
96
|
-
},
|
|
97
|
-
LL: 'month',
|
|
98
|
-
LLL: {
|
|
99
|
-
sectionType: 'month',
|
|
100
|
-
contentType: 'letter'
|
|
101
|
-
},
|
|
102
|
-
LLLL: {
|
|
103
|
-
sectionType: 'month',
|
|
104
|
-
contentType: 'letter'
|
|
105
|
-
},
|
|
106
|
-
// Day of the month
|
|
107
|
-
d: {
|
|
108
|
-
sectionType: 'day',
|
|
109
|
-
contentType: 'digit',
|
|
110
|
-
maxLength: 2
|
|
111
|
-
},
|
|
112
|
-
dd: 'day',
|
|
113
|
-
do: {
|
|
114
|
-
sectionType: 'day',
|
|
115
|
-
contentType: 'digit-with-letter'
|
|
116
|
-
},
|
|
117
|
-
// Day of the week
|
|
118
|
-
E: {
|
|
119
|
-
sectionType: 'weekDay',
|
|
120
|
-
contentType: 'letter'
|
|
121
|
-
},
|
|
122
|
-
EE: {
|
|
123
|
-
sectionType: 'weekDay',
|
|
124
|
-
contentType: 'letter'
|
|
125
|
-
},
|
|
126
|
-
EEE: {
|
|
127
|
-
sectionType: 'weekDay',
|
|
128
|
-
contentType: 'letter'
|
|
129
|
-
},
|
|
130
|
-
EEEE: {
|
|
131
|
-
sectionType: 'weekDay',
|
|
132
|
-
contentType: 'letter'
|
|
133
|
-
},
|
|
134
|
-
EEEEE: {
|
|
135
|
-
sectionType: 'weekDay',
|
|
136
|
-
contentType: 'letter'
|
|
137
|
-
},
|
|
138
|
-
i: {
|
|
139
|
-
sectionType: 'weekDay',
|
|
140
|
-
contentType: 'digit',
|
|
141
|
-
maxLength: 1
|
|
142
|
-
},
|
|
143
|
-
ii: 'weekDay',
|
|
144
|
-
iii: {
|
|
145
|
-
sectionType: 'weekDay',
|
|
146
|
-
contentType: 'letter'
|
|
147
|
-
},
|
|
148
|
-
iiii: {
|
|
149
|
-
sectionType: 'weekDay',
|
|
150
|
-
contentType: 'letter'
|
|
151
|
-
},
|
|
152
|
-
e: {
|
|
153
|
-
sectionType: 'weekDay',
|
|
154
|
-
contentType: 'digit',
|
|
155
|
-
maxLength: 1
|
|
156
|
-
},
|
|
157
|
-
ee: 'weekDay',
|
|
158
|
-
eee: {
|
|
159
|
-
sectionType: 'weekDay',
|
|
160
|
-
contentType: 'letter'
|
|
161
|
-
},
|
|
162
|
-
eeee: {
|
|
163
|
-
sectionType: 'weekDay',
|
|
164
|
-
contentType: 'letter'
|
|
165
|
-
},
|
|
166
|
-
eeeee: {
|
|
167
|
-
sectionType: 'weekDay',
|
|
168
|
-
contentType: 'letter'
|
|
169
|
-
},
|
|
170
|
-
eeeeee: {
|
|
171
|
-
sectionType: 'weekDay',
|
|
172
|
-
contentType: 'letter'
|
|
173
|
-
},
|
|
174
|
-
c: {
|
|
175
|
-
sectionType: 'weekDay',
|
|
176
|
-
contentType: 'digit',
|
|
177
|
-
maxLength: 1
|
|
178
|
-
},
|
|
179
|
-
cc: 'weekDay',
|
|
180
|
-
ccc: {
|
|
181
|
-
sectionType: 'weekDay',
|
|
182
|
-
contentType: 'letter'
|
|
183
|
-
},
|
|
184
|
-
cccc: {
|
|
185
|
-
sectionType: 'weekDay',
|
|
186
|
-
contentType: 'letter'
|
|
187
|
-
},
|
|
188
|
-
ccccc: {
|
|
189
|
-
sectionType: 'weekDay',
|
|
190
|
-
contentType: 'letter'
|
|
191
|
-
},
|
|
192
|
-
cccccc: {
|
|
193
|
-
sectionType: 'weekDay',
|
|
194
|
-
contentType: 'letter'
|
|
195
|
-
},
|
|
196
|
-
// Meridiem
|
|
197
|
-
a: 'meridiem',
|
|
198
|
-
aa: 'meridiem',
|
|
199
|
-
aaa: 'meridiem',
|
|
200
|
-
// Hours
|
|
201
|
-
H: {
|
|
202
|
-
sectionType: 'hours',
|
|
203
|
-
contentType: 'digit',
|
|
204
|
-
maxLength: 2
|
|
205
|
-
},
|
|
206
|
-
HH: 'hours',
|
|
207
|
-
h: {
|
|
208
|
-
sectionType: 'hours',
|
|
209
|
-
contentType: 'digit',
|
|
210
|
-
maxLength: 2
|
|
211
|
-
},
|
|
212
|
-
hh: 'hours',
|
|
213
|
-
// Minutes
|
|
214
|
-
m: {
|
|
215
|
-
sectionType: 'minutes',
|
|
216
|
-
contentType: 'digit',
|
|
217
|
-
maxLength: 2
|
|
218
|
-
},
|
|
219
|
-
mm: 'minutes',
|
|
220
|
-
// Seconds
|
|
221
|
-
s: {
|
|
222
|
-
sectionType: 'seconds',
|
|
223
|
-
contentType: 'digit',
|
|
224
|
-
maxLength: 2
|
|
225
|
-
},
|
|
226
|
-
ss: 'seconds'
|
|
227
|
-
};
|
|
228
|
-
var defaultFormats = {
|
|
229
|
-
year: 'yyyy',
|
|
230
|
-
month: 'LLLL',
|
|
231
|
-
monthShort: 'MMM',
|
|
232
|
-
dayOfMonth: 'd',
|
|
233
|
-
weekday: 'EEEE',
|
|
234
|
-
weekdayShort: 'EEEEEE',
|
|
235
|
-
hours24h: 'HH',
|
|
236
|
-
hours12h: 'hh',
|
|
237
|
-
meridiem: 'aa',
|
|
238
|
-
minutes: 'mm',
|
|
239
|
-
seconds: 'ss',
|
|
240
|
-
fullDate: 'PP',
|
|
241
|
-
fullDateWithWeekday: 'PPPP',
|
|
242
|
-
keyboardDate: 'P',
|
|
243
|
-
shortDate: 'MMM d',
|
|
244
|
-
normalDate: 'd MMMM',
|
|
245
|
-
normalDateWithWeekday: 'EEE, MMM d',
|
|
246
|
-
monthAndYear: 'LLLL yyyy',
|
|
247
|
-
monthAndDate: 'MMMM d',
|
|
248
|
-
fullTime: 'p',
|
|
249
|
-
fullTime12h: 'hh:mm aa',
|
|
250
|
-
fullTime24h: 'HH:mm',
|
|
251
|
-
fullDateTime: 'PP p',
|
|
252
|
-
fullDateTime12h: 'PP hh:mm aa',
|
|
253
|
-
fullDateTime24h: 'PP HH:mm',
|
|
254
|
-
keyboardDateTime: 'P p',
|
|
255
|
-
keyboardDateTime12h: 'P hh:mm aa',
|
|
256
|
-
keyboardDateTime24h: 'P HH:mm'
|
|
257
|
-
};
|
|
258
|
-
|
|
67
|
+
import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
|
|
259
68
|
/**
|
|
260
69
|
* Based on `@date-io/date-fns`
|
|
261
70
|
*
|
|
@@ -281,339 +90,280 @@ var defaultFormats = {
|
|
|
281
90
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
282
91
|
* SOFTWARE.
|
|
283
92
|
*/
|
|
284
|
-
export var AdapterDateFns = /*#__PURE__*/
|
|
285
|
-
|
|
286
|
-
var
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
this.formatTokenMap = formatTokenMap;
|
|
296
|
-
this.escapedCharacters = {
|
|
297
|
-
start: "'",
|
|
298
|
-
end: "'"
|
|
299
|
-
};
|
|
300
|
-
this.date = function (value) {
|
|
301
|
-
if (typeof value === 'undefined') {
|
|
302
|
-
return new Date();
|
|
93
|
+
export var AdapterDateFns = /*#__PURE__*/function (_ref) {
|
|
94
|
+
_inherits(AdapterDateFns, _ref);
|
|
95
|
+
var _super = _createSuper(AdapterDateFns);
|
|
96
|
+
function AdapterDateFns() {
|
|
97
|
+
var _this;
|
|
98
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
99
|
+
locale = _ref2.locale,
|
|
100
|
+
formats = _ref2.formats;
|
|
101
|
+
_classCallCheck(this, AdapterDateFns);
|
|
102
|
+
if (typeof addDays !== 'function') {
|
|
103
|
+
throw new Error(['MUI: The `date-fns` package v3.x is not compatible with this adapter.', 'Please, install v2.x of the package or use the `AdapterDateFnsV3` instead.'].join('\n'));
|
|
303
104
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
};
|
|
309
|
-
this.dateWithTimezone = function (value) {
|
|
310
|
-
return _this.date(value);
|
|
311
|
-
};
|
|
312
|
-
this.getTimezone = function () {
|
|
313
|
-
return 'default';
|
|
314
|
-
};
|
|
315
|
-
this.setTimezone = function (value) {
|
|
316
|
-
return value;
|
|
317
|
-
};
|
|
318
|
-
this.toJsDate = function (value) {
|
|
319
|
-
return value;
|
|
320
|
-
};
|
|
321
|
-
this.parseISO = function (isoString) {
|
|
322
|
-
return parseISO(isoString);
|
|
323
|
-
};
|
|
324
|
-
this.toISO = function (value) {
|
|
325
|
-
return formatISO(value, {
|
|
326
|
-
format: 'extended'
|
|
327
|
-
});
|
|
328
|
-
};
|
|
329
|
-
this.parse = function (value, format) {
|
|
330
|
-
if (value === '') {
|
|
331
|
-
return null;
|
|
332
|
-
}
|
|
333
|
-
return dateFnsParse(value, format, new Date(), {
|
|
334
|
-
locale: _this.locale
|
|
105
|
+
_this = _super.call(this, {
|
|
106
|
+
locale: locale != null ? locale : defaultLocale,
|
|
107
|
+
formats: formats,
|
|
108
|
+
longFormatters: longFormatters
|
|
335
109
|
});
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
// By default, date-fns is using en-US locale with am/pm enabled
|
|
349
|
-
return true;
|
|
350
|
-
};
|
|
351
|
-
this.expandFormat = function (format) {
|
|
352
|
-
var longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
|
353
|
-
|
|
354
|
-
// @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
|
|
355
|
-
return format.match(longFormatRegexp).map(function (token) {
|
|
356
|
-
var firstCharacter = token[0];
|
|
357
|
-
if (firstCharacter === 'p' || firstCharacter === 'P') {
|
|
358
|
-
var longFormatter = longFormatters[firstCharacter];
|
|
359
|
-
var locale = _this.locale || defaultLocale;
|
|
360
|
-
return longFormatter(token, locale.formatLong, {});
|
|
110
|
+
_this.parseISO = function (isoString) {
|
|
111
|
+
return parseISO(isoString);
|
|
112
|
+
};
|
|
113
|
+
_this.toISO = function (value) {
|
|
114
|
+
return formatISO(value, {
|
|
115
|
+
format: 'extended'
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
_this.parse = function (value, format) {
|
|
119
|
+
if (value === '') {
|
|
120
|
+
return null;
|
|
361
121
|
}
|
|
362
|
-
return
|
|
363
|
-
}).join('');
|
|
364
|
-
};
|
|
365
|
-
this.getFormatHelperText = function (format) {
|
|
366
|
-
return _this.expandFormat(format).replace(/(aaa|aa|a)/g, '(a|p)m').toLocaleLowerCase();
|
|
367
|
-
};
|
|
368
|
-
this.isNull = function (value) {
|
|
369
|
-
return value === null;
|
|
370
|
-
};
|
|
371
|
-
this.isValid = function (value) {
|
|
372
|
-
return isValid(_this.date(value));
|
|
373
|
-
};
|
|
374
|
-
this.format = function (value, formatKey) {
|
|
375
|
-
return _this.formatByString(value, _this.formats[formatKey]);
|
|
376
|
-
};
|
|
377
|
-
this.formatByString = function (value, formatString) {
|
|
378
|
-
return dateFnsFormat(value, formatString, {
|
|
379
|
-
locale: _this.locale
|
|
380
|
-
});
|
|
381
|
-
};
|
|
382
|
-
this.formatNumber = function (numberToFormat) {
|
|
383
|
-
return numberToFormat;
|
|
384
|
-
};
|
|
385
|
-
this.getDiff = function (value, comparing, unit) {
|
|
386
|
-
switch (unit) {
|
|
387
|
-
case 'years':
|
|
388
|
-
return differenceInYears(value, _this.date(comparing));
|
|
389
|
-
case 'quarters':
|
|
390
|
-
return differenceInQuarters(value, _this.date(comparing));
|
|
391
|
-
case 'months':
|
|
392
|
-
return differenceInMonths(value, _this.date(comparing));
|
|
393
|
-
case 'weeks':
|
|
394
|
-
return differenceInWeeks(value, _this.date(comparing));
|
|
395
|
-
case 'days':
|
|
396
|
-
return differenceInDays(value, _this.date(comparing));
|
|
397
|
-
case 'hours':
|
|
398
|
-
return differenceInHours(value, _this.date(comparing));
|
|
399
|
-
case 'minutes':
|
|
400
|
-
return differenceInMinutes(value, _this.date(comparing));
|
|
401
|
-
case 'seconds':
|
|
402
|
-
return differenceInSeconds(value, _this.date(comparing));
|
|
403
|
-
default:
|
|
404
|
-
{
|
|
405
|
-
return differenceInMilliseconds(value, _this.date(comparing));
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
this.isEqual = function (value, comparing) {
|
|
410
|
-
if (value === null && comparing === null) {
|
|
411
|
-
return true;
|
|
412
|
-
}
|
|
413
|
-
return isEqual(value, comparing);
|
|
414
|
-
};
|
|
415
|
-
this.isSameYear = function (value, comparing) {
|
|
416
|
-
return isSameYear(value, comparing);
|
|
417
|
-
};
|
|
418
|
-
this.isSameMonth = function (value, comparing) {
|
|
419
|
-
return isSameMonth(value, comparing);
|
|
420
|
-
};
|
|
421
|
-
this.isSameDay = function (value, comparing) {
|
|
422
|
-
return isSameDay(value, comparing);
|
|
423
|
-
};
|
|
424
|
-
this.isSameHour = function (value, comparing) {
|
|
425
|
-
return isSameHour(value, comparing);
|
|
426
|
-
};
|
|
427
|
-
this.isAfter = function (value, comparing) {
|
|
428
|
-
return isAfter(value, comparing);
|
|
429
|
-
};
|
|
430
|
-
this.isAfterYear = function (value, comparing) {
|
|
431
|
-
return isAfter(value, endOfYear(comparing));
|
|
432
|
-
};
|
|
433
|
-
this.isAfterDay = function (value, comparing) {
|
|
434
|
-
return isAfter(value, endOfDay(comparing));
|
|
435
|
-
};
|
|
436
|
-
this.isBefore = function (value, comparing) {
|
|
437
|
-
return isBefore(value, comparing);
|
|
438
|
-
};
|
|
439
|
-
this.isBeforeYear = function (value, comparing) {
|
|
440
|
-
return isBefore(value, startOfYear(comparing));
|
|
441
|
-
};
|
|
442
|
-
this.isBeforeDay = function (value, comparing) {
|
|
443
|
-
return isBefore(value, startOfDay(comparing));
|
|
444
|
-
};
|
|
445
|
-
this.isWithinRange = function (value, _ref2) {
|
|
446
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
447
|
-
start = _ref3[0],
|
|
448
|
-
end = _ref3[1];
|
|
449
|
-
return isWithinInterval(value, {
|
|
450
|
-
start: start,
|
|
451
|
-
end: end
|
|
452
|
-
});
|
|
453
|
-
};
|
|
454
|
-
this.startOfYear = function (value) {
|
|
455
|
-
return startOfYear(value);
|
|
456
|
-
};
|
|
457
|
-
this.startOfMonth = function (value) {
|
|
458
|
-
return startOfMonth(value);
|
|
459
|
-
};
|
|
460
|
-
this.startOfWeek = function (value) {
|
|
461
|
-
return startOfWeek(value, {
|
|
462
|
-
locale: _this.locale
|
|
463
|
-
});
|
|
464
|
-
};
|
|
465
|
-
this.startOfDay = function (value) {
|
|
466
|
-
return startOfDay(value);
|
|
467
|
-
};
|
|
468
|
-
this.endOfYear = function (value) {
|
|
469
|
-
return endOfYear(value);
|
|
470
|
-
};
|
|
471
|
-
this.endOfMonth = function (value) {
|
|
472
|
-
return endOfMonth(value);
|
|
473
|
-
};
|
|
474
|
-
this.endOfWeek = function (value) {
|
|
475
|
-
return endOfWeek(value, {
|
|
476
|
-
locale: _this.locale
|
|
477
|
-
});
|
|
478
|
-
};
|
|
479
|
-
this.endOfDay = function (value) {
|
|
480
|
-
return endOfDay(value);
|
|
481
|
-
};
|
|
482
|
-
this.addYears = function (value, amount) {
|
|
483
|
-
return addYears(value, amount);
|
|
484
|
-
};
|
|
485
|
-
this.addMonths = function (value, amount) {
|
|
486
|
-
return addMonths(value, amount);
|
|
487
|
-
};
|
|
488
|
-
this.addWeeks = function (value, amount) {
|
|
489
|
-
return addWeeks(value, amount);
|
|
490
|
-
};
|
|
491
|
-
this.addDays = function (value, amount) {
|
|
492
|
-
return addDays(value, amount);
|
|
493
|
-
};
|
|
494
|
-
this.addHours = function (value, amount) {
|
|
495
|
-
return addHours(value, amount);
|
|
496
|
-
};
|
|
497
|
-
this.addMinutes = function (value, amount) {
|
|
498
|
-
return addMinutes(value, amount);
|
|
499
|
-
};
|
|
500
|
-
this.addSeconds = function (value, amount) {
|
|
501
|
-
return addSeconds(value, amount);
|
|
502
|
-
};
|
|
503
|
-
this.getYear = function (value) {
|
|
504
|
-
return getYear(value);
|
|
505
|
-
};
|
|
506
|
-
this.getMonth = function (value) {
|
|
507
|
-
return getMonth(value);
|
|
508
|
-
};
|
|
509
|
-
this.getDate = function (value) {
|
|
510
|
-
return getDate(value);
|
|
511
|
-
};
|
|
512
|
-
this.getHours = function (value) {
|
|
513
|
-
return getHours(value);
|
|
514
|
-
};
|
|
515
|
-
this.getMinutes = function (value) {
|
|
516
|
-
return getMinutes(value);
|
|
517
|
-
};
|
|
518
|
-
this.getSeconds = function (value) {
|
|
519
|
-
return getSeconds(value);
|
|
520
|
-
};
|
|
521
|
-
this.getMilliseconds = function (value) {
|
|
522
|
-
return getMilliseconds(value);
|
|
523
|
-
};
|
|
524
|
-
this.setYear = function (value, year) {
|
|
525
|
-
return setYear(value, year);
|
|
526
|
-
};
|
|
527
|
-
this.setMonth = function (value, month) {
|
|
528
|
-
return setMonth(value, month);
|
|
529
|
-
};
|
|
530
|
-
this.setDate = function (value, date) {
|
|
531
|
-
return setDate(value, date);
|
|
532
|
-
};
|
|
533
|
-
this.setHours = function (value, hours) {
|
|
534
|
-
return setHours(value, hours);
|
|
535
|
-
};
|
|
536
|
-
this.setMinutes = function (value, minutes) {
|
|
537
|
-
return setMinutes(value, minutes);
|
|
538
|
-
};
|
|
539
|
-
this.setSeconds = function (value, seconds) {
|
|
540
|
-
return setSeconds(value, seconds);
|
|
541
|
-
};
|
|
542
|
-
this.setMilliseconds = function (value, milliseconds) {
|
|
543
|
-
return setMilliseconds(value, milliseconds);
|
|
544
|
-
};
|
|
545
|
-
this.getDaysInMonth = function (value) {
|
|
546
|
-
return getDaysInMonth(value);
|
|
547
|
-
};
|
|
548
|
-
this.getNextMonth = function (value) {
|
|
549
|
-
return addMonths(value, 1);
|
|
550
|
-
};
|
|
551
|
-
this.getPreviousMonth = function (value) {
|
|
552
|
-
return addMonths(value, -1);
|
|
553
|
-
};
|
|
554
|
-
this.getMonthArray = function (value) {
|
|
555
|
-
var firstMonth = startOfYear(value);
|
|
556
|
-
var monthArray = [firstMonth];
|
|
557
|
-
while (monthArray.length < 12) {
|
|
558
|
-
var prevMonth = monthArray[monthArray.length - 1];
|
|
559
|
-
monthArray.push(_this.getNextMonth(prevMonth));
|
|
560
|
-
}
|
|
561
|
-
return monthArray;
|
|
562
|
-
};
|
|
563
|
-
this.mergeDateAndTime = function (dateParam, timeParam) {
|
|
564
|
-
return _this.setSeconds(_this.setMinutes(_this.setHours(dateParam, _this.getHours(timeParam)), _this.getMinutes(timeParam)), _this.getSeconds(timeParam));
|
|
565
|
-
};
|
|
566
|
-
this.getWeekdays = function () {
|
|
567
|
-
var now = new Date();
|
|
568
|
-
return eachDayOfInterval({
|
|
569
|
-
start: startOfWeek(now, {
|
|
122
|
+
return dateFnsParse(value, format, new Date(), {
|
|
570
123
|
locale: _this.locale
|
|
571
|
-
})
|
|
572
|
-
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
_this.isValid = function (value) {
|
|
127
|
+
return isValid(_this.date(value));
|
|
128
|
+
};
|
|
129
|
+
_this.format = function (value, formatKey) {
|
|
130
|
+
return _this.formatByString(value, _this.formats[formatKey]);
|
|
131
|
+
};
|
|
132
|
+
_this.formatByString = function (value, formatString) {
|
|
133
|
+
return dateFnsFormat(value, formatString, {
|
|
573
134
|
locale: _this.locale
|
|
574
|
-
})
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
_this.getDiff = function (value, comparing, unit) {
|
|
138
|
+
switch (unit) {
|
|
139
|
+
case 'years':
|
|
140
|
+
return differenceInYears(value, _this.date(comparing));
|
|
141
|
+
case 'quarters':
|
|
142
|
+
return differenceInQuarters(value, _this.date(comparing));
|
|
143
|
+
case 'months':
|
|
144
|
+
return differenceInMonths(value, _this.date(comparing));
|
|
145
|
+
case 'weeks':
|
|
146
|
+
return differenceInWeeks(value, _this.date(comparing));
|
|
147
|
+
case 'days':
|
|
148
|
+
return differenceInDays(value, _this.date(comparing));
|
|
149
|
+
case 'hours':
|
|
150
|
+
return differenceInHours(value, _this.date(comparing));
|
|
151
|
+
case 'minutes':
|
|
152
|
+
return differenceInMinutes(value, _this.date(comparing));
|
|
153
|
+
case 'seconds':
|
|
154
|
+
return differenceInSeconds(value, _this.date(comparing));
|
|
155
|
+
default:
|
|
156
|
+
{
|
|
157
|
+
return differenceInMilliseconds(value, _this.date(comparing));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
_this.isEqual = function (value, comparing) {
|
|
162
|
+
if (value === null && comparing === null) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
return isEqual(value, comparing);
|
|
166
|
+
};
|
|
167
|
+
_this.isSameYear = function (value, comparing) {
|
|
168
|
+
return isSameYear(value, comparing);
|
|
169
|
+
};
|
|
170
|
+
_this.isSameMonth = function (value, comparing) {
|
|
171
|
+
return isSameMonth(value, comparing);
|
|
172
|
+
};
|
|
173
|
+
_this.isSameDay = function (value, comparing) {
|
|
174
|
+
return isSameDay(value, comparing);
|
|
175
|
+
};
|
|
176
|
+
_this.isSameHour = function (value, comparing) {
|
|
177
|
+
return isSameHour(value, comparing);
|
|
178
|
+
};
|
|
179
|
+
_this.isAfter = function (value, comparing) {
|
|
180
|
+
return isAfter(value, comparing);
|
|
181
|
+
};
|
|
182
|
+
_this.isAfterYear = function (value, comparing) {
|
|
183
|
+
return isAfter(value, endOfYear(comparing));
|
|
184
|
+
};
|
|
185
|
+
_this.isAfterDay = function (value, comparing) {
|
|
186
|
+
return isAfter(value, endOfDay(comparing));
|
|
187
|
+
};
|
|
188
|
+
_this.isBefore = function (value, comparing) {
|
|
189
|
+
return isBefore(value, comparing);
|
|
190
|
+
};
|
|
191
|
+
_this.isBeforeYear = function (value, comparing) {
|
|
192
|
+
return isBefore(value, startOfYear(comparing));
|
|
193
|
+
};
|
|
194
|
+
_this.isBeforeDay = function (value, comparing) {
|
|
195
|
+
return isBefore(value, startOfDay(comparing));
|
|
196
|
+
};
|
|
197
|
+
_this.isWithinRange = function (value, _ref3) {
|
|
198
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
199
|
+
start = _ref4[0],
|
|
200
|
+
end = _ref4[1];
|
|
201
|
+
return isWithinInterval(value, {
|
|
202
|
+
start: start,
|
|
203
|
+
end: end
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
_this.startOfYear = function (value) {
|
|
207
|
+
return startOfYear(value);
|
|
208
|
+
};
|
|
209
|
+
_this.startOfMonth = function (value) {
|
|
210
|
+
return startOfMonth(value);
|
|
211
|
+
};
|
|
212
|
+
_this.startOfWeek = function (value) {
|
|
213
|
+
return startOfWeek(value, {
|
|
214
|
+
locale: _this.locale
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
_this.startOfDay = function (value) {
|
|
218
|
+
return startOfDay(value);
|
|
219
|
+
};
|
|
220
|
+
_this.endOfYear = function (value) {
|
|
221
|
+
return endOfYear(value);
|
|
222
|
+
};
|
|
223
|
+
_this.endOfMonth = function (value) {
|
|
224
|
+
return endOfMonth(value);
|
|
225
|
+
};
|
|
226
|
+
_this.endOfWeek = function (value) {
|
|
227
|
+
return endOfWeek(value, {
|
|
228
|
+
locale: _this.locale
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
_this.endOfDay = function (value) {
|
|
232
|
+
return endOfDay(value);
|
|
233
|
+
};
|
|
234
|
+
_this.addYears = function (value, amount) {
|
|
235
|
+
return addYears(value, amount);
|
|
236
|
+
};
|
|
237
|
+
_this.addMonths = function (value, amount) {
|
|
238
|
+
return addMonths(value, amount);
|
|
239
|
+
};
|
|
240
|
+
_this.addWeeks = function (value, amount) {
|
|
241
|
+
return addWeeks(value, amount);
|
|
242
|
+
};
|
|
243
|
+
_this.addDays = function (value, amount) {
|
|
244
|
+
return addDays(value, amount);
|
|
245
|
+
};
|
|
246
|
+
_this.addHours = function (value, amount) {
|
|
247
|
+
return addHours(value, amount);
|
|
248
|
+
};
|
|
249
|
+
_this.addMinutes = function (value, amount) {
|
|
250
|
+
return addMinutes(value, amount);
|
|
251
|
+
};
|
|
252
|
+
_this.addSeconds = function (value, amount) {
|
|
253
|
+
return addSeconds(value, amount);
|
|
254
|
+
};
|
|
255
|
+
_this.getYear = function (value) {
|
|
256
|
+
return getYear(value);
|
|
257
|
+
};
|
|
258
|
+
_this.getMonth = function (value) {
|
|
259
|
+
return getMonth(value);
|
|
260
|
+
};
|
|
261
|
+
_this.getDate = function (value) {
|
|
262
|
+
return getDate(value);
|
|
263
|
+
};
|
|
264
|
+
_this.getHours = function (value) {
|
|
265
|
+
return getHours(value);
|
|
266
|
+
};
|
|
267
|
+
_this.getMinutes = function (value) {
|
|
268
|
+
return getMinutes(value);
|
|
269
|
+
};
|
|
270
|
+
_this.getSeconds = function (value) {
|
|
271
|
+
return getSeconds(value);
|
|
272
|
+
};
|
|
273
|
+
_this.getMilliseconds = function (value) {
|
|
274
|
+
return getMilliseconds(value);
|
|
275
|
+
};
|
|
276
|
+
_this.setYear = function (value, year) {
|
|
277
|
+
return setYear(value, year);
|
|
278
|
+
};
|
|
279
|
+
_this.setMonth = function (value, month) {
|
|
280
|
+
return setMonth(value, month);
|
|
281
|
+
};
|
|
282
|
+
_this.setDate = function (value, date) {
|
|
283
|
+
return setDate(value, date);
|
|
284
|
+
};
|
|
285
|
+
_this.setHours = function (value, hours) {
|
|
286
|
+
return setHours(value, hours);
|
|
287
|
+
};
|
|
288
|
+
_this.setMinutes = function (value, minutes) {
|
|
289
|
+
return setMinutes(value, minutes);
|
|
290
|
+
};
|
|
291
|
+
_this.setSeconds = function (value, seconds) {
|
|
292
|
+
return setSeconds(value, seconds);
|
|
293
|
+
};
|
|
294
|
+
_this.setMilliseconds = function (value, milliseconds) {
|
|
295
|
+
return setMilliseconds(value, milliseconds);
|
|
296
|
+
};
|
|
297
|
+
_this.getDaysInMonth = function (value) {
|
|
298
|
+
return getDaysInMonth(value);
|
|
299
|
+
};
|
|
300
|
+
_this.getNextMonth = function (value) {
|
|
301
|
+
return addMonths(value, 1);
|
|
302
|
+
};
|
|
303
|
+
_this.getPreviousMonth = function (value) {
|
|
304
|
+
return addMonths(value, -1);
|
|
305
|
+
};
|
|
306
|
+
_this.getMonthArray = function (value) {
|
|
307
|
+
var firstMonth = startOfYear(value);
|
|
308
|
+
var monthArray = [firstMonth];
|
|
309
|
+
while (monthArray.length < 12) {
|
|
310
|
+
var prevMonth = monthArray[monthArray.length - 1];
|
|
311
|
+
monthArray.push(_this.getNextMonth(prevMonth));
|
|
312
|
+
}
|
|
313
|
+
return monthArray;
|
|
314
|
+
};
|
|
315
|
+
_this.mergeDateAndTime = function (dateParam, timeParam) {
|
|
316
|
+
return _this.setSeconds(_this.setMinutes(_this.setHours(dateParam, _this.getHours(timeParam)), _this.getMinutes(timeParam)), _this.getSeconds(timeParam));
|
|
317
|
+
};
|
|
318
|
+
_this.getWeekdays = function () {
|
|
319
|
+
var now = new Date();
|
|
320
|
+
return eachDayOfInterval({
|
|
321
|
+
start: startOfWeek(now, {
|
|
322
|
+
locale: _this.locale
|
|
323
|
+
}),
|
|
324
|
+
end: endOfWeek(now, {
|
|
325
|
+
locale: _this.locale
|
|
326
|
+
})
|
|
327
|
+
}).map(function (day) {
|
|
328
|
+
return _this.formatByString(day, 'EEEEEE');
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
_this.getWeekArray = function (value) {
|
|
332
|
+
var start = startOfWeek(startOfMonth(value), {
|
|
333
|
+
locale: _this.locale
|
|
334
|
+
});
|
|
335
|
+
var end = endOfWeek(endOfMonth(value), {
|
|
336
|
+
locale: _this.locale
|
|
337
|
+
});
|
|
338
|
+
var count = 0;
|
|
339
|
+
var current = start;
|
|
340
|
+
var nestedWeeks = [];
|
|
341
|
+
while (isBefore(current, end)) {
|
|
342
|
+
var weekNumber = Math.floor(count / 7);
|
|
343
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
344
|
+
nestedWeeks[weekNumber].push(current);
|
|
345
|
+
current = addDays(current, 1);
|
|
346
|
+
count += 1;
|
|
347
|
+
}
|
|
348
|
+
return nestedWeeks;
|
|
349
|
+
};
|
|
350
|
+
_this.getWeekNumber = function (value) {
|
|
351
|
+
return getWeek(value, {
|
|
352
|
+
locale: _this.locale
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
_this.getYearRange = function (start, end) {
|
|
356
|
+
var startDate = startOfYear(start);
|
|
357
|
+
var endDate = endOfYear(end);
|
|
358
|
+
var years = [];
|
|
359
|
+
var current = startDate;
|
|
360
|
+
while (isBefore(current, endDate)) {
|
|
361
|
+
years.push(current);
|
|
362
|
+
current = addYears(current, 1);
|
|
363
|
+
}
|
|
364
|
+
return years;
|
|
365
|
+
};
|
|
366
|
+
return _this;
|
|
367
|
+
}
|
|
368
|
+
return _createClass(AdapterDateFns);
|
|
369
|
+
}(AdapterDateFnsBase);
|