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, -15)
	// 获取七天前 00:00:00 的时间
	startTime := time.Date(noticeStartDay.Year(), noticeStartDay.Month(), noticeStartDay.Day(), 0, 0, 0, 0, noticeStartDay.Location())

	noticeEndDay := now.AddDate(0, 0, -1)
	// 获取昨天 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)
}

func TestNum(t *testing.T) {
	useNum := 0
	used(&useNum)
	t.Log(useNum)
}

func used(useNum *int) {
	queryUsed(useNum)
	queryUsed(useNum)
	*useNum += 1
}

func queryUsed(useNum *int) {
	*useNum += 1
}

func TestMd5(t *testing.T) {
	s := Md5(`{"product_no":"","start_time":"2025-04-20 09:00:00","end_time":"2025-05-01 00:00:00"}`)
	t.Log(s)
}
