Date + duration is not working when date is in a variable
vlazar opened this issue · 0 comments
vlazar commented
This works:
calc = Dentaku::Calculator.new
calc.evaluate!('2020-04-01 + duration(1, month)').to_date
# => Fri, 01 May 2020
This fails:
calc.evaluate!('value + duration(1, month)', { value: DateTime.parse('2020-04-01').to_date }).to_date
# => Traceback (most recent call last):
# => .../gems/dentaku-3.4.1/lib/dentaku/ast/arithmetic.rb:81:in `validate_operation': Dentaku::AST::Addition requires operands that respond to + (Dentaku::ArgumentError)