On Apr 6, 2011, at 11:18 AM, Robert Pankowecki wrote:

> ruby-1.9.2-p136 :080 > Rails.version
> "3.0.6"
> 
> ruby-1.9.2-p136 :081 > (Date.today - Date.today).class
> Rational < Numeric
> 
> Why is the difference Rational ?

This is actually a feature of the built-in date library; I get the same result 
on 1.8 in vanilla irb (after doing "require 'date'"). It's intended (AFAIK) to 
enable sensible operations between Date and DateTime objects, since subtracting 
Dates gives a value which should be read as "number of days" and DateTimes can 
mix fractions in:

require 'date'
d = Date.civil(2011,4,6)
d2 = DateTime.civil(2011,4,6,12,0,0)

d2 - d # returns Rational(1,2) - in other words, "half a day" since the docs 
say Date objects are considered to have a time of midnight

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to