lib/isodoc/nist/render.rb in metanorma-nist-0.1.0 vs lib/isodoc/nist/render.rb in metanorma-nist-0.1.1
- old
+ new
@@ -164,17 +164,18 @@
def self.series(doc, type)
s = doc.at("./series[@type = 'main']") ||
doc.at("./series[not(@type)]") ||
doc.at("./series")
return "" unless s
- f = s.at("./formattedref") and return r.text
+ f = s.at("./formattedref")
+ return f.text if f
t = s.at("./title")
a = s.at("./abbreviation")
n = s.at("./number")
p = s.at("./partnumber")
dn = doc.at("./docnumber")
- rev = doc&.at(".//edition")&.text.sub(/^Revision /, "")
+ rev = doc&.at(".//edition")&.text&.sub(/^Revision /, "")
ret = ""
if t
title = included(type) ? wrap(t.text, " <I>", "</I>") : wrap(t.text, " ", "")
ret += title
ret += " (#{a.text.sub(/^NIST /, "")})" if a
@@ -189,21 +190,19 @@
ret
end
def self.standardidentifier(doc)
ret = []
- require "byebug"; byebug
doc.xpath("./docidentifier").each do |id|
next if %w(nist-mr nist-long).include? id["type"]
ret << standardidentifier1(id)
end
ret.join(". ")
end
def self.standardidentifier1(id)
r = ""
- require "byebug"; byebug
r += "#{id['type']} " if id["type"] and
!%w(ISO IEC NIST).include? id["type"]
r += id.text
r
end
@@ -255,20 +254,36 @@
ret.join(", ")
end
def self.monthyr(isodate)
return nil if isodate.nil?
- DateTime.parse(isodate).localize(:en).to_additional_s("yMMMM")
+ arr = isodate.split("-")
+ date = if arr.size == 2
+ DateTime.new(*arr.map(&:to_i))
+ else
+ DateTime.parse(isodate)
+ end
+ date.localize(:en).to_additional_s("yMMMM")
end
def self.mmddyyyy(isodate)
return nil if isodate.nil?
- Date.parse(isodate).strftime("%m-%d-%Y")
+ arr = isodate.split("-")
+ date = if arr.size == 2
+ Date.new(*arr.map(&:to_i)).strftime("%m-%Y")
+ else
+ Date.parse(isodate).strftime("%m-%d-%Y")
+ end
end
def self.MMMddyyyy(isodate)
return nil if isodate.nil?
- Date.parse(isodate).strftime("%B %d, %Y")
+ arr = isodate.split("-")
+ date = if arr.size == 2
+ Date.new(*arr.map(&:to_i)).strftime("%B, %Y")
+ else
+ Date.parse(isodate).strftime("%B %d, %Y")
+ end
end
def self.draft(doc)
return nil unless is_nist(doc)
dr = doc&.at("./status/stage")&.text