@progress/kendo-dateinputs-common 0.1.0 → 0.2.0-dev.202301061353

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 (55) hide show
  1. package/README.md +34 -3
  2. package/dist/cdn/js/kendo-dateinputs-common.js +1 -0
  3. package/dist/cdn/main.js +1 -1
  4. package/dist/es/common/constants.js +6 -0
  5. package/dist/es/common/dateobject.js +1159 -0
  6. package/dist/es/common/key.js +16 -0
  7. package/dist/es/common/keycode.js +16 -0
  8. package/dist/es/common/mask.js +8 -0
  9. package/dist/es/common/observable.js +32 -0
  10. package/dist/es/common/utils.js +128 -0
  11. package/dist/es/dateinput/dateinput.js +1011 -0
  12. package/dist/es/dateinput/interaction-mode.js +6 -0
  13. package/dist/es/dateinput/utils.js +93 -0
  14. package/dist/es/main.js +1 -1
  15. package/dist/es2015/common/constants.js +6 -0
  16. package/dist/es2015/common/dateobject.js +1137 -0
  17. package/dist/es2015/common/key.js +16 -0
  18. package/dist/es2015/common/keycode.js +16 -0
  19. package/dist/es2015/common/mask.js +6 -0
  20. package/dist/es2015/common/observable.js +29 -0
  21. package/dist/es2015/common/utils.js +117 -0
  22. package/dist/es2015/dateinput/dateinput.js +969 -0
  23. package/dist/es2015/dateinput/interaction-mode.js +6 -0
  24. package/dist/es2015/dateinput/utils.js +92 -0
  25. package/dist/es2015/main.js +1 -1
  26. package/dist/npm/common/constants.d.ts +6 -0
  27. package/dist/npm/common/constants.js +8 -0
  28. package/dist/npm/common/dateobject.d.ts +172 -0
  29. package/dist/npm/common/dateobject.js +1161 -0
  30. package/dist/npm/common/key.d.ts +16 -0
  31. package/dist/npm/common/key.js +18 -0
  32. package/dist/npm/common/keycode.d.ts +16 -0
  33. package/dist/npm/common/keycode.js +18 -0
  34. package/dist/npm/common/mask.d.ts +4 -0
  35. package/dist/npm/common/mask.js +10 -0
  36. package/dist/npm/common/observable.d.ts +9 -0
  37. package/dist/npm/common/observable.js +34 -0
  38. package/dist/npm/common/utils.d.ts +60 -0
  39. package/dist/npm/common/utils.js +130 -0
  40. package/dist/npm/dateinput/dateinput.d.ts +204 -0
  41. package/dist/npm/dateinput/dateinput.js +1013 -0
  42. package/dist/npm/dateinput/interaction-mode.d.ts +5 -0
  43. package/dist/npm/dateinput/interaction-mode.js +8 -0
  44. package/dist/npm/dateinput/utils.d.ts +27 -0
  45. package/dist/npm/dateinput/utils.js +95 -0
  46. package/dist/npm/main.d.ts +1 -1
  47. package/dist/npm/main.js +2 -2
  48. package/dist/systemjs/kendo-dateinputs-common.js +1 -0
  49. package/package.json +10 -8
  50. package/dist/cdn/js/kendo-typescript-package-base.js +0 -1
  51. package/dist/es/my-class.js +0 -15
  52. package/dist/es2015/my-class.js +0 -11
  53. package/dist/npm/my-class.d.ts +0 -9
  54. package/dist/npm/my-class.js +0 -17
  55. package/dist/systemjs/kendo-typescript-package-base.js +0 -1
@@ -0,0 +1,1161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var kendo_date_math_1 = require("@progress/kendo-date-math");
4
+ var mask_1 = require("./mask");
5
+ var utils_1 = require("../dateinput/utils");
6
+ var utils_2 = require("./utils");
7
+ var constants_1 = require("./constants");
8
+ var PREVIOUS_CENTURY_BASE = 1900;
9
+ var CURRENT_CENTURY_BASE = 2000;
10
+ var SHORT_PATTERN_LENGTH_REGEXP = /d|M|H|h|m|s/;
11
+ var MONTH_PART_WITH_WORDS_THRESHOLD = 2;
12
+ var MONTH_SYMBOL = "M";
13
+ // JS months start from 0 (January) instead of 1 (January)
14
+ var JS_MONTH_OFFSET = 1;
15
+ var DateObject = /** @class */ (function () {
16
+ function DateObject(_a) {
17
+ var intlService = _a.intlService, formatPlaceholder = _a.formatPlaceholder, format = _a.format, _b = _a.cycleTime, cycleTime = _b === void 0 ? false : _b, _c = _a.twoDigitYearMax, twoDigitYearMax = _c === void 0 ? constants_1.Constants.twoDigitYearMax : _c, _d = _a.value, value = _d === void 0 ? null : _d, _e = _a.autoCorrectParts, autoCorrectParts = _e === void 0 ? true : _e;
18
+ this.year = true;
19
+ this.month = true;
20
+ this.date = true;
21
+ this.hours = true;
22
+ this.minutes = true;
23
+ this.seconds = true;
24
+ this.milliseconds = true;
25
+ this.leadingZero = null;
26
+ this.typedMonthPart = '';
27
+ this.knownParts = 'adHhmMsEyS';
28
+ this.symbols = {
29
+ 'E': 'E',
30
+ 'H': 'H',
31
+ 'M': 'M',
32
+ 'a': 'a',
33
+ 'd': 'd',
34
+ 'h': 'h',
35
+ 'm': 'm',
36
+ 's': 's',
37
+ 'y': 'y',
38
+ 'S': 'S'
39
+ };
40
+ this._value = kendo_date_math_1.getDate(new Date());
41
+ this.cycleTime = false;
42
+ this._partiallyInvalidDate = {
43
+ startDate: null,
44
+ invalidDateParts: {
45
+ 'E': { value: null, date: null, startDateOffset: 0 },
46
+ 'H': { value: null, date: null, startDateOffset: 0 },
47
+ 'M': { value: null, date: null, startDateOffset: 0 },
48
+ 'a': { value: null, date: null, startDateOffset: 0 },
49
+ 'd': { value: null, date: null, startDateOffset: 0 },
50
+ 'h': { value: null, date: null, startDateOffset: 0 },
51
+ 'm': { value: null, date: null, startDateOffset: 0 },
52
+ 's': { value: null, date: null, startDateOffset: 0 },
53
+ 'y': { value: null, date: null, startDateOffset: 0 },
54
+ 'S': { value: null, date: null, startDateOffset: 0 }
55
+ }
56
+ };
57
+ this.intl = intlService;
58
+ this.formatPlaceholder = formatPlaceholder || 'wide';
59
+ this.format = format;
60
+ this.cycleTime = cycleTime;
61
+ this.monthNames = this.allFormattedMonths(this.localeId);
62
+ this.dayPeriods = this.allDayPeriods(this.localeId);
63
+ this.twoDigitYearMax = twoDigitYearMax;
64
+ this.autoCorrectParts = autoCorrectParts;
65
+ if (!value) {
66
+ this._value = kendo_date_math_1.getDate(new Date());
67
+ var sampleFormat = this.dateFormatString(this.value, this.format).symbols;
68
+ for (var i = 0; i < sampleFormat.length; i++) {
69
+ this.setExisting(sampleFormat[i], false);
70
+ }
71
+ }
72
+ else {
73
+ this._value = kendo_date_math_1.cloneDate(value);
74
+ }
75
+ }
76
+ Object.defineProperty(DateObject.prototype, "value", {
77
+ get: function () {
78
+ return this._value;
79
+ },
80
+ set: function (value) {
81
+ if (value && !(value instanceof Date)) {
82
+ // throw new Error("The 'value' should be a valid JavaScript Date instance.");
83
+ return;
84
+ }
85
+ this._value = value;
86
+ this.resetInvalidDate();
87
+ },
88
+ enumerable: true,
89
+ configurable: true
90
+ });
91
+ Object.defineProperty(DateObject.prototype, "localeId", {
92
+ get: function () {
93
+ var localeId = constants_1.Constants.defaultLocaleId;
94
+ var cldrKeys = Object.keys(this.intl.cldr);
95
+ for (var i = 0; i < cldrKeys.length; i++) {
96
+ var key = cldrKeys[i];
97
+ var value = this.intl.cldr[key];
98
+ if (value.name && value.calendar && value.numbers &&
99
+ value.name !== constants_1.Constants.defaultLocaleId) {
100
+ localeId = value.name;
101
+ break;
102
+ }
103
+ }
104
+ return localeId;
105
+ },
106
+ enumerable: true,
107
+ configurable: true
108
+ });
109
+ DateObject.prototype.setValue = function (value) {
110
+ if (!value) {
111
+ this._value = kendo_date_math_1.getDate(new Date());
112
+ this.modifyExisting(false);
113
+ }
114
+ else if (!kendo_date_math_1.isEqual(value, this._value)) {
115
+ this._value = kendo_date_math_1.cloneDate(value);
116
+ this.modifyExisting(true);
117
+ }
118
+ this.resetInvalidDate();
119
+ };
120
+ /**
121
+ * @hidden
122
+ */
123
+ DateObject.prototype.hasValue = function () {
124
+ var _this = this;
125
+ var pred = function (a, p) { return a || p.type !== 'literal' && p.type !== 'dayperiod' && _this.getExisting(p.pattern[0]); };
126
+ return this.intl.splitDateFormat(this.format, this.localeId).reduce(pred, false);
127
+ };
128
+ /**
129
+ * @hidden
130
+ */
131
+ DateObject.prototype.getValue = function () {
132
+ for (var i = 0; i < this.knownParts.length; i++) {
133
+ if (!this.getExisting(this.knownParts[i])) {
134
+ return null;
135
+ }
136
+ }
137
+ return kendo_date_math_1.cloneDate(this.value);
138
+ };
139
+ /**
140
+ * @hidden
141
+ */
142
+ DateObject.prototype.getFormattedDate = function (format) {
143
+ return this.intl.formatDate(this.getValue(), format, this.localeId);
144
+ };
145
+ /**
146
+ * @hidden
147
+ */
148
+ DateObject.prototype.getTextAndFormat = function (customFormat) {
149
+ if (customFormat === void 0) { customFormat = ""; }
150
+ var format = customFormat || this.format;
151
+ var text = this.intl.formatDate(this.value, format, this.localeId);
152
+ var mask = this.dateFormatString(this.value, format);
153
+ if (!this.autoCorrectParts && this._partiallyInvalidDate.startDate) {
154
+ var partiallyInvalidText = "";
155
+ var formattedDate = this.intl.formatDate(this.value, format, this.localeId);
156
+ var formattedDates = this.getFormattedInvalidDates(format);
157
+ for (var i = 0; i < formattedDate.length; i++) {
158
+ var symbol = mask.symbols[i];
159
+ if (mask.partMap[i].type === "literal") {
160
+ partiallyInvalidText += text[i];
161
+ }
162
+ else if (this.getInvalidDatePartValue(symbol)) {
163
+ if (symbol === "M") {
164
+ if (mask.partMap[i].pattern.length > MONTH_PART_WITH_WORDS_THRESHOLD) {
165
+ partiallyInvalidText += formattedDates[symbol][i];
166
+ }
167
+ else {
168
+ if (this.getInvalidDatePartValue(symbol)) {
169
+ var month = utils_2.parseToInt(this.getInvalidDatePartValue(symbol) + JS_MONTH_OFFSET).toString();
170
+ var formattedMonth = utils_1.padZero(Math.abs(mask.partMap[i].pattern.length - month.length)) + month;
171
+ partiallyInvalidText += formattedMonth;
172
+ i += Math.max(0, formattedMonth.length - 1);
173
+ }
174
+ else {
175
+ partiallyInvalidText += formattedDates[symbol][i];
176
+ }
177
+ }
178
+ }
179
+ else {
180
+ if (this.getInvalidDatePartValue(symbol)) {
181
+ partiallyInvalidText += this.getInvalidDatePartValue(symbol);
182
+ i += Math.max(0, this.getInvalidDatePartValue(symbol).toString().length - 1);
183
+ }
184
+ else {
185
+ partiallyInvalidText += formattedDates[symbol][i];
186
+ }
187
+ }
188
+ }
189
+ else {
190
+ partiallyInvalidText += text[i];
191
+ }
192
+ }
193
+ text = partiallyInvalidText;
194
+ }
195
+ var result = this.merge(text, mask);
196
+ return result;
197
+ };
198
+ /**
199
+ * @hidden
200
+ */
201
+ DateObject.prototype.getFormattedInvalidDates = function (customFormat) {
202
+ var _this = this;
203
+ if (customFormat === void 0) { customFormat = ""; }
204
+ var format = customFormat || this.format;
205
+ var formattedDatesForSymbol = {
206
+ 'E': '',
207
+ 'H': '',
208
+ 'M': '',
209
+ 'a': '',
210
+ 'd': '',
211
+ 'h': '',
212
+ 'm': '',
213
+ 's': '',
214
+ 'y': '',
215
+ 'S': ''
216
+ };
217
+ Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach(function (key) {
218
+ var date = _this.getInvalidDatePart(key).date;
219
+ if (date) {
220
+ var formattedInvalidDate = _this.intl.formatDate(date, format, _this.localeId);
221
+ formattedDatesForSymbol[key] = formattedInvalidDate;
222
+ }
223
+ });
224
+ return formattedDatesForSymbol;
225
+ };
226
+ DateObject.prototype.modifyExisting = function (value) {
227
+ var sampleFormat = this.dateFormatString(this.value, this.format).symbols;
228
+ for (var i = 0; i < sampleFormat.length; i++) {
229
+ this.setExisting(sampleFormat[i], value);
230
+ }
231
+ };
232
+ /**
233
+ * @hidden
234
+ */
235
+ DateObject.prototype.getExisting = function (symbol) {
236
+ switch (symbol) {
237
+ case 'y': return this.year;
238
+ case 'M':
239
+ case 'L': return this.month;
240
+ case 'd': return this.date;
241
+ case 'E': return this.date && this.month && this.year;
242
+ case 'h':
243
+ case 'H': return this.hours;
244
+ case 'm': return this.minutes;
245
+ case 's': return this.seconds;
246
+ case "S": return this.milliseconds;
247
+ default:
248
+ return true;
249
+ }
250
+ };
251
+ DateObject.prototype.setExisting = function (symbol, value) {
252
+ switch (symbol) {
253
+ case 'y':
254
+ // allow 2/29 dates
255
+ this.year = value;
256
+ if (value === false) {
257
+ this._value.setFullYear(2000);
258
+ }
259
+ break;
260
+ case 'M':
261
+ // make sure you can type 31 in the day part
262
+ this.month = value;
263
+ if (value === false) {
264
+ if (this.autoCorrectParts) {
265
+ this._value.setMonth(0);
266
+ }
267
+ }
268
+ break;
269
+ case 'd':
270
+ this.date = value;
271
+ break;
272
+ case 'h':
273
+ case 'H':
274
+ this.hours = value;
275
+ break;
276
+ case 'm':
277
+ this.minutes = value;
278
+ break;
279
+ case 's':
280
+ this.seconds = value;
281
+ break;
282
+ case "S":
283
+ this.milliseconds = value;
284
+ break;
285
+ default:
286
+ break;
287
+ }
288
+ if (this.getValue()) {
289
+ this.resetInvalidDate();
290
+ }
291
+ };
292
+ DateObject.prototype.modifyPart = function (symbol, offset) {
293
+ var newValue = kendo_date_math_1.cloneDate(this.value);
294
+ var originalValue = kendo_date_math_1.cloneDate(this.value);
295
+ var timeModified = false;
296
+ var invalidDateFound;
297
+ var currentInvalidDatePartValue = 0;
298
+ if (!this.autoCorrectParts) {
299
+ var isMonth = symbol === "M";
300
+ var isDay = symbol === "d" || symbol === "E";
301
+ var invalidDateParts = this._partiallyInvalidDate.invalidDateParts || {};
302
+ var invalidDatePart = invalidDateParts[symbol];
303
+ var year = invalidDateParts.y.value || newValue.getFullYear();
304
+ var month = invalidDateParts.M.value || newValue.getMonth();
305
+ var day = invalidDateParts.d.value || invalidDateParts.E.value || newValue.getDate();
306
+ var hour = invalidDateParts.h.value || invalidDateParts.H.value || newValue.getHours();
307
+ var minutes = invalidDateParts.m.value || newValue.getMinutes();
308
+ var seconds = invalidDateParts.s.value || newValue.getSeconds();
309
+ var milliseconds = invalidDateParts.S.value || newValue.getMilliseconds();
310
+ switch (symbol) {
311
+ case 'y':
312
+ year += offset;
313
+ break;
314
+ case 'M':
315
+ month += offset;
316
+ break;
317
+ case 'd':
318
+ case 'E':
319
+ day += offset;
320
+ break;
321
+ case 'h':
322
+ case 'H':
323
+ hour += offset;
324
+ break;
325
+ case 'm':
326
+ minutes += offset;
327
+ break;
328
+ case 's':
329
+ seconds += offset;
330
+ break;
331
+ case 'S':
332
+ milliseconds += offset;
333
+ break;
334
+ // case 'a': newValue.setHours(newValue.getHours() + (12 * offset)); timeModified = true; break;
335
+ default: break;
336
+ }
337
+ if (symbol === "M") {
338
+ if ((month < 0 || month > 11) && this.getExisting(symbol)) {
339
+ // do not cycle months
340
+ this.setExisting(symbol, false);
341
+ return;
342
+ }
343
+ // const mask = this.dateFormatString(this.value, this.format);
344
+ // const monthPart = mask.partMap.filter(x => x.type === "month");
345
+ // if (monthPart && monthPart[0] && monthPart[0].pattern.length > MONTH_PART_WITH_WORDS_THRESHOLD) {
346
+ month = (12 + month) % 12;
347
+ // }
348
+ }
349
+ var dateCandidate = kendo_date_math_1.createDate(year, month, day, hour, minutes, seconds, milliseconds);
350
+ var newValueCandidate = isMonth || isDay ?
351
+ this.modifyDateSymbolWithValue(newValue, symbol, isMonth ? month : day) :
352
+ null;
353
+ var dateCandidateExists = utils_2.areDatePartsEqualTo(dateCandidate, year, month, day, hour, minutes, seconds, milliseconds);
354
+ if (this.getValue() && utils_2.areDatePartsEqualTo(dateCandidate, year, month, day, hour, minutes, seconds, milliseconds)) {
355
+ newValue = kendo_date_math_1.cloneDate(dateCandidate);
356
+ this.markDatePartsAsExisting();
357
+ }
358
+ else if (isMonth && newValueCandidate) {
359
+ if (newValueCandidate.getMonth() === month) {
360
+ if (this.getExisting("d")) {
361
+ if (dateCandidateExists) {
362
+ newValue = kendo_date_math_1.cloneDate(dateCandidate);
363
+ this.resetInvalidDateSymbol(symbol);
364
+ }
365
+ else {
366
+ invalidDateFound = true;
367
+ this.setInvalidDatePart(symbol, {
368
+ value: month,
369
+ date: kendo_date_math_1.cloneDate(newValueCandidate),
370
+ startDateOffset: offset,
371
+ startDate: kendo_date_math_1.cloneDate(this.value)
372
+ });
373
+ this.setExisting(symbol, false);
374
+ }
375
+ }
376
+ else if (dateCandidateExists) {
377
+ this.resetInvalidDateSymbol(symbol);
378
+ newValue = kendo_date_math_1.cloneDate(dateCandidate);
379
+ if (this.getExisting("M") && this.getExisting("y")) {
380
+ // changing from 28/Feb to 29/Feb to 29/March
381
+ this.setExisting("d", true);
382
+ this.resetInvalidDateSymbol("d");
383
+ }
384
+ }
385
+ else {
386
+ this.resetInvalidDateSymbol(symbol);
387
+ newValue = kendo_date_math_1.cloneDate(newValueCandidate);
388
+ }
389
+ }
390
+ else {
391
+ invalidDateFound = true;
392
+ this.setInvalidDatePart(symbol, {
393
+ value: month,
394
+ date: kendo_date_math_1.cloneDate(newValueCandidate),
395
+ startDateOffset: offset,
396
+ startDate: kendo_date_math_1.cloneDate(this.value)
397
+ });
398
+ this.setExisting(symbol, false);
399
+ }
400
+ }
401
+ else if (isDay && newValueCandidate) {
402
+ if (newValueCandidate.getDate() === day) {
403
+ if (this.getExisting("M")) {
404
+ if (dateCandidateExists) {
405
+ newValue = kendo_date_math_1.cloneDate(dateCandidate);
406
+ this.resetInvalidDateSymbol(symbol);
407
+ }
408
+ else {
409
+ invalidDateFound = true;
410
+ this.setInvalidDatePart(symbol, {
411
+ value: day,
412
+ date: kendo_date_math_1.cloneDate(newValueCandidate),
413
+ startDateOffset: offset,
414
+ startDate: kendo_date_math_1.cloneDate(this.value)
415
+ });
416
+ this.setExisting(symbol, false);
417
+ }
418
+ }
419
+ else if (dateCandidateExists) {
420
+ newValue = kendo_date_math_1.cloneDate(dateCandidate);
421
+ this.resetInvalidDateSymbol(symbol);
422
+ if (this.getExisting("d") && this.getExisting("y")) {
423
+ // changing from 31/Jan to 31/Feb to 28/Feb
424
+ this.setExisting("M", true);
425
+ this.resetInvalidDateSymbol("M");
426
+ }
427
+ }
428
+ else {
429
+ this.resetInvalidDateSymbol(symbol);
430
+ newValue = kendo_date_math_1.cloneDate(newValueCandidate);
431
+ }
432
+ }
433
+ else {
434
+ invalidDateFound = true;
435
+ this.setInvalidDatePart(symbol, {
436
+ value: day,
437
+ date: kendo_date_math_1.cloneDate(this.value),
438
+ startDateOffset: offset,
439
+ startDate: kendo_date_math_1.cloneDate(this.value)
440
+ });
441
+ this.setExisting(symbol, false);
442
+ }
443
+ }
444
+ else {
445
+ // this.modifyDateSymbol()
446
+ switch (symbol) {
447
+ case 'y':
448
+ newValue.setFullYear(newValue.getFullYear() + offset);
449
+ break;
450
+ case 'M':
451
+ newValue = kendo_date_math_1.addMonths(this.value, offset);
452
+ break;
453
+ case 'd':
454
+ case 'E':
455
+ newValue.setDate(newValue.getDate() + offset);
456
+ break;
457
+ case 'h':
458
+ case 'H':
459
+ newValue.setHours(newValue.getHours() + offset);
460
+ timeModified = true;
461
+ break;
462
+ case 'm':
463
+ newValue.setMinutes(newValue.getMinutes() + offset);
464
+ timeModified = true;
465
+ break;
466
+ case 's':
467
+ newValue.setSeconds(newValue.getSeconds() + offset);
468
+ timeModified = true;
469
+ break;
470
+ case "S":
471
+ newValue.setMilliseconds(newValue.getMilliseconds() + offset);
472
+ break;
473
+ case 'a':
474
+ newValue.setHours(newValue.getHours() + (12 * offset));
475
+ timeModified = true;
476
+ break;
477
+ default: break;
478
+ }
479
+ invalidDateFound = true;
480
+ if (invalidDatePart && invalidDatePart.value) {
481
+ currentInvalidDatePartValue = utils_2.parseToInt(invalidDatePart.value);
482
+ }
483
+ else {
484
+ if (!utils_2.isPresent(invalidDatePart.value)) {
485
+ newValue = kendo_date_math_1.cloneDate(originalValue);
486
+ // this.modifyDateSymbol()
487
+ switch (symbol) {
488
+ case 'y':
489
+ currentInvalidDatePartValue = originalValue.getFullYear();
490
+ break;
491
+ case 'M':
492
+ currentInvalidDatePartValue = originalValue.getMonth();
493
+ break;
494
+ case 'd':
495
+ case 'E':
496
+ currentInvalidDatePartValue = originalValue.getDate();
497
+ break;
498
+ case 'h':
499
+ case 'H':
500
+ currentInvalidDatePartValue = originalValue.getHours();
501
+ break;
502
+ case 'm':
503
+ currentInvalidDatePartValue = originalValue.getMinutes();
504
+ break;
505
+ case 's':
506
+ currentInvalidDatePartValue = originalValue.getSeconds();
507
+ break;
508
+ case 'S':
509
+ currentInvalidDatePartValue = originalValue.getMilliseconds();
510
+ break;
511
+ // case 'a': newValue.setHours(newValue.getHours() + (12 * offset)); timeModified = true; break;
512
+ default: break;
513
+ }
514
+ }
515
+ else {
516
+ }
517
+ }
518
+ var invalidDatePartValue = Math.max(0, currentInvalidDatePartValue + offset);
519
+ if (symbol !== "y") {
520
+ invalidDatePartValue = utils_2.clamp(currentInvalidDatePartValue + offset, 0, 99);
521
+ }
522
+ this.setInvalidDatePart(symbol, {
523
+ value: invalidDatePartValue,
524
+ date: kendo_date_math_1.cloneDate(newValue),
525
+ startDateOffset: (this.getInvalidDatePart(symbol).startDateOffset || 0) + offset,
526
+ startDate: kendo_date_math_1.cloneDate(this.value)
527
+ });
528
+ this.setExisting(symbol, false);
529
+ }
530
+ }
531
+ else {
532
+ switch (symbol) {
533
+ case 'y':
534
+ newValue.setFullYear(newValue.getFullYear() + offset);
535
+ break;
536
+ case 'M':
537
+ newValue = kendo_date_math_1.addMonths(this.value, offset);
538
+ break;
539
+ case 'd':
540
+ case 'E':
541
+ newValue.setDate(newValue.getDate() + offset);
542
+ break;
543
+ case 'h':
544
+ case 'H':
545
+ newValue.setHours(newValue.getHours() + offset);
546
+ timeModified = true;
547
+ break;
548
+ case 'm':
549
+ newValue.setMinutes(newValue.getMinutes() + offset);
550
+ timeModified = true;
551
+ break;
552
+ case 's':
553
+ newValue.setSeconds(newValue.getSeconds() + offset);
554
+ timeModified = true;
555
+ break;
556
+ case "S":
557
+ newValue.setMilliseconds(newValue.getMilliseconds() + offset);
558
+ break;
559
+ case 'a':
560
+ newValue.setHours(newValue.getHours() + (12 * offset));
561
+ timeModified = true;
562
+ break;
563
+ default: break;
564
+ }
565
+ }
566
+ if (this.shouldNormalizeCentury()) {
567
+ newValue = this.normalizeCentury(newValue);
568
+ }
569
+ if (timeModified && !this.cycleTime && newValue.getDate() !== this._value.getDate()) {
570
+ // todo: blazor has this fix, but this fails a unit test
571
+ // newValue.setDate(this._value.getDate());
572
+ // newValue.setMonth(this._value.getMonth());
573
+ // newValue.setFullYear(this._value.getFullYear());
574
+ }
575
+ if (!invalidDateFound) {
576
+ this.setExisting(symbol, true);
577
+ this._value = newValue;
578
+ if (this.getValue()) {
579
+ this.resetInvalidDate();
580
+ }
581
+ }
582
+ };
583
+ /**
584
+ * @hidden
585
+ */
586
+ DateObject.prototype.parsePart = function (_a) {
587
+ var _b;
588
+ var symbol = _a.symbol, currentChar = _a.currentChar, resetSegmentValue = _a.resetSegmentValue, cycleSegmentValue = _a.cycleSegmentValue, rawTextValue = _a.rawTextValue, isDeleting = _a.isDeleting;
589
+ var isInCaretMode = !cycleSegmentValue;
590
+ var dateParts = this.dateFormatString(this.value, this.format);
591
+ var datePartsLiterals = dateParts.partMap
592
+ .filter(function (x) { return x.type === "literal"; })
593
+ .map(function (x, index) {
594
+ return {
595
+ datePartIndex: index,
596
+ literal: x.pattern
597
+ };
598
+ });
599
+ var shouldResetPart = isInCaretMode && symbol === "M" && dateParts.partMap
600
+ .filter(function (x) { return x.type === "month"; })
601
+ .some(function (x) { return x.pattern.length > MONTH_PART_WITH_WORDS_THRESHOLD; });
602
+ var parseResult = {
603
+ value: null,
604
+ switchPart: false,
605
+ resetPart: shouldResetPart
606
+ };
607
+ if (!currentChar) {
608
+ if (isInCaretMode) {
609
+ for (var i = 0; i < datePartsLiterals.length; i++) {
610
+ var literal = datePartsLiterals[i].literal;
611
+ var rawValueStartsWithLiteral = rawTextValue.startsWith(literal);
612
+ var rawValueEndsWithLiteral = rawTextValue.endsWith(literal);
613
+ var rawValueHasConsecutiveLiterals = rawTextValue.indexOf(literal + literal) >= 0;
614
+ if (rawValueStartsWithLiteral || rawValueEndsWithLiteral || rawValueHasConsecutiveLiterals) {
615
+ this.resetLeadingZero();
616
+ this.setExisting(symbol, false);
617
+ this.resetInvalidDateSymbol(symbol);
618
+ return utils_2.extend(parseResult, { value: null, switchToNext: false });
619
+ }
620
+ }
621
+ }
622
+ else {
623
+ this.resetLeadingZero();
624
+ this.setExisting(symbol, false);
625
+ this.resetInvalidDateSymbol(symbol);
626
+ // return extend(parseResult, { value: null, switchToNext: false });
627
+ return { value: null, switchToNext: false };
628
+ }
629
+ }
630
+ var baseDate = this.intl.formatDate(this.value, this.format, this.localeId);
631
+ var baseFormat = dateParts.symbols;
632
+ var replaced = false;
633
+ var prefix = '';
634
+ var current = '';
635
+ var datePartText = '';
636
+ var suffix = '';
637
+ if (isInCaretMode) {
638
+ var datePartIndex = 0;
639
+ var outOfDatePartBounds = false;
640
+ for (var i = 0; i < baseDate.length; i++) {
641
+ var datePartLiteral = datePartsLiterals[datePartIndex];
642
+ if (datePartLiteral && datePartLiteral === baseDate[i]) {
643
+ datePartIndex++;
644
+ }
645
+ if (baseFormat[i] === symbol) {
646
+ var existing = this.getExisting(symbol);
647
+ current += existing ? baseDate[i] : '0';
648
+ var rawInputChar = rawTextValue[i];
649
+ if (rawInputChar !== baseDate[i] && rawInputChar === datePartsLiterals[datePartIndex].literal) {
650
+ outOfDatePartBounds = true;
651
+ }
652
+ else if (!outOfDatePartBounds) {
653
+ if (rawInputChar === undefined) {
654
+ var formatOffset = Math.abs(this.format.length - baseFormat.length);
655
+ datePartText += rawTextValue[i - formatOffset] || '';
656
+ }
657
+ else {
658
+ datePartText += rawInputChar || '';
659
+ }
660
+ }
661
+ replaced = true;
662
+ }
663
+ else if (!replaced) {
664
+ prefix += baseDate[i];
665
+ }
666
+ else {
667
+ suffix += baseDate[i];
668
+ }
669
+ }
670
+ }
671
+ else {
672
+ for (var i = 0; i < baseDate.length; i++) {
673
+ if (baseFormat[i] === symbol) {
674
+ var existing = this.getExisting(symbol);
675
+ current += existing ? baseDate[i] : '0';
676
+ replaced = true;
677
+ }
678
+ else if (!replaced) {
679
+ prefix += baseDate[i];
680
+ }
681
+ else {
682
+ suffix += baseDate[i];
683
+ }
684
+ }
685
+ }
686
+ var parsedDate = null;
687
+ var month = this.matchMonth(currentChar);
688
+ var dayPeriod = this.matchDayPeriod(currentChar, symbol);
689
+ var isZeroCurrentChar = currentChar === '0';
690
+ var leadingZero = this.leadingZero || {};
691
+ if (isZeroCurrentChar && !isInCaretMode) {
692
+ var valueNumber = parseInt(resetSegmentValue ? currentChar : current + currentChar, 10);
693
+ if (valueNumber === 0 && !this.isAbbrMonth(dateParts.partMap, symbol)) {
694
+ this.incrementLeadingZero(symbol);
695
+ }
696
+ }
697
+ else {
698
+ this.resetLeadingZero();
699
+ }
700
+ var partPattern = this.partPattern(dateParts.partMap, symbol);
701
+ var patternValue = partPattern ? partPattern.pattern : null;
702
+ if (isInCaretMode && isDeleting) {
703
+ var padPrefix = utils_1.padZero(Math.abs(current.length - datePartText.length));
704
+ current = padPrefix + datePartText;
705
+ }
706
+ if (isInCaretMode) {
707
+ if (isDeleting && !datePartText) {
708
+ this.setExisting(symbol, false);
709
+ return utils_2.extend(parseResult, { value: null, switchToNext: false });
710
+ }
711
+ }
712
+ var currentMaxLength = current.length - 3;
713
+ var tryParse = true;
714
+ for (var i = Math.max(0, currentMaxLength); i <= current.length; i++) {
715
+ if (!tryParse) {
716
+ break;
717
+ }
718
+ if (!this.autoCorrectParts) {
719
+ tryParse = false;
720
+ }
721
+ var middle = resetSegmentValue ? currentChar : (current.substring(i) + currentChar);
722
+ if (!tryParse && isInCaretMode) {
723
+ // try to make an exact match as there will be only 1 attempt
724
+ middle = utils_1.unpadZero(middle);
725
+ }
726
+ var middleNumber = parseInt(middle, 10);
727
+ var candidateDateString = prefix + middle + suffix;
728
+ parsedDate = this.intl.parseDate(candidateDateString, this.format, this.localeId);
729
+ var isCurrentCharParsable = !isNaN(parseInt(currentChar, 10)) || (isInCaretMode && isDeleting && currentChar === "");
730
+ if (!parsedDate && !isNaN(middleNumber) && isCurrentCharParsable) {
731
+ if (symbol === MONTH_SYMBOL && !month) {
732
+ // JS months start from 0 (January) instead of 1 (January)
733
+ var monthNumber = middleNumber - JS_MONTH_OFFSET;
734
+ if (monthNumber > -1 && monthNumber < 12) {
735
+ parsedDate = kendo_date_math_1.cloneDate(this.value);
736
+ parsedDate.setMonth(monthNumber);
737
+ if (parsedDate.getMonth() !== monthNumber) {
738
+ parsedDate = kendo_date_math_1.lastDayOfMonth(kendo_date_math_1.addMonths(parsedDate, -1));
739
+ }
740
+ }
741
+ }
742
+ if (symbol === 'y') {
743
+ parsedDate = kendo_date_math_1.createDate(parseInt(middle, 10), this.month ? this.value.getMonth() : 0, this.date ? this.value.getDate() : 1, this.hours ? this.value.getHours() : 0, this.minutes ? this.value.getMinutes() : 0, this.seconds ? this.value.getSeconds() : 0, this.milliseconds ? this.value.getMilliseconds() : 0);
744
+ if (this.date && parsedDate.getDate() !== this.value.getDate()) {
745
+ parsedDate = kendo_date_math_1.lastDayOfMonth(kendo_date_math_1.addMonths(parsedDate, -1));
746
+ }
747
+ }
748
+ }
749
+ if (parsedDate) {
750
+ // move to next segment if the part will overflow with next char
751
+ // when start from empty date (01, then 010), padded zeros should be trimmed
752
+ var peekDate = this.intl.parseDate("" + prefix + this.peek(middle, patternValue) + suffix, this.format, this.localeId);
753
+ var patternLength = this.patternLength(patternValue) || patternValue.length;
754
+ var patternSatisfied = (leadingZero + (utils_1.unpadZero(middle) || currentChar).length) >= patternLength;
755
+ var switchToNext = peekDate === null || patternSatisfied;
756
+ if (this.shouldNormalizeCentury()) {
757
+ parsedDate = this.normalizeCentury(parsedDate);
758
+ }
759
+ this._value = parsedDate;
760
+ this.setExisting(symbol, true);
761
+ return utils_2.extend(parseResult, { value: this.value, switchToNext: switchToNext });
762
+ }
763
+ }
764
+ if (month) {
765
+ parsedDate = this.intl.parseDate(prefix + month + suffix, this.format, this.localeId);
766
+ if (parsedDate) {
767
+ this._value = parsedDate;
768
+ this.setExisting(symbol, true);
769
+ return utils_2.extend(parseResult, { value: this.value, switchToNext: false });
770
+ }
771
+ }
772
+ if (dayPeriod) {
773
+ parsedDate = this.intl.parseDate(prefix + dayPeriod + suffix, this.format);
774
+ if (parsedDate) {
775
+ this._value = parsedDate;
776
+ return utils_2.extend(parseResult, { value: this.value, switchToNext: true });
777
+ }
778
+ }
779
+ if (isZeroCurrentChar) {
780
+ this.leadingZero = !this.isAbbrMonth(dateParts.partMap, symbol) ? (_b = {}, _b[symbol] = true, _b) : null;
781
+ this.setExisting(symbol, false);
782
+ }
783
+ if (!this.autoCorrectParts) {
784
+ this.setExisting(symbol, false);
785
+ // todo check if string is better
786
+ // const padPrefix = padZero(Math.abs(current.length - datePartText.length));
787
+ // const paddedDatePartText = padPrefix + datePartText;
788
+ var datePartValue = void 0;
789
+ var textToParse = isInCaretMode ? datePartText : current;
790
+ var parsedValue = utils_2.parseToInt(textToParse);
791
+ if (utils_2.isNumber(parsedValue)) {
792
+ datePartValue = symbol === "M" ?
793
+ utils_2.clamp(parsedValue - JS_MONTH_OFFSET, 0, 12 - JS_MONTH_OFFSET) :
794
+ parsedValue;
795
+ }
796
+ if (utils_2.isNumber(datePartValue)) {
797
+ var newDate = this.modifyDateSymbolWithValue(this.value, symbol, datePartValue);
798
+ this.setInvalidDatePart(symbol, {
799
+ value: datePartValue,
800
+ date: kendo_date_math_1.cloneDate(newDate),
801
+ startDate: this._partiallyInvalidDate.startDate || kendo_date_math_1.cloneDate(this.value)
802
+ });
803
+ }
804
+ }
805
+ return utils_2.extend(parseResult, { value: null, switchToNext: false });
806
+ };
807
+ /**
808
+ * @hidden
809
+ */
810
+ DateObject.prototype.symbolMap = function (symbol) {
811
+ return this.intl.splitDateFormat(this.format, this.localeId).reduce(utils_1.dateSymbolMap, {})[symbol];
812
+ };
813
+ /**
814
+ * @hidden
815
+ */
816
+ DateObject.prototype.resetLeadingZero = function () {
817
+ var hasLeadingZero = this.leadingZero !== null;
818
+ this.setLeadingZero(null);
819
+ return hasLeadingZero;
820
+ };
821
+ DateObject.prototype.setLeadingZero = function (leadingZero) {
822
+ this.leadingZero = leadingZero;
823
+ };
824
+ /**
825
+ * @hidden
826
+ */
827
+ DateObject.prototype.normalizeCentury = function (date) {
828
+ if (!utils_2.isPresent(date)) {
829
+ return date;
830
+ }
831
+ var twoDigitYear = utils_2.cropTwoDigitYear(date);
832
+ var centuryBase = this.getNormalizedCenturyBase(twoDigitYear);
833
+ var normalizedDate = utils_2.setYears(date, centuryBase + twoDigitYear);
834
+ return normalizedDate;
835
+ };
836
+ DateObject.prototype.incrementLeadingZero = function (symbol) {
837
+ var leadingZero = this.leadingZero || {};
838
+ leadingZero[symbol] = (leadingZero[symbol] || 0) + 1;
839
+ this.leadingZero = leadingZero;
840
+ };
841
+ /**
842
+ * @hidden
843
+ */
844
+ DateObject.prototype.isAbbrMonth = function (parts, symbol) {
845
+ var pattern = this.partPattern(parts, symbol);
846
+ return pattern.type === 'month' && pattern.names;
847
+ };
848
+ /**
849
+ * @hidden
850
+ */
851
+ DateObject.prototype.partPattern = function (parts, symbol) {
852
+ return parts.filter(function (part) { return part.pattern.indexOf(symbol) !== -1; })[0];
853
+ };
854
+ /**
855
+ * @hidden
856
+ */
857
+ DateObject.prototype.peek = function (value, pattern) {
858
+ var peekValue = value.replace(/^0*/, '') + '0';
859
+ return utils_1.padZero(pattern.length - peekValue.length) + peekValue;
860
+ };
861
+ /**
862
+ * @hidden
863
+ */
864
+ DateObject.prototype.matchMonth = function (typedChar) {
865
+ this.typedMonthPart += typedChar.toLowerCase();
866
+ if (this.monthNames.length === 0) {
867
+ return '';
868
+ }
869
+ while (this.typedMonthPart.length > 0) {
870
+ for (var i = 0; i < this.monthNames.length; i++) {
871
+ if (this.monthNames[i].toLowerCase().indexOf(this.typedMonthPart) === 0) {
872
+ return this.monthNames[i];
873
+ }
874
+ }
875
+ var monthAsNum = parseInt(this.typedMonthPart, 10);
876
+ /* ensure they exact match */
877
+ if (monthAsNum >= 1 && monthAsNum <= 12 && monthAsNum.toString() === this.typedMonthPart) {
878
+ return this.monthNames[monthAsNum - 1];
879
+ }
880
+ this.typedMonthPart = this.typedMonthPart.substring(1, this.typedMonthPart.length);
881
+ }
882
+ return '';
883
+ };
884
+ /**
885
+ * @hidden
886
+ */
887
+ DateObject.prototype.matchDayPeriod = function (typedChar, symbol) {
888
+ var lowerChart = typedChar.toLowerCase();
889
+ if (symbol === 'a' && this.dayPeriods) {
890
+ if (this.dayPeriods.am.toLowerCase().startsWith(lowerChart)) {
891
+ return this.dayPeriods.am;
892
+ }
893
+ else if (this.dayPeriods.pm.toLowerCase().startsWith(lowerChart)) {
894
+ return this.dayPeriods.pm;
895
+ }
896
+ }
897
+ return '';
898
+ };
899
+ /**
900
+ * @hidden
901
+ */
902
+ DateObject.prototype.allFormattedMonths = function (locale) {
903
+ if (locale === void 0) { locale = "en"; }
904
+ var dateFormatParts = this.intl.splitDateFormat(this.format, this.localeId);
905
+ for (var i = 0; i < dateFormatParts.length; i++) {
906
+ if (dateFormatParts[i].type === 'month' && dateFormatParts[i].names) {
907
+ // return this.intl.dateFormatNames(dateFormatParts[i].names);
908
+ return this.intl.dateFormatNames(locale, dateFormatParts[i].names);
909
+ }
910
+ }
911
+ return [];
912
+ };
913
+ /**
914
+ * @hidden
915
+ */
916
+ DateObject.prototype.allDayPeriods = function (locale) {
917
+ if (locale === void 0) { locale = "en"; }
918
+ var dateFormatParts = this.intl.splitDateFormat(this.format);
919
+ for (var i = 0; i < dateFormatParts.length; i++) {
920
+ if (dateFormatParts[i].type === "dayperiod" && dateFormatParts[i].names) {
921
+ return this.intl.dateFormatNames(locale, dateFormatParts[i].names);
922
+ }
923
+ }
924
+ return null;
925
+ };
926
+ /**
927
+ * @hidden
928
+ */
929
+ DateObject.prototype.patternLength = function (pattern) {
930
+ if (pattern[0] === 'y') {
931
+ return 4;
932
+ }
933
+ if (SHORT_PATTERN_LENGTH_REGEXP.test(pattern)) {
934
+ return 2;
935
+ }
936
+ return 0;
937
+ };
938
+ /**
939
+ * @hidden
940
+ */
941
+ DateObject.prototype.dateFormatString = function (date, format) {
942
+ var dateFormatParts = this.intl.splitDateFormat(format, this.localeId);
943
+ var parts = [];
944
+ var partMap = [];
945
+ for (var i = 0; i < dateFormatParts.length; i++) {
946
+ var partLength = this.intl.formatDate(date, { pattern: dateFormatParts[i].pattern }, this.localeId).length;
947
+ while (partLength > 0) {
948
+ parts.push(this.symbols[dateFormatParts[i].pattern[0]] || constants_1.Constants.formatSeparator);
949
+ partMap.push(dateFormatParts[i]);
950
+ partLength--;
951
+ }
952
+ }
953
+ var returnValue = new mask_1.Mask();
954
+ returnValue.symbols = parts.join('');
955
+ returnValue.partMap = partMap;
956
+ return returnValue;
957
+ };
958
+ /**
959
+ * @hidden
960
+ */
961
+ DateObject.prototype.merge = function (text, mask) {
962
+ // Important: right to left.
963
+ var resultText = '';
964
+ var resultFormat = '';
965
+ var format = mask.symbols;
966
+ for (var formatSymbolIndex = format.length - 1; formatSymbolIndex >= 0; formatSymbolIndex--) {
967
+ if (this.knownParts.indexOf(format[formatSymbolIndex]) === -1 || this.getExisting(format[formatSymbolIndex])) {
968
+ resultText = text[formatSymbolIndex] + resultText;
969
+ resultFormat = format[formatSymbolIndex] + resultFormat;
970
+ }
971
+ else {
972
+ var symbol = format[formatSymbolIndex];
973
+ while (formatSymbolIndex >= 0 && symbol === format[formatSymbolIndex]) {
974
+ formatSymbolIndex--;
975
+ }
976
+ formatSymbolIndex++;
977
+ if (this.leadingZero && this.leadingZero[symbol]) {
978
+ resultText = '0' + resultText;
979
+ }
980
+ else {
981
+ if (!this.autoCorrectParts && this.getInvalidDatePartValue(symbol)) {
982
+ var segmentText = text.substr(formatSymbolIndex, mask.partMap[formatSymbolIndex].pattern.length);
983
+ resultText = segmentText + resultText;
984
+ }
985
+ else {
986
+ resultText = this.dateFieldName(mask.partMap[formatSymbolIndex]) + resultText;
987
+ }
988
+ }
989
+ while (resultFormat.length < resultText.length) {
990
+ resultFormat = format[formatSymbolIndex] + resultFormat;
991
+ }
992
+ }
993
+ }
994
+ return { text: resultText, format: resultFormat };
995
+ };
996
+ /**
997
+ * @hidden
998
+ */
999
+ DateObject.prototype.dateFieldName = function (part) {
1000
+ var formatPlaceholder = this.formatPlaceholder || 'wide';
1001
+ if (formatPlaceholder[part.type]) {
1002
+ return formatPlaceholder[part.type];
1003
+ }
1004
+ if (formatPlaceholder === 'formatPattern') {
1005
+ return part.pattern;
1006
+ }
1007
+ return this.intl.dateFieldName(Object.assign(part, { nameType: formatPlaceholder }));
1008
+ };
1009
+ /**
1010
+ * @hidden
1011
+ */
1012
+ DateObject.prototype.getNormalizedCenturyBase = function (twoDigitYear) {
1013
+ return twoDigitYear > this.twoDigitYearMax ?
1014
+ PREVIOUS_CENTURY_BASE :
1015
+ CURRENT_CENTURY_BASE;
1016
+ };
1017
+ /**
1018
+ * @hidden
1019
+ */
1020
+ DateObject.prototype.shouldNormalizeCentury = function () {
1021
+ return this.intl.splitDateFormat(this.format).some(function (part) { return part.pattern === 'yy'; });
1022
+ };
1023
+ DateObject.prototype.resetInvalidDate = function () {
1024
+ var _this = this;
1025
+ this._partiallyInvalidDate.startDate = null;
1026
+ Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach(function (key) {
1027
+ _this.resetInvalidDatePart(key);
1028
+ });
1029
+ };
1030
+ DateObject.prototype.resetInvalidDateSymbol = function (symbol) {
1031
+ var _this = this;
1032
+ this.resetInvalidDatePart(symbol);
1033
+ var shouldResetInvalidDate = true;
1034
+ Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach(function (key) {
1035
+ if (_this._partiallyInvalidDate.invalidDateParts[key] &&
1036
+ utils_2.isPresent(_this._partiallyInvalidDate.invalidDateParts[key].value)) {
1037
+ shouldResetInvalidDate = false;
1038
+ }
1039
+ });
1040
+ if (shouldResetInvalidDate) {
1041
+ this.resetInvalidDate();
1042
+ }
1043
+ };
1044
+ DateObject.prototype.resetInvalidDatePart = function (symbol) {
1045
+ if (this._partiallyInvalidDate.invalidDateParts[symbol]) {
1046
+ this._partiallyInvalidDate.invalidDateParts[symbol] = {
1047
+ value: null,
1048
+ date: null,
1049
+ startDateOffset: 0
1050
+ };
1051
+ }
1052
+ };
1053
+ /**
1054
+ * @hidden
1055
+ */
1056
+ DateObject.prototype.getInvalidDatePart = function (symbol) {
1057
+ var invalidDatePart = this._partiallyInvalidDate.invalidDateParts[symbol];
1058
+ return invalidDatePart || {};
1059
+ };
1060
+ /**
1061
+ * @hidden
1062
+ */
1063
+ DateObject.prototype.getInvalidDatePartValue = function (symbol) {
1064
+ var invalidDatePart = this._partiallyInvalidDate.invalidDateParts[symbol];
1065
+ return (invalidDatePart || {}).value;
1066
+ };
1067
+ DateObject.prototype.setInvalidDatePart = function (symbol, _a) {
1068
+ var _b = _a.value, value = _b === void 0 ? null : _b, _c = _a.date, date = _c === void 0 ? null : _c, _d = _a.startDateOffset, startDateOffset = _d === void 0 ? 0 : _d, _e = _a.startDate, startDate = _e === void 0 ? null : _e;
1069
+ if (this._partiallyInvalidDate.invalidDateParts[symbol]) {
1070
+ this._partiallyInvalidDate.invalidDateParts[symbol].value = value;
1071
+ this._partiallyInvalidDate.invalidDateParts[symbol].date = date;
1072
+ this._partiallyInvalidDate.invalidDateParts[symbol].startDateOffset = startDateOffset;
1073
+ this._partiallyInvalidDate.startDate = startDate;
1074
+ }
1075
+ };
1076
+ /**
1077
+ * @hidden
1078
+ */
1079
+ DateObject.prototype.modifyDateSymbolWithOffset = function (date, symbol, offset) {
1080
+ var newValue = kendo_date_math_1.cloneDate(date);
1081
+ var timeModified = false;
1082
+ switch (symbol) {
1083
+ case 'y':
1084
+ newValue.setFullYear(newValue.getFullYear() + offset);
1085
+ break;
1086
+ case 'M':
1087
+ newValue = kendo_date_math_1.addMonths(this.value, offset);
1088
+ break;
1089
+ case 'd':
1090
+ case 'E':
1091
+ newValue.setDate(newValue.getDate() + offset);
1092
+ break;
1093
+ case 'h':
1094
+ case 'H':
1095
+ newValue.setHours(newValue.getHours() + offset);
1096
+ timeModified = true;
1097
+ break;
1098
+ case 'm':
1099
+ newValue.setMinutes(newValue.getMinutes() + offset);
1100
+ timeModified = true;
1101
+ break;
1102
+ case 's':
1103
+ newValue.setSeconds(newValue.getSeconds() + offset);
1104
+ timeModified = true;
1105
+ break;
1106
+ case "S":
1107
+ newValue.setMilliseconds(newValue.getMilliseconds() + offset);
1108
+ break;
1109
+ case 'a':
1110
+ newValue.setHours(newValue.getHours() + (12 * offset));
1111
+ timeModified = true;
1112
+ break;
1113
+ default: break;
1114
+ }
1115
+ return {
1116
+ date: newValue,
1117
+ timeModified: timeModified
1118
+ };
1119
+ };
1120
+ /**
1121
+ * @hidden
1122
+ */
1123
+ DateObject.prototype.modifyDateSymbolWithValue = function (date, symbol, value) {
1124
+ var newValue = kendo_date_math_1.cloneDate(date);
1125
+ switch (symbol) {
1126
+ case 'y':
1127
+ newValue.setFullYear(value);
1128
+ break;
1129
+ case 'M':
1130
+ newValue = kendo_date_math_1.addMonths(date, value - date.getMonth());
1131
+ break;
1132
+ case 'd':
1133
+ case 'E':
1134
+ newValue.setDate(value);
1135
+ break;
1136
+ case 'h':
1137
+ case 'H':
1138
+ newValue.setHours(value);
1139
+ break;
1140
+ case 'm':
1141
+ newValue.setMinutes(value);
1142
+ break;
1143
+ case 's':
1144
+ newValue.setSeconds(value);
1145
+ break;
1146
+ case "S":
1147
+ newValue.setMilliseconds(value);
1148
+ break;
1149
+ case 'a':
1150
+ newValue.setHours(value);
1151
+ break;
1152
+ default: break;
1153
+ }
1154
+ return newValue;
1155
+ };
1156
+ DateObject.prototype.markDatePartsAsExisting = function () {
1157
+ this.modifyExisting(true);
1158
+ };
1159
+ return DateObject;
1160
+ }());
1161
+ exports.DateObject = DateObject;