class Gorillib::Factory::DateFactory
Constants
- FLAT_DATE_RE
Public Instance Methods
convert(obj)
click to toggle source
# File lib/gorillib/model/type/extended.rb, line 25 def convert(obj) case obj when FLAT_DATE_RE then product.new(obj[0..3].to_i, obj[4..5].to_i, obj[6..7].to_i) when Time then Date.new(obj.year, obj.month, obj.day) when String then Date.parse(obj) else mismatched!(obj) end rescue ArgumentError => err raise if err.is_a?(TypeMismatchError) warn "Cannot parse time #{obj}: #{err}" return nil end