From 8283eca993b042e0d5a48c8f382da2845b0fda18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Sat, 20 Aug 2022 08:14:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(utils):=E5=A2=9E=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E7=94=A8=E4=BA=8E=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=98=AF=E4=B8=8B=E4=B8=80=E4=B8=AA=E6=9C=88=E7=9A=84=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E5=87=BD=E6=95=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/time.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/utils/time.go b/utils/time.go index efa7515..1531dc1 100644 --- a/utils/time.go +++ b/utils/time.go @@ -9,3 +9,15 @@ func VeryBeginOfDate(date time.Time) time.Time { func VeryEndOfDate(date time.Time) time.Time { return time.Date(date.Year(), date.Month(), date.Day(), 23, 59, 59, 999999999, date.Location()) } + +func IsNextMonth(t1, t2 time.Time) bool { + 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()) + } + return (differMonth == -11 && differYear == 1) || (differMonth == 1 && differYear == 0) +}