Skip to content

Commit

Permalink
feat(module:datepicker): support string and number type as value (#593)
Browse files Browse the repository at this point in the history
change NzDatePipe to support display string type in valid ISO 8601 
format (eg: '2013-02-08 09:30:26.123') and number type (eg: 
timestamp-'123456789') .

修改了NzDatePipe从而支持显示输入的ISO 8601时间格式的字符串类型(如: “2013-02-08 09:30:26.123”)和数字类型(如:时间戳-“123456789”)。
  • Loading branch information
JuniorTour authored and vthinkxie committed Nov 26, 2017
1 parent 9385826 commit aee7abe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/util/nz-date.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import * as moment from 'moment';

@Pipe({ name: 'nzDate' })
export class NzDatePipe implements PipeTransform {
transform(value: Date, formatString: string): string {
if (value) {
return moment(+value).format(formatString);
transform(value: Date | number | string, formatString: string): string {
if (moment(value).isValid()) {
return moment(value).format(formatString);
} else {
return '';
return 'Invalid Date';
}
}
}

0 comments on commit aee7abe

Please sign in to comment.