Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

JSON DateTime Parsing Helpers

#19

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.

Reported by Matt Todd · March 26th, 2008 @ 10:01 PM

State: resolved
Milestone: Release 0.5.0
Assigned to: Matt Todd Matt Todd

Activity

  1. Matt Todd
    Matt Todd
    • Milestone changed from Release 0.4.0 to Release 0.5.0
    • State changed from new to open

    Filed under Release 0.5.0.

    March 26th, 2008 @ 10:04 PM

  2. Matt Todd
    Matt Todd

    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.

    March 26th, 2008 @ 10:53 PM

  3. Matt Todd
    Matt Todd

    http://dev.rubyonrails.org/brows...

    This is how ActiveSupport parses JSON (via YAML). Nasty but it works.

    March 26th, 2008 @ 10:54 PM

  4. Matt Todd
    Matt Todd
    • 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.

    March 30th, 2008 @ 11:49 PM

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.