Sha256: 92b7ca4991925f3b44da354e6218df46e24d0da94448ff4d54b79a36f010cdcc

Contents?: true

Size: 551 Bytes

Versions: 9

Compression:

Stored size: 551 Bytes

Contents

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.5.0 lib/timely/rails/date_time.rb
timely-0.4.2 lib/timely/rails/date_time.rb
timely-0.4.1 lib/timely/rails/date_time.rb
timely-0.4.0 lib/timely/rails/date_time.rb
timely-0.3.4 lib/timely/rails/date_time.rb
timely-0.3.2 lib/timely/rails/date_time.rb
timely-0.3.1 lib/timely/rails/date_time.rb
timely-0.3.0 lib/timely/rails/date_time.rb
timely-0.1.0 lib/timely/rails/date_time.rb