class Necromancer::DateTimeConverters::StringToDateConverter

An object that converts a String to a Date

Public Instance Methods

call(value, strict: config.strict) click to toggle source

Convert a string value to a Date

@example

converter.call("1-1-2015")    # => "2015-01-01"
converter.call("01/01/2015")  # => "2015-01-01"
converter.call("2015-11-12")  # => "2015-11-12"
converter.call("12/11/2015")  # => "2015-11-12"

@api public

# File lib/necromancer/converters/date_time.rb, line 23
def call(value, strict: config.strict)
  Date.parse(value)
rescue StandardError
  strict ? raise_conversion_type(value) : value
end