Sha256: ec1fb1b0ceb55ae16195d3205d1989c214b0c8d6f51a25f4dfa7ed3953f18607

Contents?: true

Size: 505 Bytes

Versions: 8

Compression:

Stored size: 505 Bytes

Contents

# encoding: utf-8

require 'date'

begin
  d = ::Date.today
  d.freeze
  d.year
  needs_patch = false
rescue
  needs_patch = true
end

if needs_patch

  class ::Date

    [ :amjd, :jd, :day_fraction, :mjd, :ld, :civil, :ordinal, :commercial, :weeknum0, :weeknum1, :time, :wday, :julian?, :gregorian?, :leap? ].each do |m|
      module_eval <<EOS
        alias_method :__orig_#{m}, :#{m}
        def #{m}
          self.frozen? ? self.dup.#{m} : self.send(:__orig_#{m})
        end
EOS
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nanoc-3.7.3 lib/nanoc/base/core_ext/date.rb
nanoc-3.7.2 lib/nanoc/base/core_ext/date.rb
nanoc-3.7.1 lib/nanoc/base/core_ext/date.rb
nanoc-3.7.0 lib/nanoc/base/core_ext/date.rb
nanoc-3.6.11 lib/nanoc/base/core_ext/date.rb
nanoc-3.6.10 lib/nanoc/base/core_ext/date.rb
nanoc-3.6.9 lib/nanoc/base/core_ext/date.rb
nanoc-3.6.8 lib/nanoc/base/core_ext/date.rb