vendor/bundle/ruby/1.8/gems/chronic-0.6.7/lib/chronic/chronic.rb
def tokens_to_span(tokens, options)
      definitions = definitions(options)

      (definitions[:endian] + definitions[:date]).each do |handler|
        if handler.match(tokens, definitions)
          good_tokens = tokens.select { |o| !o.get_tag Separator }
          return handler.invoke(:date, good_tokens, options)
        end
      end

      definitions[:anchor].each do |handler|
        if handler.match(tokens, definitions)
          good_tokens = tokens.select { |o| !o.get_tag Separator }
          return handler.invoke(:anchor, good_tokens, options)
        end
      end

      definitions[:arrow].each do |handler|
        if handler.match(tokens, definitions)
          good_tokens = tokens.reject { |o| o.get_tag(SeparatorAt) || o.get_tag(SeparatorSlashOrDash) || o.get_tag(SeparatorComma) }
          return handler.invoke(:arrow, good_tokens, options)
        end
      end

      definitions[:narrow].each do |handler|
        if handler.match(tokens, definitions)
          return handler.invoke(:narrow, tokens, options)
        end
      end

      puts "-none" if Chronic.debug
      return nil
    end
# Parses a string containing a natural language date or time
#
# If the parser can find a date or time, either a Time or Chronic::Span
# will be returned (depending on the value of `:guess`). If no
# date or time can be found, `nil` will be returned
#
# @param [String] text The text to parse
#
# @option opts [Symbol] :context (:future)
#   * If your string represents a birthday, you can set `:context` to
#     `:past` and if an ambiguous string is given, it will assume it is
#     in the past. Specify `:future` or omit to set a future context.
#
# @option opts [Object] :now (Time.now)
#   * By setting `:now` to a Time, all computations will be based off of
#     that time instead of `Time.now`. If set to nil, Chronic will use
#     `Time.now`
#
# @option opts [Boolean] :guess (true)
#   * By default, the parser will guess a single point in time for the
#     given date or time. If you'd rather have the entire time span
#     returned, set `:guess` to `false` and a {Chronic::Span} will
#     be returned
#
# @option opts [Integer] :ambiguous_time_range (6)
#   * If an Integer is given, ambiguous times (like 5:00) will be
#     assumed to be within the range of that time in the AM to that time
#     in the PM. For example, if you set it to `7`, then the parser
#     will look for the time between 7am and 7pm. In the case of 5:00, it
#     would assume that means 5:00pm. If `:none` is given, no
#     assumption will be made, and the first matching instance of that
#     time will be used
#
# @option opts [Array] :endian_precedence ([:middle, :little])
#   * By default, Chronic will parse "03/04/2011" as the fourth day
#     of the third month. Alternatively you can tell Chronic to parse
#     this as the third day of the fourth month by altering the
#     `:endian_precedence` to `[:little, :middle]`
#
# @option opts [Integer] :ambiguous_year_future_bias (50)
#   * When parsing two digit years (ie 79) unlike Rubys Time class,
#     Chronic will attempt to assume the full year using this figure.
#     Chronic will look x amount of years into the future and past. If
#     the two digit year is `now + x years` it's assumed to be the
#     future, `now - x years` is assumed to be the past
#
# @return [Time, Chronic::Span, nil]
Parses a string containing a natural language date or time
If the parser can find a date or time, either a Time or Chronic::Span
will be returned (depending on the value of `:guess`). If no
date or time can be found, `nil` will be returned
Parses a string containing a natural language date or time If the parser can find a date or time either a Time or Chronic :: Span will be returned ( depending on the value of ` : guess ` ) . If no date or time can be found ` nil ` will be returned
def tokens_to_span(tokens, options)
      definitions = definitions(options)
      (definitions[:endian] + definitions[:date]).each do |handler|
        if handler.match(tokens, definitions)
          good_tokens = tokens.select { |o| !o.get_tag Separator }
          return handler.invoke(:date, good_tokens, options)
        end
      end
      definitions[:anchor].each do |handler|
        if handler.match(tokens, definitions)
          good_tokens = tokens.select { |o| !o.get_tag Separator }
          return handler.invoke(:anchor, good_tokens, options)
        end
      end
      definitions[:arrow].each do |handler|
        if handler.match(tokens, definitions)
          good_tokens = tokens.reject { |o| o.get_tag(SeparatorAt) || o.get_tag(SeparatorSlashOrDash) || o.get_tag(SeparatorComma) }
          return handler.invoke(:arrow, good_tokens, options)
        end
      end
      definitions[:narrow].each do |handler|
        if handler.match(tokens, definitions)
          return handler.invoke(:narrow, tokens, options)
        end
      end
      puts "-none" if Chronic.debug
      return nil
    end
def tokens_to_span ( tokens , options ) definitions = definitions ( options ) ( definitions [ :endian ] + definitions [ :date ] ) . each do | handler | if handler . match ( tokens , definitions ) good_tokens = tokens . select { | o | ! o . get_tag Separator } return handler . invoke ( :date , good_tokens , options ) end end definitions [ :anchor ] . each do | handler | if handler . match ( tokens , definitions ) good_tokens = tokens . select { | o | ! o . get_tag Separator } return handler . invoke ( :anchor , good_tokens , options ) end end definitions [ :arrow ] . each do | handler | if handler . match ( tokens , definitions ) good_tokens = tokens . reject { | o | o . get_tag ( SeparatorAt ) || o . get_tag ( SeparatorSlashOrDash ) || o . get_tag ( SeparatorComma ) } return handler . invoke ( :arrow , good_tokens , options ) end end definitions [ :narrow ] . each do | handler | if handler . match ( tokens , definitions ) return handler . invoke ( :narrow , tokens , options ) end end puts "-none" if Chronic . debug return nil end
Parses a string containing a natural language date or time
If the parser can find a date or time, either a Time or Chronic::Span
will be returned (depending on the value of `:guess`).
Parses a string containing a natural language date or time If the parser can find a date or time either a Time or Chronic :: Span will be returned ( depending on the value of ` : guess ` ) .
None
Time, Chronic::Span, nil
tokens
options
text The text to parse
text The text to parse
opts
:ambiguous_year_future_bias (50) * When parsing two digit years  unlike Rubys Time class, Chronic will attempt to assume the full year using this figure. Chronic will look x amount of years into the future and past. If the two digit year is `now + x years` it's assumed to be the future, `now - x years` is assumed to be the past
: ambiguous_year_future_bias ( 50 ) * When parsing two digit years unlike Rubys Time class Chronic will attempt to assume the full year using this figure . Chronic will look x amount of years into the future and past . If the two digit year is ` now + x years ` it ' s assumed to be the future ` now - x years ` is assumed to be the past