From d7079395d8f8beb302e74aefed723063478c22ed Mon Sep 17 00:00:00 2001 From: Iwein Fuld Date: Thu, 30 Aug 2012 06:39:52 +0200 Subject: [PATCH] Makes the time zone optional in the date filter Problem with the current R_ISO8601_STR regex was that the time was optional, but the zone was not. This results in the filter not formatting local date times, which it could easily do. For example: 2012-08-30 -> formatted 2012-08-30T06:06:06.123Z -> formatted 2012-08-30T06:06:06.123 -> NOT formatted A simple change in the regex fixes this. Arguably this is closer to the ISO8601 spec which specifies local dates being in the "current time zone" and not requiring a Z. In any case it behaves more like a user would expect. --- src/ng/filter/filters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/filter/filters.js b/src/ng/filter/filters.js index c56210f67b0d..af29c75a6f2d 100644 --- a/src/ng/filter/filters.js +++ b/src/ng/filter/filters.js @@ -320,7 +320,7 @@ dateFilter.$inject = ['$locale']; function dateFilter($locale) { - var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/; + var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; function jsonStringToDate(string){ var match; if (match = string.match(R_ISO8601_STR)) {