Sha256: 11d50b635e457d26fa1664d0a9d47c0aadcc95c295011951ccd9935a014016d1

Contents?: true

Size: 641 Bytes

Versions: 3

Compression:

Stored size: 641 Bytes

Contents

require 'time'

module DateHelper

  def yesterday
    Time.now - seconds_per_day
  end

  def tomorrow
    Time.now + seconds_per_day
  end

  def today
    Time.parse Time.now.strftime("%Y-%m-%d 00:00:00 -0300")
  end

  def now
    Time.now
  end

  def next_hour
    Time.now + seconds_per_hour
  end

  def next_month
    Time.now + seconds_per_month
  end

  def next_year
    Time.new + seconds_per_year
  end

  private

  def seconds_per_hour
    60 * 60
  end

  def seconds_per_day
    seconds_per_hour * 24
  end

  def seconds_per_month
    seconds_per_day * 31
  end

  def seconds_per_year
    seconds_per_day * 365
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_wrapper-1.1.2 spec/support/helpers/date_helper.rb
git_wrapper-1.1.1 spec/support/helpers/date_helper.rb
git_wrapper-1.1.0 spec/support/helpers/date_helper.rb