Skip to content

Commit

Permalink
修改 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
toolgood committed Aug 9, 2024
1 parent b213d6e commit cb65e6a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

}

0 comments on commit cb65e6a

Please sign in to comment.