Sha256: 698542064c9a193a42a465e914656f2342e3f256a78c407b96cc8bea74c8e535

Contents?: true

Size: 349 Bytes

Versions: 41

Compression:

Stored size: 349 Bytes

Contents

module DateAndTime
  module Calculations
    # Polyfill, already implemented on Rails 5.2
    # https://api.rubyonrails.org/classes/DateAndTime/Calculations.html#method-i-prev_occurring
    def prev_occurring(day_of_week)
      ago = wday - DAYS_INTO_WEEK.fetch(day_of_week)
      ago += 7 unless ago > 0
      advance(days: -ago)
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
mumuki-laboratory-9.23.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.22.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.21.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.20.1 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.20.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.19.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.18.1 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.18.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.17.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.16.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.15.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.14.1 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.14.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.13.2 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.13.1 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.13.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.12.1 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.12.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.11.0 lib/mumuki/laboratory/extensions/date_and_time.rb
mumuki-laboratory-9.10.0 lib/mumuki/laboratory/extensions/date_and_time.rb