class ParamsReady::Value::DateTimeCoder
Public Class Methods
coerce(input, _)
click to toggle source
# File lib/params_ready/value/coder.rb, line 189 def self.coerce(input, _) return nil if input.nil? || input == '' if input.is_a?(Numeric) Time.at(input).to_datetime elsif input.is_a?(String) DateTime.parse(input) elsif input.respond_to?(:to_datetime) input.to_datetime else raise ParamsReadyError, "Unimplemented for type #{input.class.name}" end end
format(value, format)
click to toggle source
# File lib/params_ready/value/coder.rb, line 202 def self.format(value, format) value.to_s end