dadhi/FastExpressionCompiler

Date difference is giving wrong negative value

maulik-chavda opened this issue · 1 comments

Hi,

we are using https://www.nuget.org/packages/RulesEngine/ to execute rules

which does use expression.CompileFast(); Reference : https://github.com/microsoft/RulesEngine/blob/main/src/RulesEngine/ExpressionBuilders/RuleExpressionParser.cs#L68

for certain expression of date difference it giving wrong negative values, while expression.Compile() is giving correct result for below expressions

e.g.

(DateTime.Now - Contract.StartDate).TotalDays 
(DateTime.Now.Date - Contract.StartDate.Date).TotalDays 

is giving wrong --10675001 value instead of 198, when DateTime.Now is 2024-07-17T19:09:02.088+05:30 and StartDate is 2024-01-01

while its working fine for below expressions in FastExpressionCompiler

(Contract.StartDate - Contract.StartDate).TotalDays 
(DateTime.Now - DateTime.Now).TotalDays 

Looking for fix or some workaround for this scenario.

Thanks!