From fc9ce9ec075aa21cdf6a79987e4aa152991f6a44 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 8 Nov 2010 10:51:28 -0800 Subject: make angular.String.toDate consider all time fractions as optional --- test/ApiSpecs.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') diff --git a/test/ApiSpecs.js b/test/ApiSpecs.js index 344cf5da..81fd9155 100644 --- a/test/ApiSpecs.js +++ b/test/ApiSpecs.js @@ -190,8 +190,25 @@ describe('api', function(){ }); it('UTCtoDate', function(){ + //full ISO8061 expect(angular.String.toDate("2003-09-10T13:02:03.000Z")). toEqual(new Date("Sep 10 2003 13:02:03 GMT")); + + //no millis + expect(angular.String.toDate("2003-09-10T13:02:03Z")). + toEqual(new Date("Sep 10 2003 13:02:03 GMT")); + + //no seconds + expect(angular.String.toDate("2003-09-10T13:02Z")). + toEqual(new Date("Sep 10 2003 13:02:00 GMT")); + + //no minutes + expect(angular.String.toDate("2003-09-10T13Z")). + toEqual(new Date("Sep 10 2003 13:00:00 GMT")); + + //no time + expect(angular.String.toDate("2003-09-10")). + toEqual(new Date("Sep 10 2003 00:00:00 GMT")); }); it('StringFromUTC', function(){ -- cgit v1.2.3