Sha256: bc0aa27b0b9bc18be5c77ec5526aaaab7d86a6164bd4f4ec7a722cf2bebee9fa

Contents?: true

Size: 668 Bytes

Versions: 1

Compression:

Stored size: 668 Bytes

Contents

require 'active_support'
require 'active_support/time'

module FeCoreExt::CoreExt
end

module FeCoreExt::CoreExt::Date
  def end_of_month?
    self == end_of_month
  end

  def range(duration)
    Range.new([(self + duration), self].min, [self + duration, self].max)
  end
end

module FeCoreExt::CoreExt::DateClassMethods
  def parse_as_future(string)
    date = parse(string)
    date > current ? date : date + 1.year
  end

  def parse_heisei(string)
    string.match('平成(\d+)年(\d+)月(\d+)日') {
      Date.new($1.to_i + 1988, $2.to_i, $3.to_i)
    }
  end
end

class Date
  include FeCoreExt::CoreExt::Date
  extend FeCoreExt::CoreExt::DateClassMethods
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fe_core_ext-0.1.38 lib/fe_core_ext/core_ext/date.rb