From 712c7d5c3bd4086861f6d0fa1ccae16f7e681c92 Mon Sep 17 00:00:00 2001 From: Andrei Tserakhau Date: Sun, 14 Aug 2016 21:05:21 +0400 Subject: [PATCH] fix(datePipe): allow float for date pipe input (#10687) --- modules/@angular/common/src/pipes/date_pipe.ts | 2 +- modules/@angular/common/test/pipes/date_pipe_spec.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/@angular/common/src/pipes/date_pipe.ts b/modules/@angular/common/src/pipes/date_pipe.ts index bac0f10875..68bf023591 100644 --- a/modules/@angular/common/src/pipes/date_pipe.ts +++ b/modules/@angular/common/src/pipes/date_pipe.ts @@ -104,7 +104,7 @@ export class DatePipe implements PipeTransform { } if (NumberWrapper.isNumeric(value)) { - value = DateWrapper.fromMillis(NumberWrapper.parseInt(value, 10)); + value = DateWrapper.fromMillis(parseFloat(value)); } else if (isString(value)) { value = DateWrapper.fromISOString(value); } diff --git a/modules/@angular/common/test/pipes/date_pipe_spec.ts b/modules/@angular/common/test/pipes/date_pipe_spec.ts index dd9e889eae..e45dede9ae 100644 --- a/modules/@angular/common/test/pipes/date_pipe_spec.ts +++ b/modules/@angular/common/test/pipes/date_pipe_spec.ts @@ -36,6 +36,9 @@ export function main() { it('should support numeric strings', () => { expect(() => pipe.transform('123456789')).not.toThrow(); }); + it('should support decimal strings', + () => { expect(() => pipe.transform('123456789.11')).not.toThrow(); }); + it('should support ISO string', () => { expect(() => pipe.transform('2015-06-15T21:43:11Z')).not.toThrow(); });