class Necromancer::DateTimeConverters::StringToDateTimeConverter

An object that converts a String to a DateTime

Public Instance Methods

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

Convert a string value to a DateTime

@example

converer.call("1-1-2015")           # => "2015-01-01T00:00:00+00:00"
converer.call("1-1-2015 15:12:44")  # => "2015-01-01T15:12:44+00:00"

@api public

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