Permalink
Browse files

allow month regexp to accept :/. with substrings

We're doing this because in pre_normalize, we replace all periods with
colons. So `Dec. 1st` becomes `dec: 1st'

closes #159
  • Loading branch information...
1 parent 2f8759e commit 9b2461064ad3ca4660efb5785998e6289562a090 @leejarvis leejarvis committed Dec 21, 2012
Showing with 14 additions and 11 deletions.
  1. +11 −11 lib/chronic/repeater.rb
  2. +3 −0 test/test_parsing.rb
View
@@ -38,18 +38,18 @@ def self.scan_for_season_names(token)
def self.scan_for_month_names(token)
scan_for token, RepeaterMonthName,
{
- /^jan\.?(uary)?$/ => :january,
- /^feb\.?(ruary)?$/ => :february,
- /^mar\.?(ch)?$/ => :march,
- /^apr\.?(il)?$/ => :april,
+ /^jan[:\.]?(uary)?$/ => :january,
+ /^feb[:\.]?(ruary)?$/ => :february,
+ /^mar[:\.]?(ch)?$/ => :march,
+ /^apr[:\.]?(il)?$/ => :april,
/^may$/ => :may,
- /^jun\.?e?$/ => :june,
- /^jul\.?y?$/ => :july,
- /^aug\.?(ust)?$/ => :august,
- /^sep\.?(t\.?|tember)?$/ => :september,
- /^oct\.?(ober)?$/ => :october,
- /^nov\.?(ember)?$/ => :november,
- /^dec\.?(ember)?$/ => :december
+ /^jun[:\.]?e?$/ => :june,
+ /^jul[:\.]?y?$/ => :july,
+ /^aug[:\.]?(ust)?$/ => :august,
+ /^sep[:\.]?(t[:\.]?|tember)?$/ => :september,
+ /^oct[:\.]?(ober)?$/ => :october,
+ /^nov[:\.]?(ember)?$/ => :november,
+ /^dec[:\.]?(ember)?$/ => :december
}
end
View
@@ -33,6 +33,9 @@ def test_handle_rmn_sd
time = parse_now("aug 3", :context => :past)
assert_equal Time.local(2006, 8, 3, 12), time
+ time = parse_now("aug. 3")
+ assert_equal Time.local(2006, 8, 3, 12), time
+
time = parse_now("aug 20")
assert_equal Time.local(2006, 8, 20, 12), time

0 comments on commit 9b24610

Please sign in to comment.