@@ -220,42 +220,44 @@ describe('json', function() {
220
220
} ) ;
221
221
222
222
223
- it ( 'should read/write to date' , function ( ) {
224
- var date = new Date ( 'Sep 10 2003 13:02:03 GMT' ) ;
225
- expect ( jsonDateToString ( date ) ) . toBe ( '2003-09-10T13:02:03.000Z' ) ;
226
- expect ( jsonStringToDate ( jsonDateToString ( date ) ) . getTime ( ) ) . toBe ( date . getTime ( ) ) ;
227
- } ) ;
223
+ describe ( 'iso 8061 date' , function ( ) {
224
+ it ( 'should read/write to date' , function ( ) {
225
+ var date = new Date ( 'Sep 10 2003 13:02:03 GMT' ) ;
226
+ expect ( jsonDateToString ( date ) ) . toBe ( '2003-09-10T13:02:03.000Z' ) ;
227
+ expect ( jsonStringToDate ( jsonDateToString ( date ) ) . getTime ( ) ) . toBe ( date . getTime ( ) ) ;
228
+ } ) ;
228
229
229
230
230
- it ( 'should convert to date' , function ( ) {
231
- //full ISO8061
232
- expect ( jsonStringToDate ( '2003-09-10T13:02:03.000Z' ) ) .
233
- toEqual ( new Date ( 'Sep 10 2003 13:02:03 GMT' ) ) ;
231
+ it ( 'should convert to date' , function ( ) {
232
+ //full ISO8061
233
+ expect ( jsonStringToDate ( '2003-09-10T13:02:03.000Z' ) ) . toEqual ( new Date ( 'Sep 10 2003 13:02:03 GMT' ) ) ;
234
234
235
- //no millis
236
- expect ( jsonStringToDate ( '2003-09-10T13:02:03Z' ) ) .
237
- toEqual ( new Date ( 'Sep 10 2003 13:02:03 GMT' ) ) ;
235
+ expect ( jsonStringToDate ( '2003-09-10T13:02:03.000+00:00' ) ) . toEqual ( new Date ( 'Sep 10 2003 13:02:03 GMT' ) ) ;
238
236
239
- //no seconds
240
- expect ( jsonStringToDate ( '2003-09-10T13:02Z' ) ) .
241
- toEqual ( new Date ( 'Sep 10 2003 13:02:00 GMT' ) ) ;
237
+ expect ( jsonStringToDate ( '20030910T033203-0930' ) ) . toEqual ( new Date ( 'Sep 10 2003 13:02:03 GMT' ) ) ;
242
238
243
- //no minutes
244
- expect ( jsonStringToDate ( '2003-09-10T13Z' ) ) .
245
- toEqual ( new Date ( 'Sep 10 2003 13:00:00 GMT' ) ) ;
239
+ //no millis
240
+ expect ( jsonStringToDate ( '2003-09-10T13:02:03Z' ) ) . toEqual ( new Date ( 'Sep 10 2003 13:02:03 GMT' ) ) ;
246
241
247
- //no time
248
- expect ( jsonStringToDate ( '2003-09-10' ) ) .
249
- toEqual ( new Date ( 'Sep 10 2003 00:00:00 GMT' ) ) ;
250
- } ) ;
242
+ //no seconds
243
+ expect ( jsonStringToDate ( '2003-09-10T13:02Z' ) ) . toEqual ( new Date ( 'Sep 10 2003 13:02:00 GMT' ) ) ;
251
244
245
+ //no minutes
246
+ expect ( jsonStringToDate ( '2003-09-10T13Z' ) ) . toEqual ( new Date ( 'Sep 10 2003 13:00:00 GMT' ) ) ;
252
247
253
- it ( 'should parse date' , function ( ) {
254
- var date = jsonStringToDate ( '2003-09-10T13:02:03.000Z' ) ;
255
- expect ( jsonDateToString ( date ) ) . toBe ( '2003-09-10T13:02:03.000Z' ) ;
256
- expect ( jsonStringToDate ( 'str' ) ) . toBe ( 'str' ) ;
257
- } ) ;
248
+ //no time
249
+ expect ( jsonStringToDate ( '2003-09-10' ) ) . toEqual ( new Date ( 'Sep 10 2003 00:00:00 GMT' ) ) ;
258
250
251
+ expect ( jsonStringToDate ( '2011-12-28T13:02:09-08:00' ) ) . toEqual ( new Date ( 'Dec 28 2011 21:02:09 GMT' ) ) ;
252
+ } ) ;
253
+
254
+
255
+ it ( 'should parse date' , function ( ) {
256
+ var date = jsonStringToDate ( '2003-09-10T13:02:03.000Z' ) ;
257
+ expect ( jsonDateToString ( date ) ) . toBe ( '2003-09-10T13:02:03.000Z' ) ;
258
+ expect ( jsonStringToDate ( 'str' ) ) . toBe ( 'str' ) ;
259
+ } ) ;
260
+ } ) ;
259
261
260
262
describe ( 'string' , function ( ) {
261
263
it ( 'should quote' , function ( ) {
0 commit comments