rubysolo/dentaku

Misinterpreting formula with minus signs as a date

gstenson opened this issue · 1 comments

Dentaku::Calculator.new.evaluate("1353+91-1-3322-22")

Is throwing an err. Part of stack:

/usr/lib/ruby/2.7.0/time.rb:266:in `local'
/usr/lib/ruby/2.7.0/time.rb:266:in `make_time'
/usr/lib/ruby/2.7.0/time.rb:375:in `parse'
/var/lib/gems/2.7.0/gems/dentaku-3.3.4/lib/dentaku/token_scanner.rb:89:in `block in datetime'
/var/lib/gems/2.7.0/gems/dentaku-3.3.4/lib/dentaku/token_scanner.rb:20:in `scan'

Thanks for reporting this. I've added a negative lookahead assertion that should prevent some of these false positives. However, it's impossible to completely prevent this from happening, so I also added a raw_date_literals option for the Calendar class that turns off date parsing entirely.