lib/variable_precision_date.rb
# Given a value, attempt to parse it into a {VariablePrecisionDate}. It will always
# return a date, swallowing any parser errors. If something cannot be parsed, this
# method will return a `:none`-valued date.
#
# @param [String, Date, Hash, VariablePrecisionDate] value
# @return [VariablePrecisionDate]
Given a value, attempt to parse it into a {VariablePrecisionDate}. It will always
return a date, swallowing any parser errors. If something cannot be parsed, this
method will return a `:none`-valued date.
Given a value attempt to parse it into a { VariablePrecisionDate } . It will always return a date swallowing any parser errors . If something cannot be parsed this method will return a ` : none ` - valued date .
def parse(value)
      case value
      when ::VariablePrecisionDate
        value
      when SQL_REPRESENTATION
        parse_sql value
      when Date, Dry::Types["json.date"]
        new value, :day
      when HashSchema
        validated = HashSchema[value]
        new validated[:value], validated[:precision]
      else
        new nil, :none
      end
    end
def parse ( value ) case value when :: VariablePrecisionDate value when SQL_REPRESENTATION parse_sql value when Date , Dry :: Types [ "json.date" ] new value , :day when HashSchema validated = HashSchema [ value ] new validated [ :value ] , validated [ :precision ] else new nil , :none end end
Given a value, attempt to parse it into a {VariablePrecisionDate}.
Given a value attempt to parse it into a { VariablePrecisionDate } .
None
VariablePrecisionDate
value
None