lib/amsi/attribute_parser/date_time.rb in amsi-1.0.1 vs lib/amsi/attribute_parser/date_time.rb in amsi-1.1.0
- old
+ new
@@ -11,11 +11,17 @@
private_constant :TIME_ZONE
# @return [Date] the parsed attribute value
def parse
return if value == ''
+
date_time = ::DateTime.parse(value)
- TIME_ZONE.local_to_utc(date_time) { |periods| periods.last }
+ 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
end