package tools import ( "time" ) // 计算时间差值 func RemainingTimeUntilNextFriday17() time.Duration { // 获取当前时间 now := time.Now() // 计算下一个周五的时间 nextFriday := now.AddDate(0, 0, (int(time.Friday)-int(now.Weekday())+7)%7) // 如果今天是周五,则直接返回距离今天17点的时间 if now.Weekday() == time.Friday { today17 := time.Date(now.Year(), now.Month(), now.Day(), 17, 0, 0, 0, now.Location()) return today17.Sub(now) } // 构造下一个周五 17 点的时间 nextFriday17 := time.Date(nextFriday.Year(), nextFriday.Month(), nextFriday.Day(), 17, 0, 0, 0, nextFriday.Location()) // 计算时间差 duration := nextFriday17.Sub(now) return duration }