class Gorillib::Factory::TimeFactory

Constants

FLAT_TIME_RE

Public Instance Methods

convert(obj) click to toggle source
# File lib/gorillib/model/factories.rb, line 429
def convert(obj)
  case obj
  when FLAT_TIME_RE  then product.utc(obj[0..3].to_i, obj[4..5].to_i, obj[6..7].to_i, obj[8..9].to_i, obj[10..11].to_i, obj[12..13].to_i)
  when Time          then obj.getutc
  when Date          then product.utc(obj.year, obj.month, obj.day)
  when String        then product.parse(obj).utc
  when Numeric       then product.at(obj)
  else                    mismatched!(obj)
  end
rescue ArgumentError => err
  raise if err.is_a?(TypeMismatchError)
  warn "Cannot parse time #{obj}: #{err}"
  return nil
end
native?(obj) click to toggle source
Calls superclass method Gorillib::Factory::BaseFactory#native?
# File lib/gorillib/model/factories.rb, line 428
def native?(obj) super(obj) && obj.utc_offset == 0 ; end