Sha256: ec28236241b9cee9137e2668260efee8ee05e3066a1d953e12ba43604aef41a4

Contents?: true

Size: 516 Bytes

Versions: 2

Compression:

Stored size: 516 Bytes

Contents

require 'date'

module RujitsuDate
  def start_of_this_month
    today = self.today
    self.new(today.year, today.month)
  end

  def start_of_last_month
    today = self.today
    if today.month == 1
      self.new(today.year - 1, 12)
    else
      self.new(today.year, today.month - 1)
    end
  end

  def start_of_next_month
    today = self.today
    if today.month < 12
      self.new(today.year, today.month + 1)
    else
      self.new(today.year + 1, 1)
    end
  end
end

Date.send(:extend, RujitsuDate)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rujitsu-0.5.0 lib/rujitsu/date.rb
rujitsu-0.4.0 lib/rujitsu/date.rb