lib/rapa/resources/item_resource.rb in rapa-0.5.3 vs lib/rapa/resources/item_resource.rb in rapa-0.5.4

- old
+ new

@@ -422,13 +422,19 @@ result[element["Description"]] = element["URL"] end end # @param string [String] - # @return [Date] + # @return [Date, nil] def parse_date(string) - string += "-01" if /\A(\d{4})-(\d{2})\z/ === string - ::Date.parse(string) + case string + when /\A\d{1,4}\z/ + ::Date.parse("#{string}-01-01") + when /\A\d{1,4}-\d{1,2}\z/ + ::Date.parse("#{string}-01") + when /\A\d{1,4}-\d{1,2}-\d{1,2}\z/ + ::Date.parse(string) + end end end end end