Re: Duration

Peter Vandenabeele
Wed, 22 Dec 2010 21:11:42 -0000

Frederick Cheung wrote in post #970025:
> a Duration object doesn''t have days (or seconds etc.) methods that
> return the invidual components (the parts method does that)

Many thanks. I found that very useful to understand the behaviour.

$ rails c
Loading development environment (Rails 3.0.3)
001:0> a_long_time = 1.year + 2.months + 3.weeks + 4.days + 5.hours +
6.minutes + 7.seconds
=> 1 year, 2 months, 25 days, and 18367 seconds
002:0> a_long_time.parts
=> [[:years, 1], [:months, 2], [:days, 21], [:days, 4], [:seconds,
18000], [:seconds, 360], [:seconds, 7]]

Peter

--
Posted via http://www.ruby-forum.com/.

--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org