[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

DateTime yaml bug

Artur Merke

8/27/2007 10:09:00 AM

Hi,

does anybody know a quick fix to the DateTime or Yaml bug

YAML::load(DateTime.now.to_yaml).class
=> Time

Thx

Artur

3 Answers

Artur Merke

8/28/2007 9:26:00 AM

0

On 27 Aug., 12:09, Artur Merke <a...@artbot.de> wrote:
> Hi,
>
> does anybody know a quick fix to the DateTime or Yaml bug
>
> YAML::load(DateTime.now.to_yaml).class
> => Time

Nobody out there to answer the question? The Problem is
not only, that the class switches to Time, but also that
the read in date is wrong by an week (and the time differs too):

> dt= DateTime.now
=> #<DateTime: 21205505265589/8640000,1/12,2299161>

> dt.to_yaml
=> "--- !timestamp 2007-08-28T11:17:35+0200\n"

> res= YAML::load(dt.to_yaml)
=> Mon Aug 20 05:17:35 Westeurop ische Normalzeit 2007

> res.to_yaml
=> "--- 2007-08-20 05:17:35 +02:00\n"

using Marshal

Marshal.load(Marshal.dump(dt))

gives the right solution (both the class and the data in it are
exactly the same), but I really wanted to stick to yaml ...

Artur

Peña, Botp

8/28/2007 10:00:00 AM

0

From: Artur Merke [mailto:am@artbot.de]
# > does anybody know a quick fix to the DateTime or Yaml bug
# >
# > YAML::load(DateTime.now.to_yaml).class
# > => Time

cannot help you, but only say that i can replicate the behaviour here too. someone complained too http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...

i think it's a bug. stick to marshall in the meantime.

kind regards -botp

Eric Hodel

9/9/2007 9:44:00 PM

0

On Aug 27, 2007, at 03:10, Artur Merke wrote:

> does anybody know a quick fix to the DateTime or Yaml bug
>
> YAML::load(DateTime.now.to_yaml).class
> => Time

Please file a bug in the ruby tracker on RubyForge.

Also:

irb(main):003:0> DateTime.parse '3000/01/01 01:01:01'
=> #<DateTime: 243370443661/86400,0,2299161>
irb(main):004:0> dt = _
=> #<DateTime: 243370443661/86400,0,2299161>
irb(main):005:0> YAML.load dt.to_yaml
ArgumentError: time out of range

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars