Class: Amsi::AttributeParser::DateTime
- Defined in:
- lib/amsi/attribute_parser/date_time.rb
Overview
Parse the response value of a date with time attribute.
Instance Method Summary collapse
-
#parse ⇒ Date
The parsed attribute value.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Amsi::AttributeParser::Base
Instance Method Details
#parse ⇒ Date
Returns the parsed attribute value.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/amsi/attribute_parser/date_time.rb', line 14 def parse return if value == '' date_time = ::DateTime.parse(value) if timezone.nil? TIME_ZONE.local_to_utc(date_time, &:last) else time_zone = TZInfo::Timezone.get(timezone) time_zone.local_to_utc(date_time, &:last) end rescue ArgumentError raise Error::InvalidResponse, "Invalid date/time response value: #{value}" end |