Skip to content

Commit

Permalink
feat(datepicker): improve manual DateRange input
Browse files Browse the repository at this point in the history
allow the DateRangepicker to ignore missing spaces in manual Input
  • Loading branch information
Berger authored and daniloff200 committed Jan 28, 2021
1 parent 6972d53 commit 1d7adbd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/datepicker/bs-daterangepicker-input.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,20 @@ export class BsDaterangepickerInputDirective
);
}

let _input: (string[] | Date[]) = [];
let _input: (string | Date)[] = [];
if (typeof value === 'string') {
_input = value.split(this._picker._config.rangeSeparator);
const trimmedSeparator = this._picker._config.rangeSeparator.trim();
_input = value
.split(trimmedSeparator.length > 0 ? trimmedSeparator : this._picker._config.rangeSeparator)
.map(_val => _val.trim());
}

if (Array.isArray(value)) {
_input = value;
}

this._value = (_input as string[])
.map((_val: string): Date => {
this._value = _input
.map((_val: string | Date): Date => {
if (this._picker._config.useUtc) {
return utcAsLocal(
parseDate(_val, this._picker._config.rangeInputFormat, this._localeService.currentLocale)
Expand Down

0 comments on commit 1d7adbd

Please sign in to comment.