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