If you look at the classes returned, Date.new.to_time returns a DateTime,  
while Date.today.to_time returns a Time

Date.new.to_time.class --> DateTime
Date.today.to_time.class --> Time

Not sure why that is the case, but obviously DateTime doesn't have a to_i  
method.

Simon

On Fri, 19 Jun 2009 07:37:21 +0800, Michael Economy  
<[email protected]> wrote:

>
> What's going on here!?
>
>>> Date.new.to_time.to_i
> NoMethodError: undefined method `to_i' for Mon, 01 Jan -4712 00:00:00
> -0800:DateTime
>   from (irb):25
>>> Date.today.to_time.to_i
> => 1245308400
>
>
>
>
>
>>> RUBY_VERSION
> => "1.8.7"
>>> Rails.version
> => "2.1.1"
>
>
> (I'm not sure if this is a rails thing, or just a ruby thing)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to