module Chronic
def parse(text, opts={})
-
(Time, Chronic::Span, nil)
-
Options Hash:
(**opts)
-
:ambiguous_year_future_bias
(Integer
) -- -
:endian_precedence
(Array
) -- -
:ambiguous_time_range
(Integer
) -- -
:guess
(Boolean
) -- -
:now
(Object
) -- -
:context
(Symbol
) --
Parameters:
-
text
(String
) -- The text to parse
def parse(text, opts={}) options = DEFAULT_OPTIONS.merge opts # ensure the specified options are valid (opts.keys - DEFAULT_OPTIONS.keys).each do |key| raise ArgumentError, "#{key} is not a valid option key." end unless [:past, :future, :none].include?(options[:context]) raise ArgumentError, "Invalid context, :past/:future only" end options[:text] = text Chronic.now = options[:now] || Chronic.time_class.now # tokenize words tokens = tokenize(text, options) if Chronic.debug puts "+#{'-' * 51}\n| #{tokens}\n+#{'-' * 51}" end span = tokens_to_span(tokens, options) if span options[:guess] ? guess(span) : span end end