Class: Date

Inherits:
Object
  • Object
show all
Defined in:
lib/harvest_submit.rb

Class Method Summary collapse

Class Method Details

.nearest_sundayObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/harvest_submit.rb', line 13

def self.nearest_sunday
  date = Date.today
  wday = date.wday
  if wday >= 4
    wday.upto(6) do
      date = 1.day.after(date)
    end
  elsif wday <= 3
    wday.downto(1) do
      date = 1.day.before(date)
    end
  end
  return date
end