@skyux/datetime 6.5.0 → 6.8.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.
@@ -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();