Sha256: d582fe0f86960d184e81952c7ce46b518fac3c0fe6b231fad493e35a8825b2fb

Contents?: true

Size: 641 Bytes

Versions: 12

Compression:

Stored size: 641 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].minmax)
  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

12 entries across 12 versions & 1 rubygems

Version Path
fe_core_ext-0.2.2 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.2.1 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.1.49 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.1.48 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.1.47 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.1.46 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.1.45 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.1.44 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.1.43 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.1.42 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.1.41 lib/fe_core_ext/core_ext/date.rb
fe_core_ext-0.1.40 lib/fe_core_ext/core_ext/date.rb