Sha256: 7e23211a25cd991e51bf501c603ca2df496606ebb5c3912fbab0c1e452d576a2
Contents?: true
Size: 421 Bytes
Versions: 10
Compression:
Stored size: 421 Bytes
Contents
# frozen_string_literal: true module Decidim module Attributes # Custom Virtus value to parse a String representing a Date using # the app localization format. class LocalizedDate < Virtus::Attribute def coerce(value) return value unless value.is_a?(String) Date.strptime(value, I18n.t("date.formats.decidim_short")) rescue ArgumentError nil end end end end
Version data entries
10 entries across 10 versions & 1 rubygems