Re: TimeRange ''this weekend''

Laughlink
Mon, 19 May 2008 16:36:10 -0000

Thanks alot! This works exactly right. I modified the -2 to -3 to
include Friday. This is actually very close to what I had tried, but I
did not have the parenthesis correct. Too bad I wasted a whole day
before trying the forum.

Best regards,

Kyle

On May 19, 6:24 pm, AndyV
<AndyVana...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> I''m sure Fred will have a better way of attacking this but
something
> like this should work:
>
> [(1.week.from_now.beginning_of_week-2.days).to_date,
> 1.week.from_now.beginning_of_week.to_date]
>
> On May 19, 11:25 am, Laughlink
<m...-Pd2240bJ1K0yaJ3wHwELyQ@public.gmane.org> wrote:
>
> > How would one calculate ''this weekend''?
>
> > In my event model I have:
>
> >   def self.dates_for_time_range(range)
> >     case range
> >       when ''today'' then [Date.today, Date.today]
> >       when ''tomorrow'' then [Date.tomorrow,
Date.tomorrow]
> >       when ''this_week'' then [Date.today,
1.week.from_now.to_date]
> >       else raise ArgumentError, "Incorrect time range:
#{range}"
> >     end
> >   end
>
> > Which works perfectly, but trying to figure out what ''this
weekend''
> > has proven to be a bit more difficult.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com