Class: Treat::Workers::Extractors::Time::Kronic

Inherits:
Object
  • Object
show all
Defined in:
lib/treat/workers/extractors/time/kronic.rb

Overview

Time/date extraction using a simple rule-based library.

Supported formats: Today, yesterday, tomorrow, last thursday, this thursday, 14 Sep, 14 June 2010. Any dates without a year are assumed to be in the past.

Class Method Summary collapse

Class Method Details

.time(entity, options = {}) ⇒ Object

Return the date information contained within the entity by parsing it with the ‘chronic’ gem.

Options: none.



15
16
17
18
# File 'lib/treat/workers/extractors/time/kronic.rb', line 15

def self.time(entity, options = {})
  time = Kronic.parse(entity.to_s)
  time.is_a?(DateTime) ? time : nil
end