Class: CocinaDisplay::Dates::MarcFormat

Inherits:
Date
  • Object
show all
Defined in:
lib/cocina_display/dates/date.rb

Overview

MARC date parser; similar to EDTF but with some MARC-specific encodings.

Constant Summary

Constants inherited from Date

Date::BCE_CHAR_SORT_MAP, Date::UNPARSABLE_VALUES

Instance Attribute Summary

Attributes inherited from Date

#cocina, #date, #encoding, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Date

#<=>, #approximate?, #as_range, #base_value, #decoded_value, #encoding?, #end?, format_date, from_cocina, #inferred?, #initialize, #known?, #label, notifier, #parsable?, parse_date, #parsed_date?, #precision, #primary?, #qualified?, #qualified_value, #qualifier, #questionable?, #sort_key, #start?, #to_a, #to_s, #value

Constructor Details

This class inherits a constructor from CocinaDisplay::Dates::Date

Class Method Details

.normalize_to_edtf(value) ⇒ Object



524
525
526
527
528
# File 'lib/cocina_display/dates/date.rb', line 524

def self.normalize_to_edtf(value)
  return nil if value == "9999" || value == "||||"

  super
end

Instance Method Details

#earliest_dateObject



530
531
532
533
534
535
536
# File 'lib/cocina_display/dates/date.rb', line 530

def earliest_date
  if value == "1uuu"
    ::Date.parse("1000-01-01")
  else
    super
  end
end

#latest_dateObject



538
539
540
541
542
543
544
# File 'lib/cocina_display/dates/date.rb', line 538

def latest_date
  if value == "1uuu"
    ::Date.parse("1999-12-31")
  else
    super
  end
end