Open colinlieberman opened 4 years ago
Same happens for string starting with letter "p" and having number
[91] pry(main)> Chronic.parse("p 2")
=> 2021-01-22 14:00:00 +0530
[92] pry(main)> Chronic.parse("panything random 2")
=> 2021-01-22 14:00:00 +0530
[93] pry(main)> Chronic.parse("p nything random 2")
=> 2021-01-22 14:00:00 +0530
[94] pry(main)> Chronic.parse("p nything random")
=> nil
@colinlieberman it's due to this line in the pre-normalization step:
text.gsub!(/^\s?an? /i, '1 ')
which converts any a/an followed by a space into the numeric '1' which is allowed as a standalone scalar value and interpreted as a time (1pm?). AFAICT it's there to address interpreting "a minute" as "1 minute" or "an hour" as "1 hour" cases.
Apologies if this has already been addressed and I didn't find it when searching.
ruby 2.4.0p0 chronic 0.10.2
First had this issue with the string "A Swiftly Turning Planet", and expected a
nil
return:After some poking around, it looks like it's the letter A followed by a space that's the issue: