From 84451f8aaabbc945820a8fcbcbaeb21b48d5b47b Mon Sep 17 00:00:00 2001 From: ziming Date: Wed, 28 May 2025 20:40:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pkg/helper/utils_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/pkg/helper/utils_test.go b/internal/pkg/helper/utils_test.go index 5ab23c1..64996c6 100644 --- a/internal/pkg/helper/utils_test.go +++ b/internal/pkg/helper/utils_test.go @@ -3,9 +3,25 @@ package helper import ( "fmt" "testing" + "time" ) func TestHashMod(t *testing.T) { serverId := HashMod("1dfsfdsfsddf12dddd5451212iodewnsanf2") fmt.Println(serverId) } + +func TestNoticeTime(t *testing.T) { + now := time.Now() + + // 获取七天前的日期 + noticeStartDay := now.AddDate(0, 0, -29) + // 获取七天前 00:00:00 的时间 + startTime := time.Date(noticeStartDay.Year(), noticeStartDay.Month(), noticeStartDay.Day(), 0, 0, 0, 0, noticeStartDay.Location()) + + noticeEndDay := now.AddDate(0, 0, -28) + // 获取昨天 23:59:59 的时间 + endTime := time.Date(noticeEndDay.Year(), noticeEndDay.Month(), noticeEndDay.Day(), 23, 59, 59, 0, noticeEndDay.Location()) + + t.Logf("startTime:%s,endTime:%s", startTime, endTime) +}