Permalink
Browse files

handle text starting w/ a ...

  • Loading branch information...
1 parent 5042ae5 commit f9aa0e21d5e442ec13c45bafbc40d790472c4bfc Steve Burkett committed May 25, 2012
Showing with 12 additions and 0 deletions.
  1. +1 −0 lib/chronic/chronic.rb
  2. +11 −0 test/test_parsing.rb
View
@@ -123,6 +123,7 @@ def pre_normalize(text)
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.gsub!(/^a /, '1 ')
text
end
View
@@ -685,6 +685,17 @@ def test_parse_guess_rgr
assert_equal Time.local(2006, 8, 8, 12), time
end
+ def test_parse_guess_a_ago
+ time = parse_now("a day ago")
+ assert_equal Time.local(2006, 8, 15, 14), time
+
+ time = parse_now("a month ago")
+ assert_equal Time.local(2006, 7, 16, 14), time
+
+ time = parse_now("a year ago")
+ assert_equal Time.local(2005, 8, 16, 14), time
+ end
+
def test_parse_guess_s_r_p
# past

0 comments on commit f9aa0e2

Please sign in to comment.