Class: Db2Query::Type::Timestamp
- Inherits:
-
Value
- Object
- Value
- Db2Query::Type::Timestamp
show all
- Defined in:
- lib/db2_query/type/timestamp.rb
Instance Attribute Summary
Attributes inherited from Value
#options
Instance Method Summary
collapse
Methods inherited from Value
#initialize, #quote, #type_name
Instance Method Details
#deserialize(value) ⇒ Object
25
26
27
|
# File 'lib/db2_query/type/timestamp.rb', line 25
def deserialize(value)
value
end
|
#serialize(value) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/db2_query/type/timestamp.rb', line 10
def serialize(value)
if value.is_a?(::String)
case value
when /\A(\d{4})-(\d\d)-(\d\d)-(\d\d).(\d\d).(\d\d).(\d{1,6})\z/
quote(value)
else
nil
end
elsif value.is_a?(::DateTime) || value.is_a?(::Time)
quote(value.strftime("%F-%H.%M.%S.%6N"))
else
nil
end
end
|
#type ⇒ Object
6
7
8
|
# File 'lib/db2_query/type/timestamp.rb', line 6
def type
:time
end
|