0
@@ -23,8 +23,9 @@ module Chronic
0
def self.scan_for_days(token, post_token)
0
if token.word =~ /^\d\d?$/
0
- unless token.word.to_i > 31 || (post_token && %w{am pm morning afternoon evening night}.include?(post_token))
0
- return ScalarDay.new(token.word.to_i)
0
+ unless toi > 31 || toi < 1 || (post_token && %w{am pm morning afternoon evening night}.include?(post_token.word))
0
+ return ScalarDay.new(toi)
0
@@ -32,8 +33,9 @@ module Chronic
0
def self.scan_for_months(token, post_token)
0
if token.word =~ /^\d\d?$/
0
- unless token.word.to_i > 12 || (post_token && %w{am pm morning afternoon evening night}.include?(post_token))
0
- return ScalarMonth.new(token.word.to_i)
0
+ unless toi > 12 || toi < 1 || (post_token && %w{am pm morning afternoon evening night}.include?(post_token.word))
0
+ return ScalarMonth.new(toi)
0
@@ -41,7 +43,7 @@ module Chronic
0
def self.scan_for_years(token, post_token)
0
if token.word =~ /^([1-9]\d)?\d\d?$/
0
- unless post_token && %w{am pm morning afternoon evening night}.include?(post_token)
0
+ unless post_token && %w{am pm morning afternoon evening night}.include?(post_token.word)
0
return ScalarYear.new(token.word.to_i)
0
@@ -71,4 +73,4 @@ module Chronic
0
\ No newline at end of file
Comments
What’s the deal with this? "unless $1.to_i > 31 && $1.to_i < 1" Isn’t that impossible? Should there be tests with this?
pretty sure you meant: unless $1.to_i > 31 || $1.to_i < 1
aii!!! yep folks, you caught me on this one… thanks, JackDanger. Commit on the way…