Historical Question about ActiveSupport::Duration objects

Trek
Wed, 19 Mar 2008 20:44:06 -0000

Hey all,

I was wondering what decision led to the cut off point in
ActiveSupport::Duration where a duration''s switches from listing the
tracking itself by its own time unit value (year, month, day) and
switches to seconds (hour, minutes, and seconds)
e.g.

1.year + 2.months
# => 1 year and 2 months

>> 1.year + 2.months + 4.days
#=> 1 year, 2 months, and 4 days

But
4.days + 3.hours
#=> 4 days and 10800 seconds
(I''d expect ''4 days and 3 hours'')

4.days + 3.hours + 12.minutes
#=> 4 days and 11520 seconds
(I''d expect ''4 days, 3 hours, and 12 minutes)

I can see from ActiveSupport::CoreExtensions::Numeric::Time that hours
and minutes define themselves in terms of seconds, but was wondering
if anyone could shed light on why this organized this way.


--~--~---------~--~----~------------~-------~--~----~
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-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---