2009/6/29 Rob Biedenharn <[email protected]>:
> ...
> This will get everything up to 4:59.  If you want 12:00am (00:00) to
> 4:00am (04:00) inclusive, you want something like
>
> (0...4).include?(current_time.hour) ||
>   (current_time.hour == 4 &&
>    current_time.minute == 0 &&
>    current_time.second == 0)
>
> Note that (x...y).include?(z) is equivalent to:
>   (x <= z && z < y)

That is not correct is it?  I thought the default on a Range is to
include the limits so it would be
x<=z && z<=y
If I am right then you would need (0..3).include? in the above code.

Also in principle you may need to check that microseconds are zero,
though the design of the rest of the app may make this not necessary.
current_time.usec == 0

Colin

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

Reply via email to