Class: Dynamoid::TypeCasting::DateTimeTypeCaster
- Defined in:
- lib/dynamoid/type_casting.rb
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Dynamoid::TypeCasting::Base
Instance Method Details
#process(value) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/dynamoid/type_casting.rb', line 230 def process(value) if !value.respond_to?(:to_datetime) nil elsif value.is_a?(String) dt = begin DateTime.parse(value) rescue StandardError nil end if dt seconds = string_utc_offset(value) || ApplicationTimeZone.utc_offset offset = seconds_to_offset(seconds) DateTime.new(dt.year, dt.mon, dt.mday, dt.hour, dt.min, dt.sec, offset) end else value.to_datetime end end |