lib/rfcbib/scrapper.rb in rfcbib-0.2.3 vs lib/rfcbib/scrapper.rb in rfcbib-0.2.4
- old
+ new
@@ -144,17 +144,23 @@
# @return [String]
def contributor_role(author)
author[:role] || 'author'
end
+ def month(mo)
+ return mo if /^\d+$/.match mo
+ Date::MONTHNAMES.index(mo)
+ end
+
#
# Extract date from reference.
#
# @return [Array<IsoBibItem::BibliographicDate>] published data.
#
def dates
return unless (date = @reference.at '//front/date')
- d = [date[:year], date[:month], date[:day]].compact.join '-'
+ d = [date[:year], month(date[:month]),
+ (date[:day] || "01")].compact.join '-'
date = Time.parse(d).strftime '%Y-%m-%d'
[IsoBibItem::BibliographicDate.new(type: 'published', on: date)]
end
#