Class: Krikri::Enrichments::ParseDate

Inherits:
Object
  • Object
show all
Includes:
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:

Constant Summary

Constants included from SoftwareAgent

SoftwareAgent::Logger

Instance Method Summary collapse

Methods included from FieldEnrichment

#enrich, #enrich_all, #enrich_field

Methods included from Krikri::Enrichment

#enrich, #enrich!, #list_fields

Methods included from SoftwareAgent

#agent_name, #log, #run

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