From a3976455379cef41345a04bc91cfcf6d848aa609 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sat, 6 Nov 2010 23:40:44 -0700 Subject: date filter should accept ISO 8601 formatted string as input Closes #125 --- src/filters.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/filters.js') diff --git a/src/filters.js b/src/filters.js index 14d0dff8..2dde740c 100644 --- a/src/filters.js +++ b/src/filters.js @@ -168,7 +168,8 @@ var NUMBER_STRING = /^\d+$/; * * `'a'`: am/pm marker * * `'Z'`: 4 digit (+sign) representation of the timezone offset (-1200‒1200) * - * @param {(Date|number|string)} date Date to format either as Date object or milliseconds. + * @param {(Date|number|string)} date Date to format either as Date object, milliseconds (string or + * number) or ISO 8601 string (yyyy-MM-ddTHH:mm:ssZ). * @param {string=} format Formatting rules. If not specified, Date#toLocaleDateString is used. * @returns {string} Formatted string or the input if input is not recognized as date/millis. * @@ -188,8 +189,12 @@ var NUMBER_STRING = /^\d+$/; * */ angularFilter.date = function(date, format) { - if (isString(date) && NUMBER_STRING.test(date)) { - date = parseInt(date, 10); + if (isString(date)) { + if (NUMBER_STRING.test(date)) { + date = parseInt(date, 10); + } else { + date = angularString.toDate(date); + } } if (isNumber(date)) { -- cgit v1.2.3