aboutsummaryrefslogtreecommitdiffstats
path: root/test/JsonSpec.js
diff options
context:
space:
mode:
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() {