优化 DiffInMonths 方法

This commit is contained in:
gouguoyin 2024-11-25 03:55:14 +08:00
parent 47e15d293c
commit 9d0f6e2567

View File

@ -284,7 +284,7 @@ func getDiffInMonths(start, end Carbon, months int64) int64 {
next := start.AddDays(start.DaysInMonth())
days := next.DiffInDays(end)
seconds := next.DiffInSeconds(end)
if days < 0 || days == 0 && seconds < 0 {
if days < 0 || (days == 0 && seconds < 0) {
return months
}
months += 1