On Jun 27, 2009, at 9:08 PM, Jason Burgett wrote: > Ok, the real calculation I'm trying to do is between 12:00am and > 4:00am > > cuurent_time = Time.now > > (current_time.hour > 0) and (current_time.hour <= 4) > > If the current time is 00:17:24... > > Duh, just figure out my error. I was doing that but didn't have > current_time >= 0, I had current_time > 0. > > Thanks for the help.
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) -Rob Rob Biedenharn http://agileconsultingllc.com r...@agileconsultingllc.com > Robby Russell wrote: >> current_time = Time.now >> >> (current_time.hour >= 17) and (current_time.hour <= 21) >> >> => true >> >> On Sat, Jun 27, 2009 at 5:30 PM, Jason >> Burgett<rails-mailing-l...@andreas-s.net> wrote: >>> between two times. For example, is "t" between 5:00 PM and 9:00 PM. >>> -- >>> Posted via http://www.ruby-forum.com/. >> >> -- >> Robby Russell >> Chief Evangelist, Partner >> >> PLANET ARGON, LLC >> design // development // hosting w/Ruby on Rails >> >> http://planetargon.com/ >> http://robbyonrails.com/ >> http://twitter.com/planetargon >> aim: planetargon >> >> +1 503 445 2457 >> +1 877 55 ARGON [toll free] >> +1 815 642 4068 [fax] --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---