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

Date difference is giving wrong negative value #421

Closed
maulik-chavda opened this issue Jul 18, 2024 · 1 comment
Closed

Date difference is giving wrong negative value #421

maulik-chavda opened this issue Jul 18, 2024 · 1 comment
Assignees
Labels
Milestone

Comments

@maulik-chavda
Copy link

maulik-chavda commented Jul 18, 2024

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!

@maulik-chavda maulik-chavda changed the title Date difference is giving wrong value Date difference is giving wrong negative value Jul 18, 2024
@dadhi dadhi self-assigned this Jul 18, 2024
@dadhi dadhi added this to the v4.2.2 milestone Jul 18, 2024
@dadhi dadhi added the bug label Jul 18, 2024
dadhi added a commit that referenced this issue Oct 12, 2024
@dadhi
Copy link
Owner

dadhi commented Oct 12, 2024

@maulik-chavda Bug is confirmed, working on the fix.

@dadhi dadhi closed this as completed in 8d6a169 Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants