From: "list. rb" Date: 2009-01-17T23:15:24+09:00 Subject: Re: Time Compare --000e0cd151de819b8e0460ae56dd Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit now = Time.now yesterday=now-1.day tomorrow=now+1.day is_between = true if now > yesterday and now < tomorrow So.. you want to know if On Sat, Jan 17, 2009 at 8:32 AM, badboy wrote: > Cyrus Dev schrieb: > >> Hello all >> >> is there any direct comparison function in ruby or in rails for time >> >> I need a function which compare current time is between 2 time objects >> or not >> >> ... >> >> Please help me >> >> thanks in advance >> > my first solution would be to put the three time objects in an Array: > now = Time.now > timebefore = now - 30*60*60 > timeafter = now + 30*60*60 > timearray = [now, timebefore, timeafter] > and after that using > timearray.sort > to sort them. If now is between the two dates if should be on position 1 > > > > --000e0cd151de819b8e0460ae56dd--