Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misinterpreting formula with minus signs as a date #276

Closed
gstenson opened this issue Sep 23, 2022 · 1 comment
Closed

Misinterpreting formula with minus signs as a date #276

gstenson opened this issue Sep 23, 2022 · 1 comment

Comments

@gstenson
Copy link

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'
@rubysolo
Copy link
Owner

rubysolo commented Mar 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants