Sha256: 04d331c4933144a953ab7165508ecf078d376c7bf5cbd951ab714e97daf4e079

Contents?: true

Size: 871 Bytes

Versions: 17

Compression:

Stored size: 871 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 day subclass
    class Day < Calendar
      DEFAULT = { order:  :asc,      # rubocop:disable Style/MutableConstant
                  format: '%Y-%m-%d' }

      protected

      # Setup the calendar variables
      def setup_unit_vars
        super
        @initial = new_time(@starting.year, @starting.month, @starting.day)
        @final   = new_time(@ending.year, @ending.month, @ending.day) + DAY
        @pages   = @last = (@final - @initial).to_i / DAY
        @from    = starting_time_for(@page)
        @to      = @from + DAY
      end

      # Starting time for the page
      def starting_time_for(page)
        @initial + (offset_units_for(page) * DAY)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pagy-5.8.1 lib/pagy/calendar/day.rb
pagy-5.8.0 lib/pagy/calendar/day.rb
pagy-5.7.6 lib/pagy/calendar/day.rb
pagy-5.7.5 lib/pagy/calendar/day.rb
pagy-5.7.4 lib/pagy/calendar/day.rb
pagy-5.7.3 lib/pagy/calendar/day.rb
pagy-5.7.2 lib/pagy/calendar/day.rb
pagy-5.7.1 lib/pagy/calendar/day.rb
pagy-5.7.0 lib/pagy/calendar/day.rb
pagy-5.6.10 lib/pagy/calendar/day.rb
pagy-5.6.9 lib/pagy/calendar/day.rb
pagy-5.6.8 lib/pagy/calendar/day.rb
pagy-5.6.7 lib/pagy/calendar/day.rb
pagy-5.6.6 lib/pagy/calendar/day.rb
pagy-5.6.5 lib/pagy/calendar/day.rb
pagy-5.6.4 lib/pagy/calendar/day.rb
pagy-5.6.3 lib/pagy/calendar/day.rb