@skyux/datetime 6.4.0 → 6.7.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/documentation.json +14 -14
- package/esm2020/lib/modules/datepicker/datepicker-input.directive.mjs +19 -1
- package/esm2020/lib/modules/timepicker/timepicker.directive.mjs +5 -2
- package/fesm2015/skyux-datetime.mjs +22 -1
- package/fesm2015/skyux-datetime.mjs.map +1 -1
- package/fesm2020/skyux-datetime.mjs +22 -1
- package/fesm2020/skyux-datetime.mjs.map +1 -1
- package/package.json +8 -8
@@ -2882,6 +2882,10 @@ class SkyDatepickerInputDirective {
|
|
2882
2882
|
validate(control) {
|
2883
2883
|
if (!this.control) {
|
2884
2884
|
this.control = control;
|
2885
|
+
// Account for any date conversion that may have occurred prior to validation.
|
2886
|
+
if (this.control.value !== this.value) {
|
2887
|
+
this.control.patchValue(this.value, { emitEvent: false });
|
2888
|
+
}
|
2885
2889
|
}
|
2886
2890
|
if (this.skyDatepickerNoValidate) {
|
2887
2891
|
return;
|
@@ -2989,6 +2993,20 @@ class SkyDatepickerInputDirective {
|
|
2989
2993
|
getShortcutOrDateValue(value) {
|
2990
2994
|
const num = Number(value);
|
2991
2995
|
if (Number.isInteger(num)) {
|
2996
|
+
// We require 8 digits in order to know that we have all information needed to determine what part of the number is the month (2), day (2), and year (4).
|
2997
|
+
if (value.length === 8) {
|
2998
|
+
const regex = new RegExp(/\b(MM)\b|\b(DD)\b|\b(YY)\b|\b(YYYY)\b/, 'g');
|
2999
|
+
const formatTokensOnly = this.dateFormat
|
3000
|
+
.match(regex)
|
3001
|
+
.join('')
|
3002
|
+
.replace(new RegExp(/Y+/), 'YYYY');
|
3003
|
+
if (formatTokensOnly.length === 8) {
|
3004
|
+
const date = this.dateFormatter.getDateFromString(value, formatTokensOnly, true);
|
3005
|
+
if (this.dateFormatter.dateIsValid(date)) {
|
3006
|
+
return date;
|
3007
|
+
}
|
3008
|
+
}
|
3009
|
+
}
|
2992
3010
|
const now = new Date();
|
2993
3011
|
const shortcutDate = new Date(now.getFullYear(), now.getMonth(), num);
|
2994
3012
|
const daysInMonth = shortcutDate.getDate();
|
@@ -4576,7 +4594,10 @@ class SkyTimepickerInputDirective {
|
|
4576
4594
|
}
|
4577
4595
|
}
|
4578
4596
|
ngOnDestroy() {
|
4579
|
-
|
4597
|
+
/* istanbul ignore else */
|
4598
|
+
if (this.pickerChangedSubscription) {
|
4599
|
+
this.pickerChangedSubscription.unsubscribe();
|
4600
|
+
}
|
4580
4601
|
}
|
4581
4602
|
ngOnChanges() {
|
4582
4603
|
this.skyTimepickerInput.setFormat(this.timeFormat);
|