Sha256: 31ea01909c2c65e9678461f8f8ccfde4c25a3c07e9a47e63d5d19b8c58f5a76b

Contents?: true

Size: 704 Bytes

Versions: 5

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true

require "date"

class Date
  NOT_SET = Object.new # :nodoc:
  def to_s(format = NOT_SET) # :nodoc:
    if formatter = DATE_FORMATS[format]
      ActiveSupport::Deprecation.warn(
        "Date#to_s(#{format.inspect}) is deprecated. Please use Date#to_formatted_s(#{format.inspect}) instead."
      )
      if formatter.respond_to?(:call)
        formatter.call(self).to_s
      else
        strftime(formatter)
      end
    elsif format == NOT_SET
      to_default_s
    else
      ActiveSupport::Deprecation.warn(
        "Date#to_s(#{format.inspect}) is deprecated. Please use Date#to_formatted_s(#{format.inspect}) instead."
      )
      to_default_s
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activesupport-7.0.1 lib/active_support/core_ext/date/deprecated_conversions.rb
activesupport-7.0.0 lib/active_support/core_ext/date/deprecated_conversions.rb
activesupport-7.0.0.rc3 lib/active_support/core_ext/date/deprecated_conversions.rb
activesupport-7.0.0.rc2 lib/active_support/core_ext/date/deprecated_conversions.rb
activesupport-7.0.0.rc1 lib/active_support/core_ext/date/deprecated_conversions.rb