Sha256: 56dd11e452a11385ce1e9862aef4d90a8339a8fe46d36d36d647867a27ffd09e
Contents?: true
Size: 881 Bytes
Versions: 7
Compression:
Stored size: 881 Bytes
Contents
require_relative 'base' module RealPage class AttributeParser # Parse the response value of a date attribute class Date < Base # RealPage responds with multiple date formats. This is one format that # Date.parse will not parse correctly, so we need special handling FORMAT = '%m/%d/%Y'.freeze private_constant :FORMAT # @return [Date] the parsed attribute value def parse return if value == '' if value =~ %r[/] ::Date.strptime(value, FORMAT) else # RealPage sometimes returns 0001-01-01 for dates, which appears to be # their representation of a NULL value. date = ::Date.parse(value) date.year == 1 ? nil : date end rescue ArgumentError raise Error::InvalidResponse, "Invalid date response value: #{value}" end end end end
Version data entries
7 entries across 7 versions & 1 rubygems