@progress/kendo-dateinputs-common 0.2.0-dev.202301131210 → 0.2.0-dev.202301171717
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/dist/cdn/js/kendo-dateinputs-common.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/dateobject.js +279 -74
- package/dist/es/dateinput/dateinput.js +65 -10
- package/dist/es2015/common/dateobject.js +279 -75
- package/dist/es2015/dateinput/dateinput.js +66 -11
- package/dist/npm/common/dateobject.d.ts +8 -0
- package/dist/npm/common/dateobject.js +279 -74
- package/dist/npm/dateinput/dateinput.d.ts +1 -0
- package/dist/npm/dateinput/dateinput.js +65 -10
- package/dist/systemjs/kendo-dateinputs-common.js +1 -1
- package/package.json +1 -1
|
@@ -547,6 +547,14 @@ var DateObject = /** @class */ (function () {
|
|
|
547
547
|
literal: ""
|
|
548
548
|
};
|
|
549
549
|
});
|
|
550
|
+
var flatDateParts = dateParts.partMap
|
|
551
|
+
.map(function (x) {
|
|
552
|
+
return {
|
|
553
|
+
type: x.type,
|
|
554
|
+
pattern: x.pattern,
|
|
555
|
+
text: ""
|
|
556
|
+
};
|
|
557
|
+
});
|
|
550
558
|
for (var i = 0; i < datePartsLiterals.length; i++) {
|
|
551
559
|
var datePart = datePartsLiterals[i];
|
|
552
560
|
for (var j = 0; j < datePart.pattern.length; j++) {
|
|
@@ -556,13 +564,23 @@ var DateObject = /** @class */ (function () {
|
|
|
556
564
|
}
|
|
557
565
|
i += datePart.pattern.length - 1;
|
|
558
566
|
}
|
|
567
|
+
for (var i = 0; i < flatDateParts.length; i++) {
|
|
568
|
+
var datePart = flatDateParts[i];
|
|
569
|
+
for (var j = 0; j < datePart.pattern.length; j++) {
|
|
570
|
+
if (flatDateParts[i + j]) {
|
|
571
|
+
flatDateParts[i + j].text = datePart.pattern[j];
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
i += datePart.pattern.length - 1;
|
|
575
|
+
}
|
|
559
576
|
var shouldResetPart = isInCaretMode && symbol === "M" && dateParts.partMap
|
|
560
577
|
.filter(function (x) { return x.type === "month"; })
|
|
561
578
|
.some(function (x) { return x.pattern.length > MONTH_PART_WITH_WORDS_THRESHOLD; });
|
|
562
579
|
var parseResult = {
|
|
563
580
|
value: null,
|
|
564
581
|
switchPart: false,
|
|
565
|
-
resetPart: shouldResetPart
|
|
582
|
+
resetPart: shouldResetPart,
|
|
583
|
+
hasInvalidDatePart: false
|
|
566
584
|
};
|
|
567
585
|
if (!currentChar) {
|
|
568
586
|
if (isInCaretMode) {
|
|
@@ -596,14 +614,20 @@ var DateObject = /** @class */ (function () {
|
|
|
596
614
|
var basePrefix = '';
|
|
597
615
|
var baseSuffix = '';
|
|
598
616
|
var suffix = '';
|
|
599
|
-
var
|
|
600
|
-
var
|
|
601
|
-
|
|
617
|
+
var convertedBaseFormat = "";
|
|
618
|
+
for (var i = 0; i < flatDateParts.length; i++) {
|
|
619
|
+
convertedBaseFormat += flatDateParts[i].text;
|
|
620
|
+
}
|
|
602
621
|
var hasFixedFormat = (this.format === baseFormat) ||
|
|
622
|
+
(this.format === convertedBaseFormat) ||
|
|
603
623
|
(this.format === originalFormat) ||
|
|
604
624
|
(this.format.length === originalFormat.length);
|
|
605
|
-
|
|
606
|
-
|
|
625
|
+
var datePartStartIndex = (hasFixedFormat ? convertedBaseFormat : originalFormat).indexOf(symbol);
|
|
626
|
+
var datePartEndIndex = (hasFixedFormat ? convertedBaseFormat : originalFormat).lastIndexOf(symbol);
|
|
627
|
+
var segmentLength = datePartEndIndex - datePartStartIndex + 1;
|
|
628
|
+
var processedSegmentCharsCount = 0;
|
|
629
|
+
var formatToTextLengthDiff = originalFormat.length - rawInputValue.length;
|
|
630
|
+
if (isInCaretMode || (!isInCaretMode && !this.autoCorrectParts)) {
|
|
607
631
|
for (var i = 0; i < baseDate.length; i++) {
|
|
608
632
|
if (baseFormat[i] === symbol) {
|
|
609
633
|
var existing = this.getExisting(symbol);
|
|
@@ -615,6 +639,11 @@ var DateObject = /** @class */ (function () {
|
|
|
615
639
|
}
|
|
616
640
|
processedSegmentCharsCount++;
|
|
617
641
|
}
|
|
642
|
+
else if (formatToTextLengthDiff > 0) {
|
|
643
|
+
if (datePartText.length + formatToTextLengthDiff < segmentLength) {
|
|
644
|
+
datePartText += rawInputValue[i] || "";
|
|
645
|
+
}
|
|
646
|
+
}
|
|
618
647
|
else {
|
|
619
648
|
datePartText += rawInputValue[i] || "";
|
|
620
649
|
}
|
|
@@ -630,12 +659,12 @@ var DateObject = /** @class */ (function () {
|
|
|
630
659
|
}
|
|
631
660
|
}
|
|
632
661
|
if (hasFixedFormat) {
|
|
633
|
-
if (
|
|
662
|
+
if (convertedBaseFormat.length < rawInputValue.length) {
|
|
634
663
|
datePartText += currentChar;
|
|
635
664
|
}
|
|
636
665
|
else if (!isDeleting && originalFormat.length > rawInputValue.length) {
|
|
637
666
|
var lengthDiff = originalFormat.length - rawInputValue.length;
|
|
638
|
-
var trimmedDatePartText = datePartText.
|
|
667
|
+
var trimmedDatePartText = datePartText.substr(0, datePartText.length - lengthDiff);
|
|
639
668
|
if (trimmedDatePartText && trimmedDatePartText.length > 0) {
|
|
640
669
|
datePartText = trimmedDatePartText;
|
|
641
670
|
}
|
|
@@ -644,7 +673,7 @@ var DateObject = /** @class */ (function () {
|
|
|
644
673
|
return utils_2.extend(parseResult, { value: null, switchToNext: false });
|
|
645
674
|
}
|
|
646
675
|
}
|
|
647
|
-
|
|
676
|
+
if (!hasFixedFormat || (hasFixedFormat && !this.autoCorrectParts)) {
|
|
648
677
|
processedSegmentCharsCount = 0;
|
|
649
678
|
current = "";
|
|
650
679
|
datePartText = "";
|
|
@@ -662,6 +691,11 @@ var DateObject = /** @class */ (function () {
|
|
|
662
691
|
}
|
|
663
692
|
processedSegmentCharsCount++;
|
|
664
693
|
}
|
|
694
|
+
else if (formatToTextLengthDiff > 0) {
|
|
695
|
+
if (datePartText.length + formatToTextLengthDiff < segmentLength) {
|
|
696
|
+
datePartText += rawInputValue[i] || "";
|
|
697
|
+
}
|
|
698
|
+
}
|
|
665
699
|
else {
|
|
666
700
|
datePartText += rawInputValue[i] || "";
|
|
667
701
|
}
|
|
@@ -671,43 +705,52 @@ var DateObject = /** @class */ (function () {
|
|
|
671
705
|
prefix += rawInputValue[i] || "";
|
|
672
706
|
}
|
|
673
707
|
else {
|
|
674
|
-
suffix += rawInputValue[i] || "";
|
|
708
|
+
suffix += rawInputValue[i - formatToTextLengthDiff] || "";
|
|
675
709
|
}
|
|
676
710
|
}
|
|
677
711
|
if (originalFormat.length < rawInputValue.length) {
|
|
678
712
|
datePartText += currentChar;
|
|
679
713
|
}
|
|
680
|
-
else if (!isDeleting && originalFormat.length > rawInputValue.length) {
|
|
681
|
-
var lengthDiff = originalFormat.length - rawInputValue.length;
|
|
682
|
-
var trimmedDatePartText = datePartText.substring(0, datePartText.length - lengthDiff);
|
|
683
|
-
if (trimmedDatePartText && trimmedDatePartText.length > 0) {
|
|
684
|
-
datePartText = trimmedDatePartText;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
714
|
}
|
|
688
715
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
716
|
+
if (!isInCaretMode) {
|
|
717
|
+
if (this.autoCorrectParts) {
|
|
718
|
+
processedSegmentCharsCount = 0;
|
|
719
|
+
current = "";
|
|
720
|
+
datePartText = "";
|
|
721
|
+
prefix = "";
|
|
722
|
+
suffix = "";
|
|
723
|
+
replaced = false;
|
|
724
|
+
for (var i = 0; i < baseDate.length; i++) {
|
|
725
|
+
if (baseFormat[i] === symbol) {
|
|
726
|
+
var existing = this.getExisting(symbol);
|
|
727
|
+
current += existing ? baseDate[i] : '0';
|
|
728
|
+
replaced = true;
|
|
729
|
+
}
|
|
730
|
+
else if (!replaced) {
|
|
731
|
+
prefix += baseDate[i];
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
suffix += baseDate[i];
|
|
735
|
+
}
|
|
701
736
|
}
|
|
702
737
|
}
|
|
738
|
+
else {
|
|
739
|
+
current = resetSegmentValue ? datePartText : current;
|
|
740
|
+
}
|
|
703
741
|
}
|
|
704
742
|
var parsedDate = null;
|
|
705
743
|
var month = this.matchMonth(currentChar);
|
|
706
744
|
var dayPeriod = this.matchDayPeriod(currentChar, symbol);
|
|
707
745
|
var isZeroCurrentChar = currentChar === '0';
|
|
708
746
|
var leadingZero = this.leadingZero || {};
|
|
709
|
-
if (isZeroCurrentChar
|
|
710
|
-
|
|
747
|
+
if (isZeroCurrentChar) {
|
|
748
|
+
if (datePartText === "0") {
|
|
749
|
+
datePartText = current;
|
|
750
|
+
}
|
|
751
|
+
var valueNumber = utils_2.parseToInt(resetSegmentValue ?
|
|
752
|
+
currentChar :
|
|
753
|
+
(isInCaretMode ? datePartText : current) + currentChar);
|
|
711
754
|
if (valueNumber === 0 && !this.isAbbrMonth(dateParts.partMap, symbol)) {
|
|
712
755
|
this.incrementLeadingZero(symbol);
|
|
713
756
|
}
|
|
@@ -725,32 +768,25 @@ var DateObject = /** @class */ (function () {
|
|
|
725
768
|
}
|
|
726
769
|
var currentMaxLength = current.length - 3;
|
|
727
770
|
var tryParse = true;
|
|
771
|
+
var middle = isInCaretMode ? datePartText : current;
|
|
728
772
|
for (var i = Math.max(0, currentMaxLength); i <= current.length; i++) {
|
|
729
773
|
if (!tryParse) {
|
|
730
774
|
break;
|
|
731
775
|
}
|
|
732
|
-
|
|
776
|
+
middle = resetSegmentValue ?
|
|
733
777
|
currentChar :
|
|
734
778
|
isInCaretMode ?
|
|
735
779
|
datePartText :
|
|
736
780
|
(current.substring(i) + currentChar);
|
|
737
|
-
if (!this.autoCorrectParts) {
|
|
738
|
-
tryParse = false;
|
|
739
|
-
if (!isInCaretMode) {
|
|
740
|
-
// try to make an exact match as there will be only 1 attempt
|
|
741
|
-
middle = utils_1.unpadZero(middle);
|
|
742
|
-
middle = utils_1.padZero(segmentLength - middle.length) + middle;
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
if (isInCaretMode) {
|
|
746
|
-
// try to make an exact match as there will be only 1 attempt
|
|
781
|
+
if (isInCaretMode || !this.autoCorrectParts) {
|
|
747
782
|
tryParse = false;
|
|
748
783
|
middle = utils_1.unpadZero(middle);
|
|
784
|
+
middle = utils_1.padZero(segmentLength - middle.length) + middle;
|
|
749
785
|
}
|
|
750
786
|
var middleNumber = parseInt(middle, 10);
|
|
751
787
|
var candidateDateString = prefix + middle + suffix;
|
|
752
788
|
parsedDate = this.intl.parseDate(candidateDateString, this.format, this.localeId);
|
|
753
|
-
if (isInCaretMode && !
|
|
789
|
+
if (isInCaretMode && !utils_2.isValidDate(parsedDate)) {
|
|
754
790
|
// if part of the date is not available, e.g. "d"
|
|
755
791
|
// but an expanded format like "F" is used
|
|
756
792
|
// the element value can be "EEEE, February 1, 2022 3:04:05 AM"
|
|
@@ -758,11 +794,12 @@ var DateObject = /** @class */ (function () {
|
|
|
758
794
|
// use the base prefix and suffix, e.g. convert the candidate date string
|
|
759
795
|
// to "Thursday, February 1, 2022 3:04:05 AM"
|
|
760
796
|
// as "EEEE, February..." is not parsable
|
|
761
|
-
|
|
762
|
-
|
|
797
|
+
if (this.autoCorrectParts) {
|
|
798
|
+
parsedDate = this.intl.parseDate(basePrefix + middle + baseSuffix, this.format, this.localeId);
|
|
799
|
+
}
|
|
763
800
|
}
|
|
764
801
|
var isCurrentCharParsable = !isNaN(parseInt(currentChar, 10)) || (isInCaretMode && isDeleting && currentChar === "");
|
|
765
|
-
if (!parsedDate && !isNaN(middleNumber) && isCurrentCharParsable) {
|
|
802
|
+
if (!parsedDate && !isNaN(middleNumber) && isCurrentCharParsable && this.autoCorrectParts) {
|
|
766
803
|
if (symbol === MONTH_SYMBOL && !month) {
|
|
767
804
|
// JS months start from 0 (January) instead of 1 (January)
|
|
768
805
|
var monthNumber = middleNumber - JS_MONTH_OFFSET;
|
|
@@ -797,16 +834,34 @@ var DateObject = /** @class */ (function () {
|
|
|
797
834
|
}
|
|
798
835
|
this._value = parsedDate;
|
|
799
836
|
this.setExisting(symbol, true);
|
|
837
|
+
this.resetInvalidDateSymbol(symbol);
|
|
838
|
+
if (!this.autoCorrectParts) {
|
|
839
|
+
if (symbol === "M") {
|
|
840
|
+
if (this.getExisting("M") && this.getExisting("y")) {
|
|
841
|
+
// changing from 28/Feb to 29/Feb to 29/March
|
|
842
|
+
this.setExisting("d", true);
|
|
843
|
+
this.resetInvalidDateSymbol("d");
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
else if (symbol === "d") {
|
|
847
|
+
if (this.getExisting("d") && this.getExisting("y")) {
|
|
848
|
+
// changing from 31/Jan to 31/Feb to 28/Feb
|
|
849
|
+
this.setExisting("M", true);
|
|
850
|
+
this.resetInvalidDateSymbol("M");
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
if (!this.hasInvalidDatePart()) {
|
|
854
|
+
this.markDatePartsAsExisting();
|
|
855
|
+
}
|
|
856
|
+
}
|
|
800
857
|
if (isInCaretMode && switchToNext) {
|
|
801
858
|
if (symbol === "M") {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
switchToNext = false;
|
|
809
|
-
}
|
|
859
|
+
var datePartValue = utils_2.parseToInt(datePartText);
|
|
860
|
+
if (datePartValue >= 2 || datePartText.length >= 2) {
|
|
861
|
+
switchToNext = true;
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
switchToNext = false;
|
|
810
865
|
}
|
|
811
866
|
}
|
|
812
867
|
else {
|
|
@@ -839,29 +894,157 @@ var DateObject = /** @class */ (function () {
|
|
|
839
894
|
this.leadingZero = !this.isAbbrMonth(dateParts.partMap, symbol) ? (_b = {}, _b[symbol] = true, _b) : null;
|
|
840
895
|
this.setExisting(symbol, false);
|
|
841
896
|
}
|
|
842
|
-
if (isInCaretMode && datePartText.length > segmentLength) {
|
|
843
|
-
return utils_2.extend(parseResult, { value: null, switchToNext: false });
|
|
844
|
-
}
|
|
845
897
|
if (!this.autoCorrectParts) {
|
|
846
|
-
this.setExisting(symbol, false);
|
|
847
898
|
var datePartValue = void 0;
|
|
848
|
-
var textToParse = isInCaretMode ? datePartText :
|
|
899
|
+
var textToParse = isInCaretMode ? datePartText : middle;
|
|
849
900
|
var parsedValue = utils_2.parseToInt(textToParse);
|
|
850
901
|
if (utils_2.isNumber(parsedValue)) {
|
|
902
|
+
if ((symbol === "d" && (parsedValue <= 0 || parsedValue > 31)) ||
|
|
903
|
+
(symbol === "M" && (parsedValue < 0 || parsedValue > 11))) {
|
|
904
|
+
return utils_2.extend(parseResult, { value: null, switchToNext: false });
|
|
905
|
+
}
|
|
851
906
|
datePartValue = symbol === "M" ?
|
|
852
|
-
|
|
907
|
+
parsedValue - JS_MONTH_OFFSET :
|
|
853
908
|
parsedValue;
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
var
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
909
|
+
var isMonth = symbol === "M";
|
|
910
|
+
var isDay = symbol === "d";
|
|
911
|
+
var newValue = kendo_date_math_1.cloneDate(this._value);
|
|
912
|
+
var invalidDateParts = this._partiallyInvalidDate.invalidDateParts || {};
|
|
913
|
+
var year = invalidDateParts.y.value || newValue.getFullYear();
|
|
914
|
+
/* tslint:disable:no-shadowed-variable */
|
|
915
|
+
var month_1 = isMonth ? datePartValue : invalidDateParts.M.value || newValue.getMonth();
|
|
916
|
+
/* tslint:enable:no-shadowed-variable */
|
|
917
|
+
var day = isDay ? datePartValue : invalidDateParts.d.value || invalidDateParts.E.value || newValue.getDate();
|
|
918
|
+
var hour = invalidDateParts.h.value || invalidDateParts.H.value || newValue.getHours();
|
|
919
|
+
var minutes = invalidDateParts.m.value || newValue.getMinutes();
|
|
920
|
+
var seconds = invalidDateParts.s.value || newValue.getSeconds();
|
|
921
|
+
var milliseconds = invalidDateParts.S.value || newValue.getMilliseconds();
|
|
922
|
+
var dateCandidate = kendo_date_math_1.createDate(year, month_1, day, hour, minutes, seconds, milliseconds);
|
|
923
|
+
var dateCandidateExists = utils_2.areDatePartsEqualTo(dateCandidate, year, month_1, day, hour, minutes, seconds, milliseconds);
|
|
924
|
+
var newValueCandidate = isMonth || isDay ?
|
|
925
|
+
this.modifyDateSymbolWithValue(newValue, symbol, isMonth ? month_1 : day) :
|
|
926
|
+
null;
|
|
927
|
+
var invalidDateFound = false;
|
|
928
|
+
if (isMonth && newValueCandidate) {
|
|
929
|
+
if (newValueCandidate.getMonth() === month_1) {
|
|
930
|
+
if (this.getExisting("d")) {
|
|
931
|
+
if (dateCandidateExists) {
|
|
932
|
+
newValue = kendo_date_math_1.cloneDate(dateCandidate);
|
|
933
|
+
this.resetInvalidDateSymbol(symbol);
|
|
934
|
+
}
|
|
935
|
+
else {
|
|
936
|
+
invalidDateFound = true;
|
|
937
|
+
this.setInvalidDatePart(symbol, {
|
|
938
|
+
value: month_1,
|
|
939
|
+
date: kendo_date_math_1.cloneDate(newValueCandidate),
|
|
940
|
+
// startDateOffset: offset,
|
|
941
|
+
startDate: kendo_date_math_1.cloneDate(this.value)
|
|
942
|
+
});
|
|
943
|
+
this.setExisting(symbol, false);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
else if (dateCandidateExists) {
|
|
947
|
+
this.resetInvalidDateSymbol(symbol);
|
|
948
|
+
newValue = kendo_date_math_1.cloneDate(dateCandidate);
|
|
949
|
+
if (this.getExisting("M") && this.getExisting("y")) {
|
|
950
|
+
// changing from 28/Feb to 29/Feb to 29/March
|
|
951
|
+
this.setExisting("d", true);
|
|
952
|
+
this.resetInvalidDateSymbol("d");
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
else {
|
|
956
|
+
this.resetInvalidDateSymbol(symbol);
|
|
957
|
+
newValue = kendo_date_math_1.cloneDate(newValueCandidate);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
else {
|
|
961
|
+
invalidDateFound = true;
|
|
962
|
+
this.setInvalidDatePart(symbol, {
|
|
963
|
+
value: month_1,
|
|
964
|
+
date: kendo_date_math_1.cloneDate(newValueCandidate),
|
|
965
|
+
// startDateOffset: offset,
|
|
966
|
+
startDate: kendo_date_math_1.cloneDate(this.value)
|
|
967
|
+
});
|
|
968
|
+
this.setExisting(symbol, false);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
else if (isDay && newValueCandidate) {
|
|
972
|
+
if (newValueCandidate.getDate() === day) {
|
|
973
|
+
if (this.getExisting("M")) {
|
|
974
|
+
if (dateCandidateExists) {
|
|
975
|
+
newValue = kendo_date_math_1.cloneDate(dateCandidate);
|
|
976
|
+
this.resetInvalidDateSymbol(symbol);
|
|
977
|
+
}
|
|
978
|
+
else {
|
|
979
|
+
invalidDateFound = true;
|
|
980
|
+
this.setInvalidDatePart(symbol, {
|
|
981
|
+
value: day,
|
|
982
|
+
date: kendo_date_math_1.cloneDate(newValueCandidate),
|
|
983
|
+
// startDateOffset: offset,
|
|
984
|
+
startDate: kendo_date_math_1.cloneDate(this.value)
|
|
985
|
+
});
|
|
986
|
+
this.setExisting(symbol, false);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
else if (dateCandidateExists) {
|
|
990
|
+
newValue = kendo_date_math_1.cloneDate(dateCandidate);
|
|
991
|
+
this.resetInvalidDateSymbol(symbol);
|
|
992
|
+
if (this.getExisting("d") && this.getExisting("y")) {
|
|
993
|
+
// changing from 31/Jan to 31/Feb to 28/Feb
|
|
994
|
+
this.setExisting("M", true);
|
|
995
|
+
this.resetInvalidDateSymbol("M");
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
this.resetInvalidDateSymbol(symbol);
|
|
1000
|
+
newValue = kendo_date_math_1.cloneDate(newValueCandidate);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
else {
|
|
1004
|
+
invalidDateFound = true;
|
|
1005
|
+
this.setInvalidDatePart(symbol, {
|
|
1006
|
+
value: day,
|
|
1007
|
+
date: kendo_date_math_1.cloneDate(this.value),
|
|
1008
|
+
// startDateOffset: offset,
|
|
1009
|
+
startDate: kendo_date_math_1.cloneDate(this.value)
|
|
1010
|
+
});
|
|
1011
|
+
this.setExisting(symbol, false);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
if (!invalidDateFound) {
|
|
1015
|
+
this.setExisting(symbol, true);
|
|
1016
|
+
if (isInCaretMode && !utils_2.isValidDate(parsedDate)) {
|
|
1017
|
+
var valueCandidate = this.intl.parseDate(basePrefix + middle + baseSuffix, this.format, this.localeId);
|
|
1018
|
+
if (utils_2.isValidDate(valueCandidate)) {
|
|
1019
|
+
this._value = valueCandidate;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
else {
|
|
1023
|
+
this._value = newValue;
|
|
1024
|
+
}
|
|
1025
|
+
if (this.getValue()) {
|
|
1026
|
+
this.resetInvalidDate();
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
var switchToNext = false;
|
|
1030
|
+
if (symbol === "M") {
|
|
1031
|
+
if (parsedValue >= 2 || textToParse.length >= 2) {
|
|
1032
|
+
switchToNext = true;
|
|
1033
|
+
}
|
|
1034
|
+
else {
|
|
1035
|
+
switchToNext = false;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
switchToNext = hasFixedFormat ?
|
|
1040
|
+
textToParse.length === segmentLength :
|
|
1041
|
+
textToParse.length > segmentLength;
|
|
1042
|
+
}
|
|
1043
|
+
return utils_2.extend(parseResult, {
|
|
1044
|
+
value: null,
|
|
1045
|
+
switchToNext: switchToNext,
|
|
1046
|
+
hasInvalidDatePart: invalidDateFound
|
|
863
1047
|
});
|
|
864
|
-
// }
|
|
865
1048
|
}
|
|
866
1049
|
}
|
|
867
1050
|
return utils_2.extend(parseResult, { value: null, switchToNext: false });
|
|
@@ -883,6 +1066,12 @@ var DateObject = /** @class */ (function () {
|
|
|
883
1066
|
DateObject.prototype.setLeadingZero = function (leadingZero) {
|
|
884
1067
|
this.leadingZero = leadingZero;
|
|
885
1068
|
};
|
|
1069
|
+
/**
|
|
1070
|
+
* @hidden
|
|
1071
|
+
*/
|
|
1072
|
+
DateObject.prototype.getLeadingZero = function () {
|
|
1073
|
+
return this.leadingZero || {};
|
|
1074
|
+
};
|
|
886
1075
|
/**
|
|
887
1076
|
* @hidden
|
|
888
1077
|
*/
|
|
@@ -966,7 +1155,6 @@ var DateObject = /** @class */ (function () {
|
|
|
966
1155
|
var dateFormatParts = this.intl.splitDateFormat(this.format, this.localeId);
|
|
967
1156
|
for (var i = 0; i < dateFormatParts.length; i++) {
|
|
968
1157
|
if (dateFormatParts[i].type === 'month' && dateFormatParts[i].names) {
|
|
969
|
-
// return this.intl.dateFormatNames(dateFormatParts[i].names);
|
|
970
1158
|
return this.intl.dateFormatNames(locale, dateFormatParts[i].names);
|
|
971
1159
|
}
|
|
972
1160
|
}
|
|
@@ -1078,13 +1266,16 @@ var DateObject = /** @class */ (function () {
|
|
|
1078
1266
|
}
|
|
1079
1267
|
else {
|
|
1080
1268
|
datePartText = (utils_2.parseToInt(this.getInvalidDatePartValue(symbol)) + JS_MONTH_OFFSET).toString();
|
|
1081
|
-
|
|
1269
|
+
var formattedDatePart = utils_1.padZero(partsForSegment.length - datePartText.length) + datePartText;
|
|
1270
|
+
resultText = formattedDatePart + resultText;
|
|
1271
|
+
formatSymbolIndexModifier = partsForSegment.length - 1;
|
|
1082
1272
|
ignoreFormatSymbolsCount = datePartText.length - partsForSegment.length;
|
|
1083
1273
|
}
|
|
1084
1274
|
}
|
|
1085
1275
|
else {
|
|
1086
|
-
|
|
1087
|
-
|
|
1276
|
+
var formattedDatePart = utils_1.padZero(partsForSegment.length - datePartText.length) + datePartText;
|
|
1277
|
+
resultText = formattedDatePart + resultText;
|
|
1278
|
+
formatSymbolIndexModifier = partsForSegment.length - 1;
|
|
1088
1279
|
ignoreFormatSymbolsCount = datePartText.length - partsForSegment.length;
|
|
1089
1280
|
}
|
|
1090
1281
|
}
|
|
@@ -1182,6 +1373,20 @@ var DateObject = /** @class */ (function () {
|
|
|
1182
1373
|
this._partiallyInvalidDate.startDate = startDate;
|
|
1183
1374
|
}
|
|
1184
1375
|
};
|
|
1376
|
+
/**
|
|
1377
|
+
* @hidden
|
|
1378
|
+
*/
|
|
1379
|
+
DateObject.prototype.hasInvalidDatePart = function () {
|
|
1380
|
+
var _this = this;
|
|
1381
|
+
var hasInvalidDatePart = false;
|
|
1382
|
+
Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach(function (key) {
|
|
1383
|
+
if (_this._partiallyInvalidDate.invalidDateParts[key] &&
|
|
1384
|
+
utils_2.isPresent(_this._partiallyInvalidDate.invalidDateParts[key].value)) {
|
|
1385
|
+
hasInvalidDatePart = true;
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
return hasInvalidDatePart;
|
|
1389
|
+
};
|
|
1185
1390
|
/**
|
|
1186
1391
|
* @hidden
|
|
1187
1392
|
*/
|