Sha256: ae84d5fde7f2685e80d60167e29c067e9281a13b342cdd5931cd606fb3a8b7ef

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

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_fs(#{format.inspect}) instead."
      )
      if formatter.respond_to?(:call)
        formatter.call(self).to_s
      else
        strftime(formatter)
      end
    elsif format == NOT_SET
      if formatter = DATE_FORMATS[:default]
        ActiveSupport::Deprecation.warn(<<-MSG.squish)
          Using a :default format for Date#to_s is deprecated. Please use Date#to_fs instead. If you fixed all places
          inside your application that you see this deprecation, you can set
          `ENV['RAILS_DISABLE_DEPRECATED_TO_S_CONVERSION']` to `"true"` in the `config/application.rb` file before
          the `Bundler.require` call to fix all the callers outside of your application.
        MSG
        if formatter.respond_to?(:call)
          formatter.call(self).to_s
        else
          strftime(formatter)
        end
      else
        to_default_s
      end
    else
      ActiveSupport::Deprecation.warn(
        "Date#to_s(#{format.inspect}) is deprecated. Please use Date#to_fs(#{format.inspect}) instead."
      )
      to_default_s
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.8.7/lib/active_support/core_ext/date/deprecated_conversions.rb
activesupport-7.0.8.7 lib/active_support/core_ext/date/deprecated_conversions.rb
activesupport-7.0.8.6 lib/active_support/core_ext/date/deprecated_conversions.rb
activesupport-7.0.8.5 lib/active_support/core_ext/date/deprecated_conversions.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.4/lib/active_support/core_ext/date/deprecated_conversions.rb
activesupport-7.0.8.4 lib/active_support/core_ext/date/deprecated_conversions.rb
activesupport-7.0.8.1 lib/active_support/core_ext/date/deprecated_conversions.rb
activesupport-7.0.8 lib/active_support/core_ext/date/deprecated_conversions.rb