Wednesday, December 22, 2010

[Rails] Re: Duration

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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate