From 52a83bd34e0357d4079c560bed2bdbaf3f7d9ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Sat, 20 Aug 2022 12:09:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(utils):=E8=B0=83=E6=95=B4=E6=9C=88=E5=B7=AE?= =?UTF-8?q?=E5=80=BC=E8=AE=A1=E7=AE=97=EF=BC=8C=E4=BD=BF=E5=85=B6=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E4=BD=BF=E7=94=A8=E8=B4=9F=E6=95=B0=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E5=89=8D=E5=90=8E=E9=A1=BA=E5=BA=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/time.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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 }