Class: Mods::Date::MMDDYYFormat
- Inherits:
-
ExtractorDateFormat
- Object
- Mods::Date
- ExtractorDateFormat
- Mods::Date::MMDDYYFormat
- Defined in:
- lib/mods/date.rb
Overview
Full text extractor for MM/DD/YY-formatted dates
Constant Summary collapse
- REGEX =
/(?<month>\d{1,2})\/(?<day>\d{1,2})\/(?<year>\d{2})/
Instance Attribute Summary
Attributes inherited from Mods::Date
Class Method Summary collapse
Methods inherited from ExtractorDateFormat
Methods inherited from Mods::Date
#approximate?, #as_range, #encoding, #encoding?, #end?, from_element, #inferred?, #initialize, parse_date, #point, #qualifier, #questionable?, #single?, #start?, #text, #to_a, #type
Constructor Details
This class inherits a constructor from Mods::Date
Class Method Details
.cleanup(text) ⇒ Object
110 111 112 113 114 |
# File 'lib/mods/date.rb', line 110 def self.cleanup(text) matches = text.match(self::REGEX) year = munge_to_yyyy(matches[:year]) "#{year}-#{matches[:month].rjust(2, "0")}-#{matches[:day].rjust(2, "0")}" end |
.munge_to_yyyy(text) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/mods/date.rb', line 116 def self.munge_to_yyyy(text) if text.to_i > (::Date.current.year - 2000) "19#{text}" else "20#{text}" end end |