Sha256: 3c95443e869b4faf4eeb014fa84bd5d9f8b873e2764a5ee2b0e4c1362f60693a

Contents?: true

Size: 696 Bytes

Versions: 5

Compression:

Stored size: 696 Bytes

Contents

# frozen_string_literal: true

require "date"

class DateTime
  NOT_SET = Object.new # :nodoc:
  def to_s(format = NOT_SET) # :nodoc:
    if formatter = ::Time::DATE_FORMATS[format]
      ActiveSupport::Deprecation.warn(
        "DateTime#to_s(#{format.inspect}) is deprecated. Please use DateTime#to_formatted_s(#{format.inspect}) instead."
      )
      formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
    elsif format == NOT_SET
      to_default_s
    else
      ActiveSupport::Deprecation.warn(
        "DateTime#to_s(#{format.inspect}) is deprecated. Please use DateTime#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_time/deprecated_conversions.rb
activesupport-7.0.0 lib/active_support/core_ext/date_time/deprecated_conversions.rb
activesupport-7.0.0.rc3 lib/active_support/core_ext/date_time/deprecated_conversions.rb
activesupport-7.0.0.rc2 lib/active_support/core_ext/date_time/deprecated_conversions.rb
activesupport-7.0.0.rc1 lib/active_support/core_ext/date_time/deprecated_conversions.rb