AWS services or capabilities described in AWS Documentation may vary by region/location. Click
Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Class: Aws::Record::Marshalers::DateTimeMarshaler
- Inherits:
-
Object
- Object
- Aws::Record::Marshalers::DateTimeMarshaler
show all
- Defined in:
- lib/aws-record/record/marshalers/date_time_marshaler.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of DateTimeMarshaler.
21
22
23
24
|
# File 'lib/aws-record/record/marshalers/date_time_marshaler.rb', line 21
def initialize(opts = {})
@formatter = opts[:formatter] || Iso8601Formatter
@use_local_time = opts[:use_local_time] ? true : false
end
|
Instance Method Details
#serialize(raw_value) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/aws-record/record/marshalers/date_time_marshaler.rb', line 35
def serialize(raw_value)
datetime = type_cast(raw_value)
if datetime.nil?
nil
elsif datetime.is_a?(::DateTime)
@formatter.format(datetime)
else
msg = "expected a DateTime value or nil, got #{datetime.class}"
raise ArgumentError, msg
end
end
|
#type_cast(raw_value) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/aws-record/record/marshalers/date_time_marshaler.rb', line 26
def type_cast(raw_value)
value = _format(raw_value)
if !@use_local_time && value.is_a?(::DateTime)
value.new_offset(0)
else
value
end
end
|