JSON DateTime Parsing Helpers
Reported by Matt Todd | March 26th, 2008 @ 10:01 PM | in Release 0.5.0
There should be a way to handle parsing a variety of Date/Time formats (strings) into actual Date/Time objects, and also a way to generate these formats (possibly allowing for customization).
For example:
Time.now.to_s(:json) #=> "2008-03-26 11:56:32 -0500"
Time.now.to_s(:json, :utc) #=> "2008-03-27T16:56:58Z"
"2008-03-27T16:56:58Z".to_date(:json) #=> #<Date:0x12a2d20>
Consider this for contribution to the Merb framework as well.
Comments and changes to this ticket
-
Matt Todd March 26th, 2008 @ 10:04 PM
- Milestone changed from Release 0.4.0 to Release 0.5.0
- State changed from new to open
Filed under Release 0.5.0.
-
Matt Todd March 26th, 2008 @ 10:53 PM
Officially (or possibly unofficially), ISO 8601 Dates will be the default format for JSON 2's spec.
See: http://www.json.org/json2.js
Also: http://pastie.org/171357 which is how ActiveSupport automatically parses it.
-
Matt Todd March 26th, 2008 @ 10:54 PM
http://dev.rubyonrails.org/brows...
This is how ActiveSupport parses JSON (via YAML). Nasty but it works.
-
Matt Todd March 30th, 2008 @ 11:49 PM
- State changed from open to resolved
This issue may be resolved by the contributions planned for Merb.
http://merb.lighthouseapp.com/pr...
This just resolves Time#to_json rendering as ISO 8601 text; there's another contribution planned to make JSON.parse to convert text matching the ISO 8601 compatible strings to Time objects.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป