1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'date'

def this_week(today)
  sunday = today - today.wday
  week = [sunday]
  (1..6).each do |wday|
    week << sunday + wday
  end

  return week
end

def last_week(today)
  return this_week(today).map { |elem| elem - 7}
end

puts "This week " + this_week(Time.now).to_s
puts "Last week " + last_week(Time.now).to_s