diff --git a/utils/time.go b/utils/time.go index 10e88a4..3d27626 100644 --- a/utils/time.go +++ b/utils/time.go @@ -14,16 +14,11 @@ func VeryEndOfDate(date time.Time) time.Time { func DifferenceInMonth(t1, t2 time.Time) int { var differYear, differMonth int - if t1.After(t2) { - differYear = t1.Year() - t2.Year() - differMonth = int(t1.Month() - t2.Month()) - } else { - differYear = t2.Year() - t1.Year() - differMonth = int(t2.Month() - t1.Month()) - } + differYear = t1.Year() - t2.Year() + differMonth = int(t1.Month() - t2.Month()) return differYear*12 + differMonth } func IsNextMonth(t1, t2 time.Time) bool { - return DifferenceInMonth(t1, t2) == 1 + return DifferenceInMonth(t1, t2) == -1 }