Sha256: 22c1c1c04d4bfb2a5377bf7ed600c18eb99d32122be3fd112c7a083ac19e6799

Contents?: true

Size: 1.46 KB

Versions: 27

Compression:

Stored size: 1.46 KB

Contents

module IsoDoc
  class Metadata
    DATETYPES =
      %w{published accessed created implemented obsoleted confirmed updated
         corrected issued received transmitted copied unchanged circulated
         adapted announced vote-started vote-ended stable-until}.freeze

    def months
      {
        "01": @labels["month_january"],
        "02": @labels["month_february"],
        "03": @labels["month_march"],
        "04": @labels["month_april"],
        "05": @labels["month_may"],
        "06": @labels["month_june"],
        "07": @labels["month_july"],
        "08": @labels["month_august"],
        "09": @labels["month_september"],
        "10": @labels["month_october"],
        "11": @labels["month_november"],
        "12": @labels["month_december"],
      }
    end

    def monthyr(isodate)
      m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)/.match isodate
      return isodate unless m && m[:yr] && m[:mo]

      l10n("#{months[m[:mo].to_sym]} #{m[:yr]}")
    end

    def MMMddyyyy(isodate)
      isodate.nil? and return nil

      arr = isodate.split("-")
      arr.size == 1 && (/^\d+$/.match isodate) and
        return Date.new(*arr.map(&:to_i)).strftime("%Y")
      arr.size == 2 and
        return Date.new(*arr.map(&:to_i)).strftime("%B %Y")
      Date.parse(isodate).strftime("%B %d, %Y")
    end

    def bibdate(isoxml, _out)
      isoxml.xpath(ns("//bibdata/date")).each do |d|
        set("#{d['type'].gsub(/-/, '_')}date".to_sym, Common::date_range(d))
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
isodoc-2.12.1 lib/isodoc/metadata_date.rb
isodoc-2.12.0 lib/isodoc/metadata_date.rb
isodoc-2.11.4 lib/isodoc/metadata_date.rb
isodoc-2.11.3 lib/isodoc/metadata_date.rb
isodoc-2.11.2 lib/isodoc/metadata_date.rb
isodoc-2.11.1 lib/isodoc/metadata_date.rb
isodoc-2.11.0 lib/isodoc/metadata_date.rb
isodoc-2.10.7 lib/isodoc/metadata_date.rb
isodoc-2.10.6 lib/isodoc/metadata_date.rb
isodoc-2.10.5 lib/isodoc/metadata_date.rb
isodoc-2.10.4 lib/isodoc/metadata_date.rb
isodoc-2.10.3 lib/isodoc/metadata_date.rb
isodoc-2.10.2 lib/isodoc/metadata_date.rb
isodoc-2.10.1 lib/isodoc/metadata_date.rb
isodoc-2.10.0 lib/isodoc/metadata_date.rb
isodoc-2.9.4 lib/isodoc/metadata_date.rb
isodoc-2.9.3 lib/isodoc/metadata_date.rb
isodoc-2.9.2 lib/isodoc/metadata_date.rb
isodoc-2.9.1 lib/isodoc/metadata_date.rb
isodoc-2.9.0 lib/isodoc/metadata_date.rb