Sha256: 5eaafc7c8c50fe1da40a66368117cd3c6d50ff6ce010f49a8283eef98ed49d4c

Contents?: true

Size: 573 Bytes

Versions: 9

Compression:

Stored size: 573 Bytes

Contents

# frozen_string_literal: true

module RailsCoreExtensions
  module DateTime
    def advance_considering_calendar(units, num_units)
      case units
      when :seconds, :minutes, :hours, :days, :weeks, :months, :years
        advance(units => num_units)
      when :calendar_days
        advance(days: num_units - 1).end_of_day
      when :calendar_months
        advance(months: num_units - 1).end_of_month
      when :calendar_years
        advance(years: num_units - 1).end_of_year
      end
    end
  end
end

class DateTime
  include RailsCoreExtensions::DateTime
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
timely-0.14.0 lib/timely/rails/date_time.rb
timely-0.13.0 lib/timely/rails/date_time.rb
timely-0.12.0 lib/timely/rails/date_time.rb
timely-0.11.0 lib/timely/rails/date_time.rb
timely-0.10.0 lib/timely/rails/date_time.rb
timely-0.9.0 lib/timely/rails/date_time.rb
timely-0.8.0 lib/timely/rails/date_time.rb
timely-0.7.0 lib/timely/rails/date_time.rb
timely-0.6.0 lib/timely/rails/date_time.rb