Sha256: eae1acb6e455f04ed00de7ac43b3018e8bc75b4627b31901092ff14b6e7bf1a0
Contents?: true
Size: 957 Bytes
Versions: 6
Compression:
Stored size: 957 Bytes
Contents
# See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/api/calendar # frozen_string_literal: true class Pagy # :nodoc: class Calendar # :nodoc: # Calendar month subclass class Month < Calendar DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant format: '%Y-%m' } protected # Setup the calendar variables def setup_unit_vars super @initial = @starting.beginning_of_month @final = @ending.next_month.beginning_of_month @pages = @last = (months_in(@final) - months_in(@initial)) @from = starting_time_for(@page) @to = @from.next_month end # Starting time for the page def starting_time_for(page) @initial + offset_units_for(page).months end private # Number of months in time def months_in(time) (time.year * 12) + time.month end end end end
Version data entries
6 entries across 6 versions & 1 rubygems