Class: Krikri::Enrichments::ParseDate

Inherits:
Object
  • Object
show all
Includes:
Audumbla::FieldEnrichment
Defined in:
lib/krikri/enrichments/parse_date.rb

Overview

Normalizes date strings to EDTF or Date objects.

Attempts to convert a string value to a Date object:

- Parses EDTF values, returns an appropriate EDTF object if
  a match is found; then...
- Parses values in %m*%d*%Y format and returns a Date object if
  appropriate.
- Parses values that match any of Date#parse's supported formats.

If the value is not a ‘String` or is parsed as invalid by all parsers, the original value is returned unaltered.

See Also:

Instance Method Summary collapse

Instance Method Details

#enrich_value(value) ⇒ Object



22
23
24
25
# File 'lib/krikri/enrichments/parse_date.rb', line 22

def enrich_value(value)
  return value unless value.is_a? String
  Krikri::Util::ExtendedDateParser.parse(value) || value
end