Skip to content

Commit cb65e6a

Browse files
committed
修改 bug
1 parent b213d6e commit cb65e6a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

java/toolgood.algorithm/src/main/java/toolgood/algorithm/internals/MathVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2693,7 +2693,7 @@ public Operand visitDATEDIF_fun(final DATEDIF_funContext context) {
26932693
return Operand.Create((endDate.Year * 12 + endDate.Month - startDate.Year * 12 - startDate.Month - 1));
26942694
}
26952695
} else if (CharUtil.Equals(t, "d")) {
2696-
return Operand.Create(endDate.SUB(startDate).ToNumber().intValue());
2696+
return Operand.Create((endDate.ToNumber().subtract(startDate.ToNumber())).intValue());
26972697
} else if (CharUtil.Equals(t, "yd")) {
26982698
int day = endDate.DayOfYear() - startDate.DayOfYear();
26992699
if (endDate.Year > startDate.Year && day < 0) {

java/toolgood.algorithm/src/test/java/toolgood/algorithm/Tests/IssuesTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public void issues_27()
3636
AlgorithmEngine engine = new AlgorithmEngine();
3737
MyDate dt = engine.TryEvaluate("DATE(2024, 8, 1) + TIME(8, 0, 0)", MyDate.now());
3838
assertEquals(dt.toString(), "2024-08-01 08:00:00");
39+
40+
MyDate dt2 = engine.TryEvaluate("DATE(2024, 8, 1, 16,0,0) - TIME(8, 0, 0)", MyDate.now());
41+
assertEquals(dt2.toString(), "2024-08-01 08:00:00");
3942
}
4043

4144
}

0 commit comments

Comments
 (0)