TimeRange ''this weekend''

Laughlink
Mon, 19 May 2008 15:25:46 -0000

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.