class Decidim::Attributes::LocalizedDate

Custom Virtus value to parse a String representing a Date using the app localization format.

Public Instance Methods

coerce(value) click to toggle source
# File lib/decidim/attributes/localized_date.rb, line 8
def coerce(value)
  return value unless value.is_a?(String)

  Date.strptime(value, I18n.t("date.formats.decidim_short"))
rescue ArgumentError
  nil
end
type() click to toggle source
# File lib/decidim/attributes/localized_date.rb, line 16
def type
  Axiom::Types::Date
end