diff --git a/java/toolgood.algorithm/src/main/java/toolgood/algorithm/internals/MathVisitor.java b/java/toolgood.algorithm/src/main/java/toolgood/algorithm/internals/MathVisitor.java index 34eeb47..31285c6 100644 --- a/java/toolgood.algorithm/src/main/java/toolgood/algorithm/internals/MathVisitor.java +++ b/java/toolgood.algorithm/src/main/java/toolgood/algorithm/internals/MathVisitor.java @@ -2693,7 +2693,7 @@ public Operand visitDATEDIF_fun(final DATEDIF_funContext context) { return Operand.Create((endDate.Year * 12 + endDate.Month - startDate.Year * 12 - startDate.Month - 1)); } } else if (CharUtil.Equals(t, "d")) { - return Operand.Create(endDate.SUB(startDate).ToNumber().intValue()); + return Operand.Create((endDate.ToNumber().subtract(startDate.ToNumber())).intValue()); } else if (CharUtil.Equals(t, "yd")) { int day = endDate.DayOfYear() - startDate.DayOfYear(); if (endDate.Year > startDate.Year && day < 0) { diff --git a/java/toolgood.algorithm/src/test/java/toolgood/algorithm/Tests/IssuesTest.java b/java/toolgood.algorithm/src/test/java/toolgood/algorithm/Tests/IssuesTest.java index 499942d..48b9abf 100644 --- a/java/toolgood.algorithm/src/test/java/toolgood/algorithm/Tests/IssuesTest.java +++ b/java/toolgood.algorithm/src/test/java/toolgood/algorithm/Tests/IssuesTest.java @@ -36,6 +36,9 @@ public void issues_27() AlgorithmEngine engine = new AlgorithmEngine(); MyDate dt = engine.TryEvaluate("DATE(2024, 8, 1) + TIME(8, 0, 0)", MyDate.now()); assertEquals(dt.toString(), "2024-08-01 08:00:00"); + + MyDate dt2 = engine.TryEvaluate("DATE(2024, 8, 1, 16,0,0) - TIME(8, 0, 0)", MyDate.now()); + assertEquals(dt2.toString(), "2024-08-01 08:00:00"); } }