Class: GMO::PG::Payload::TypecastableEpochTime
Constant Summary
collapse
- TIME_ZONE =
'+09:00'
- FORMAT =
'%Y%m%d%H%M%S'
Instance Attribute Summary
#value
Instance Method Summary
collapse
#==, from_hash, #initialize
Instance Method Details
64
65
66
|
# File 'lib/gmo-pg/http_resource/payload/typecast.rb', line 64
def format
FORMAT
end
|
#to_attribute ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
|
# 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 ⇒ Object
81
82
83
|
# 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
|