Skip to content

Commit

Permalink
fix(datepicker): fix invalid input on empty input (#10)
Browse files Browse the repository at this point in the history
closes issue #9
  • Loading branch information
kyubisation authored May 27, 2019
1 parent edb7654 commit 0368615
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { SBB_INPUT_VALUE_ACCESSOR } from '../../input/input-value-accessor';
import { DateAdapter } from '../date-adapter';
import { DateFormats, SBB_DATE_FORMATS } from '../date-formats';
import { createMissingDateImplError } from '../datepicker-errors';
import { SBB_DATEPICKER } from '../datepicker-token';
import { DatepickerComponent } from '../datepicker/datepicker.component';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class NativeDateAdapter extends DateAdapter<Date> {
return date;
}

parse(value: any): Date {
parse(value: any): Date | null {
if (typeof value === 'number') {
return new Date(value);
} else if (this.isDateInstance(value)) {
Expand All @@ -133,7 +133,7 @@ export class NativeDateAdapter extends DateAdapter<Date> {
const match = /^(\w+,[ ]?)?(\d+)\.(\d+)\.(\d+)$/.exec(value);
return match
? new Date(+match[4], +match[3] - 1, +match[2], 0, 0, 0)
: new Date(NaN);
: null;
}
return null;
}
Expand Down

0 comments on commit 0368615

Please sign in to comment.