lib/rapa/resources/item_resource.rb in rapa-0.5.1 vs lib/rapa/resources/item_resource.rb in rapa-0.5.2

- old
+ new

@@ -228,11 +228,11 @@ end # @return [Date, nil] def publication_date if value = source.dig("ItemAttributes", "PublicationDate") - ::Date.parse(value) + parse_date(value) end end # @return [String, nil] def publisher @@ -285,11 +285,11 @@ end # @return [Date, nil] def release_date if value = source.dig("ItemAttributes", "ReleaseDate") - ::Date.parse(value) + parse_date(value) end end # @return [Rapa::Quantity, nil] def running_time @@ -398,9 +398,16 @@ # @return [Hash] def item_links @item_links ||= source["ItemLinks"]["ItemLink"].each_with_object({}) do |element, result| result[element["Description"]] = element["URL"] end + end + + # @param string [String] + # @return [Date] + def parse_date(string) + string += "-01" if /\A(\d{4})-(\d{2})\z/ === string + ::Date.parse(string) end end end end