class Necromancer::DateTimeConverters::StringToDateConverter
An object that converts a String to a Date
Public Instance Methods
call(value, options = {})
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 22 def call(value, options = {}) strict = options.fetch(:strict, config.strict) Date.parse(value) rescue strict ? fail_conversion_type(value) : value end