Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wonder if looking up the source is really necessary. I did some tests with Rails console just now. It seems that Ruby and Rails are handling the case quite logically.

"3.days.ago" at least by default is a TimeWithZone object in Rails.

  3.days.ago.class
   => ActiveSupport::TimeWithZone
And then the way Ruby iterates Range is through the "succ" method. So even this will give you a wall of errors:

  (3.days.ago..2.days.ago).to_a
Sending "succ" to a TimeWithZone object will print a warning because the method is deprecated. So basically a warning will show for every second in the range.

Calling .include? should be equivalent to .to_a.include? in effect.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: