vendor/bundle/ruby/1.8/gems/chronic-0.6.7/lib/chronic/chronic.rb
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
# 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 parse(text, opts={})
      options = DEFAULT_OPTIONS.merge opts
      (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
      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
def parse ( text , opts = { } ) options = DEFAULT_OPTIONS . merge opts ( 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 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
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 ` ) .
# ensure the specified options are valid # tokenize words
None
Time, Chronic::Span, nil
text
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
text The text to parse
text The text to parse