Skip to content

Commit

Permalink
fix(module:time-picker): add null input judgement when using datefns (#…
Browse files Browse the repository at this point in the history
…4283)

close #3854
  • Loading branch information
wenqi73 authored and vthinkxie committed Oct 14, 2019
1 parent 4b90577 commit a05bc02
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/i18n/date-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export class DateHelperByDateFns extends DateHelperService {
* @param date Date
* @param formatStr format string
*/
format(date: Date, formatStr: string): string {
return fnsFormat(date, formatStr, { locale: this.i18n.getDateLocale() });
format(date: Date | null, formatStr: string): string {
return date ? fnsFormat(date, formatStr, { locale: this.i18n.getDateLocale() }) : '';
}
}

Expand All @@ -103,7 +103,7 @@ export class DateHelperByDatePipe extends DateHelperService {
return this.config.firstDayOfWeek;
}

format(date: Date, formatStr: string): string {
format(date: Date | null, formatStr: string): string {
return date ? formatDate(date, formatStr, this.i18n.getLocaleId())! : '';
}

Expand Down

0 comments on commit a05bc02

Please sign in to comment.