Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove ambiguous leading 0's in timestamps whenever we include day po…

…rtions

closes #164
  • Loading branch information...
commit e86d794702aa4b02db6d2ab6aec15279f08f5936 1 parent e6d98a6
@leejarvis leejarvis authored
Showing with 7 additions and 0 deletions.
  1. +1 −0  lib/chronic/parser.rb
  2. +6 −0 test/test_parsing.rb
View
1  lib/chronic/parser.rb
@@ -116,6 +116,7 @@ def pre_normalize(text)
text.gsub!(/\b(hence|after|from)\b/, 'future')
text.gsub!(/^\s?an? /i, '1 ')
text.gsub!(/\b(\d{4}):(\d{2}):(\d{2})\b/, '\1 / \2 / \3') # DTOriginal
+ text.gsub!(/\b0(\d+):(\d{2}):(\d{2}) ([ap]m)\b/, '\1:\2:\3 \4')
text
end
View
6 test/test_parsing.rb
@@ -377,6 +377,12 @@ def test_handle_r
time = parse_now("on Tuesday")
assert_equal Time.local(2006, 8, 22, 12), time
+
+ time = parse_now("1:00:00 PM")
+ assert_equal Time.local(2006, 8, 16, 13), time
+
+ time = parse_now("01:00:00 PM")
+ assert_equal Time.local(2006, 8, 16, 13), time
end
def test_handle_r_g_r
Please sign in to comment.
Something went wrong with that request. Please try again.