Class: Superstore::Types::TimeType
Instance Attribute Summary
Attributes inherited from BaseType
#model, #options
Instance Method Summary
collapse
Methods inherited from BaseType
#initialize, #typecast
Instance Method Details
#decode(str) ⇒ Object
10
11
12
13
14
|
# File 'lib/superstore/types/time_type.rb', line 10
def decode(str)
Time.parse(str).in_time_zone if str
rescue
end
|
#encode(time) ⇒ Object
4
5
6
7
8
|
# File 'lib/superstore/types/time_type.rb', line 4
def encode(time)
raise ArgumentError.new("#{time.inspect} does not respond to #to_time") unless time.is_a?(Time) || time.respond_to?(:to_time)
time = time.to_time unless time.is_a?(Time)
time.utc.xmlschema(6)
end
|