@skyux/datetime 6.3.3 → 6.6.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.
@@ -2989,6 +2989,20 @@ class SkyDatepickerInputDirective {
2989
2989
  getShortcutOrDateValue(value) {
2990
2990
  const num = Number(value);
2991
2991
  if (Number.isInteger(num)) {
2992
+ // 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).
2993
+ if (value.length === 8) {
2994
+ const regex = new RegExp(/\b(MM)\b|\b(DD)\b|\b(YY)\b|\b(YYYY)\b/, 'g');
2995
+ const formatTokensOnly = this.dateFormat
2996
+ .match(regex)
2997
+ .join('')
2998
+ .replace(new RegExp(/Y+/), 'YYYY');
2999
+ if (formatTokensOnly.length === 8) {
3000
+ const date = this.dateFormatter.getDateFromString(value, formatTokensOnly, true);
3001
+ if (this.dateFormatter.dateIsValid(date)) {
3002
+ return date;
3003
+ }
3004
+ }
3005
+ }
2992
3006
  const now = new Date();
2993
3007
  const shortcutDate = new Date(now.getFullYear(), now.getMonth(), num);
2994
3008
  const daysInMonth = shortcutDate.getDate();
@@ -4576,7 +4590,10 @@ class SkyTimepickerInputDirective {
4576
4590
  }
4577
4591
  }
4578
4592
  ngOnDestroy() {
4579
- this.pickerChangedSubscription.unsubscribe();
4593
+ /* istanbul ignore else */
4594
+ if (this.pickerChangedSubscription) {
4595
+ this.pickerChangedSubscription.unsubscribe();
4596
+ }
4580
4597
  }
4581
4598
  ngOnChanges() {
4582
4599
  this.skyTimepickerInput.setFormat(this.timeFormat);