aboutsummaryrefslogtreecommitdiffstats
path: root/test/JsonSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2012-03-16 11:28:32 -0700
committerMisko Hevery2012-03-19 11:41:10 -0700
commit5ac14f633a69f49973b5512780c6ec7752405967 (patch)
tree7c144a79fedbea68d6b28c22d3f87aa3b0297404 /test/JsonSpec.js
parent9918b748be01266eb10db39d51b4d3098d54ab66 (diff)
downloadangular.js-5ac14f633a69f49973b5512780c6ec7752405967.tar.bz2
fix(json): added support for iso8061 timezone
Added support of timezone in dates not just zulu timezone. This fixes issues for date filter which uses json deserialization under the hood. (for now) Closes #/800
Diffstat (limited to 'test/JsonSpec.js')
-rw-r--r--test/JsonSpec.js56
1 files changed, 29 insertions, 27 deletions
diff --git a/test/JsonSpec.js b/test/JsonSpec.js
index df1e428a..e4abeef9 100644
--- a/test/JsonSpec.js
+++ b/test/JsonSpec.js
@@ -220,42 +220,44 @@ describe('json', function() {
});
- it('should read/write to date', function() {
- var date = new Date('Sep 10 2003 13:02:03 GMT');
- expect(jsonDateToString(date)).toBe('2003-09-10T13:02:03.000Z');
- expect(jsonStringToDate(jsonDateToString(date)).getTime()).toBe(date.getTime());
- });
+ describe('iso 8061 date', function() {
+ it('should read/write to date', function() {
+ var date = new Date('Sep 10 2003 13:02:03 GMT');
+ expect(jsonDateToString(date)).toBe('2003-09-10T13:02:03.000Z');
+ expect(jsonStringToDate(jsonDateToString(date)).getTime()).toBe(date.getTime());
+ });
- it('should convert to date', function() {
- //full ISO8061
- expect(jsonStringToDate('2003-09-10T13:02:03.000Z')).
- toEqual(new Date('Sep 10 2003 13:02:03 GMT'));
+ it('should convert to date', function() {
+ //full ISO8061
+ expect(jsonStringToDate('2003-09-10T13:02:03.000Z')).toEqual(new Date('Sep 10 2003 13:02:03 GMT'));
- //no millis
- expect(jsonStringToDate('2003-09-10T13:02:03Z')).
- toEqual(new Date('Sep 10 2003 13:02:03 GMT'));
+ expect(jsonStringToDate('2003-09-10T13:02:03.000+00:00')).toEqual(new Date('Sep 10 2003 13:02:03 GMT'));
- //no seconds
- expect(jsonStringToDate('2003-09-10T13:02Z')).
- toEqual(new Date('Sep 10 2003 13:02:00 GMT'));
+ expect(jsonStringToDate('20030910T033203-0930')).toEqual(new Date('Sep 10 2003 13:02:03 GMT'));
- //no minutes
- expect(jsonStringToDate('2003-09-10T13Z')).
- toEqual(new Date('Sep 10 2003 13:00:00 GMT'));
+ //no millis
+ expect(jsonStringToDate('2003-09-10T13:02:03Z')).toEqual(new Date('Sep 10 2003 13:02:03 GMT'));
- //no time
- expect(jsonStringToDate('2003-09-10')).
- toEqual(new Date('Sep 10 2003 00:00:00 GMT'));
- });
+ //no seconds
+ expect(jsonStringToDate('2003-09-10T13:02Z')).toEqual(new Date('Sep 10 2003 13:02:00 GMT'));
+ //no minutes
+ expect(jsonStringToDate('2003-09-10T13Z')).toEqual(new Date('Sep 10 2003 13:00:00 GMT'));
- it('should parse date', function() {
- var date = jsonStringToDate('2003-09-10T13:02:03.000Z');
- expect(jsonDateToString(date)).toBe('2003-09-10T13:02:03.000Z');
- expect(jsonStringToDate('str')).toBe('str');
- });
+ //no time
+ expect(jsonStringToDate('2003-09-10')).toEqual(new Date('Sep 10 2003 00:00:00 GMT'));
+ expect(jsonStringToDate('2011-12-28T13:02:09-08:00')).toEqual(new Date('Dec 28 2011 21:02:09 GMT'));
+ });
+
+
+ it('should parse date', function() {
+ var date = jsonStringToDate('2003-09-10T13:02:03.000Z');
+ expect(jsonDateToString(date)).toBe('2003-09-10T13:02:03.000Z');
+ expect(jsonStringToDate('str')).toBe('str');
+ });
+ });
describe('string', function() {
it('should quote', function() {