Skip to content

Commit

Permalink
support short-hand year notation
Browse files Browse the repository at this point in the history
  • Loading branch information
mkdynamic committed Sep 12, 2014
1 parent 1b93e33 commit 4a92354
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/chronic/parser.rb
Expand Up @@ -98,6 +98,15 @@ def pre_normalize(text)
text.gsub!(/(\s+|:\d{2}|:\d{2}\.\d{3})\-(\d{2}:?\d{2})\b/, '\1tzminus\2')
text.gsub!(/\./, ':')
text.gsub!(/([ap]):m:?/, '\1m')
text.gsub!(/'(\d{2})\b/) do
number = $1.to_i

if Chronic::Date::could_be_year?(number)
Chronic::Date::make_year(number, options[:ambiguous_year_future_bias])
else
number
end
end
text.gsub!(/['"]/, '')
text.gsub!(/,/, ' ')
text.gsub!(/^second /, '2nd ')
Expand Down
3 changes: 3 additions & 0 deletions test/test_parsing.rb
Expand Up @@ -166,6 +166,9 @@ def test_handle_rmn_sy

time = parse_now("may 32")
assert_equal Time.local(2032, 5, 16, 12, 0, 0), time

time = parse_now("may '01")
assert_equal Time.local(2001, 5, 16, 12, 0, 0), time
end

def test_handle_rdn_rmn_sd_t_tz_sy
Expand Down

0 comments on commit 4a92354

Please sign in to comment.