Module: NEU::MODS::Projection::Dates

Includes:
Support
Included in:
NEU::MODS::Projection, OriginInfo
Defined in:
lib/neu/mods/projection/dates.rb

Overview

The seven originInfo date elements, each projected as nine flat fields. See docs/dates.md, which lists every generated field.

Constant Summary collapse

W3CDTF_DATE =

Year, year-month, full date, or full date with a time. Never fall back to a bare DateTime.parse: it fills missing parts from TODAY, so "19uu" would parse as the current date.

/\A(\d{4})(?:-(\d{2})(?:-(\d{2})(T\S+)?)?)?\z/
ISO8601_BASIC_DATE =

The same shapes without hyphens, read ONLY under @encoding="iso8601": an accession number is eight digits too.

/\A(\d{4})(?:(\d{2})(?:(\d{2})(T\S+)?)?)?\z/
ISO8601_ENCODING =

@encoding, folded, so "ISO-8601" matches too.

"iso8601"
DATE_FIELDS =

Field prefix => the MODS element it reads, in FIELDS order. Written out rather than derived, so a search for a field name lands here.

{
  date_created: "dateCreated",
  date_issued: "dateIssued",
  copyright_date: "copyrightDate",
  date_captured: "dateCaptured",
  date_valid: "dateValid",
  date_other: "dateOther",
  date_modified: "dateModified"
}.freeze
DATE_KEYS =

Field suffix => the key of the #date_parts entry it reads. Each element projects one field per row.

{
  "" => :value,
  "_precision" => :precision,
  "_end" => :end_value,
  "_end_precision" => :end_precision,
  "_qualifier" => :qualifier,
  "_key_date" => :key_date,
  "_text" => :text,
  "_display_label" => :display_label,
  "_event_type" => :event_type
}.freeze
EMPTY_DATE =

What #date_parts returns when the element is absent entirely, so an absent date is distinguishable from one present and unparseable.

DATE_KEYS.values.to_h { |key| [key, nil] }.freeze
DATE_FIELD_ROWS =

The FIELDS rows for the generated fields, each element's rows together.

DATE_FIELDS.keys.product(DATE_KEYS.keys)
.to_h { |field, suffix| [:"#{field}#{suffix}", :one] }.freeze
DATE_ELEMENTS =

The same seven elements as DATE_FIELDS, in the order a consumer deciding a place header reads them. Keep this order: #origin_date_elements returns elements in it.

%w[dateIssued dateCreated copyrightDate dateCaptured
dateValid dateOther dateModified].freeze

Constants included from Support

Support::AUTHORITY_ATTRIBUTES

Instance Method Summary collapse

Instance Method Details



81
# File 'lib/neu/mods/projection/dates.rb', line 81

def copyright_date_with_precision = [copyright_date, copyright_date_precision]

#date_created_with_precision ⇒ Object

[value, precision], for a caller that wants those two alone.



79
# File 'lib/neu/mods/projection/dates.rb', line 79

def date_created_with_precision = [date_created, date_created_precision]

#date_issued_with_precision ⇒ Object



80
# File 'lib/neu/mods/projection/dates.rb', line 80

def date_issued_with_precision = [date_issued, date_issued_precision]