[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

yaml and dates

Shadowfirebird

8/14/2008 8:43:00 PM

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?

--

1 Answer

Shadowfirebird

8/14/2008 8:49:00 PM

0

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()?