yaml and dates

S

Shadowfirebird

It's turning out to be very difficult to come up with a reliable
example, but I'm having problems with dates in yaml. Sometimes they
turn up in Ruby as dates, sometimes as strings.

Is anyone else having this problem?

--
 
S

Shadowfirebird

This might be it. Understandable but annoying:


irb(main):001:0> require 'date'
=> true
irb(main):004:0> require 'yaml'
=> true
irb(main):010:0> a = "2008-08-10"
=> "2008-08-10"
irb(main):011:0> y = YAML::load(a)
=> #<Date: 4909377/2,0,2299161>
irb(main):012:0> a = "2008-8-10"
=> "2008-8-10"
irb(main):013:0> y = YAML::load(a)
=> "2008-8-10"

Annoying because Date.parse("2008-8-10") would be fine.

Can anyone suggest an elegant way to upgrade YAML::load()?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,055
Members
47,659
Latest member
salragu

Latest Threads

Top