class GMO::PG::Payload::TypecastableEpochTime

Constants

FORMAT
TIME_ZONE

Public Instance Methods

format() click to toggle source
# File lib/gmo-pg/http_resource/payload/typecast.rb, line 64
def format
  FORMAT
end
to_attribute() click to toggle source
# File lib/gmo-pg/http_resource/payload/typecast.rb, line 68
def to_attribute
  time =
    case @value
    when Time
      @value
    when DateTime
      Time.new(@value.year, @value.month, @value.day, @value.hour, @value.min, @value.sec)
    else
      Time.strptime(@value, format) rescue return super
    end
  time.to_i rescue super
end
to_payload() click to toggle source
# File lib/gmo-pg/http_resource/payload/typecast.rb, line 81
def to_payload
  Time.at(to_attribute).localtime(TIME_ZONE).strftime(format) rescue super
end