Class: CocinaDisplay::Dates::EdtfFormat
- Defined in:
- lib/cocina_display/dates/date.rb
Overview
Strict EDTF parser.
Constant Summary
Constants inherited from Date
Date::BCE_CHAR_SORT_MAP, Date::UNPARSABLE_VALUES
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
Attributes inherited from Date
Class Method Summary collapse
Methods inherited from Date
#<=>, #approximate?, #as_range, #base_value, #decoded_value, #encoding, #encoding?, #end?, format_date, from_cocina, #inferred?, #initialize, #parsable?, parse_date, #parsed_date?, #precision, #primary?, #qualified?, #qualified_value, #qualifier, #questionable?, #sort_key, #start?, #to_a, #value
Constructor Details
This class inherits a constructor from CocinaDisplay::Dates::Date
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
461 462 463 |
# File 'lib/cocina_display/dates/date.rb', line 461 def date @date end |
Class Method Details
.normalize_to_edtf(value) ⇒ Object
463 464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/cocina_display/dates/date.rb', line 463 def self.normalize_to_edtf(value) return "0000" if value.strip == "0" case value when /^\d{1,3}$/ value.rjust(4, "0") if /^\d{1,3}$/.match?(value) when /^-\d{1,3}$/ "-#{value.sub(/^-/, "").rjust(4, "0")}" else value end end |