module DateAndTime::Calculations
Public Instance Methods
prev_occurring(day_of_week)
click to toggle source
Polyfill, already implemented on Rails 5.2 api.rubyonrails.org/classes/DateAndTime/Calculations.html#method-i-prev_occurring
# File lib/mumuki/laboratory/extensions/date_and_time.rb, line 5 def prev_occurring(day_of_week) ago = wday - DAYS_INTO_WEEK.fetch(day_of_week) ago += 7 unless ago > 0 advance(days: -ago) end