class TariffDate
  include ActiveModel::Validations
  include ActiveModel::Conversion

  attr_reader :date

  def initialize(date)
    self.date = date
  end

  def date=(date)
    @date = if date.present?
              begin
                Date.parse(date.to_s)
              rescue ArgumentError
              end
            end
  end

  def date
    @date.presence || Date.today
  end

  def persisted?
    false
  end

  def to_param
    date
  end

  def to_s
    date.to_formatted_s(:date)
  end
end

class TariffDate
  include ActiveModel::Validations
  include ActiveModel::Conversion

  attr_reader :date

  def initialize(date)
    self.date = date
  end

  def date=(date)
    @date = if date.present?
              begin
                Date.parse(date.to_s)
              rescue ArgumentError
              end
            end
  end

  def date
    @date.presence || Date.today
  end

  def persisted?
    false
  end

  def to_param
    date.to_formatted_s(:full)
  end

  def to_s
    date.to_formatted_s(:date)
  end
end

Use yyyy-mm-dd date format in the url param.
Use yyyy-mm-dd date format in the url param.

This brings more clarity and trust instead of dd/mm/yyyy where '/'s are
expressed as HTML entities.
