module Chronic

def pre_normalize(text) #:nodoc:

Returns:
  • (String) - A new string ready for Chronic to parse

Parameters:
  • text (String) -- The string to normalize
def pre_normalize(text) #:nodoc:
  text = text.to_s.downcase
  text.gsub!(/['"\.,]/, '')
  text.gsub!(/\bsecond (of|day|month|hour|minute|second)\b/, '2nd \1')
  text = numericize_numbers(text)
  text.gsub!(/ \-(\d{4})\b/, ' tzminus\1')
  text.gsub!(/([\/\-\,\@])/) { ' ' + $1 + ' ' }
  text.gsub!(/\b0(\d+:\d+\s*pm?\b)/, '\1')
  text.gsub!(/\btoday\b/, 'this day')
  text.gsub!(/\btomm?orr?ow\b/, 'next day')
  text.gsub!(/\byesterday\b/, 'last day')
  text.gsub!(/\bnoon\b/, '12:00')
  text.gsub!(/\bmidnight\b/, '24:00')
  text.gsub!(/\bbefore now\b/, 'past')
  text.gsub!(/\bnow\b/, 'this second')
  text.gsub!(/\b(ago|before)\b/, 'past')
  text.gsub!(/\bthis past\b/, 'last')
  text.gsub!(/\bthis last\b/, 'last')
  text.gsub!(/\b(?:in|during) the (morning)\b/, '\1')
  text.gsub!(/\b(?:in the|during the|at) (afternoon|evening|night)\b/, '\1')
  text.gsub!(/\btonight\b/, 'this night')
  text.gsub!(/\b\d+:?\d*[ap]\b/,'\0m')
  text.gsub!(/(\d)([ap]m|oclock)\b/, '\1 \2')
  text.gsub!(/\b(hence|after|from)\b/, 'future')
  text
end