class Parameters::Types::DateTime

Public Class Methods

coerce(value) click to toggle source

Coerces a value into a DateTime object.

@param [#to_datetime, ::String] value

The value to coerce.

@return [::DateTime]

The coerced DateTime.
# File lib/parameters/types/date_time.rb, line 19
def self.coerce(value)
  if value.respond_to?(:to_datetime)
    value.to_datetime
  else
    ::DateTime.parse(value.to_s)
  end
end