diff --git a/src/server/GoUtil/timeUtil.go b/src/server/GoUtil/timeUtil.go index a00caec9..3bc805c2 100644 --- a/src/server/GoUtil/timeUtil.go +++ b/src/server/GoUtil/timeUtil.go @@ -30,8 +30,16 @@ func MonthZeroTimestamp() int64 { func NextZeroTimestampDuration() int64 { now := time.Now() - midnight := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) - return midnight.AddDate(0, 0, 1).Unix() - now.Unix() + location := now.Location() + midnight := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, location) + nextMidnight := midnight.AddDate(0, 0, 1) + + // Adjust for daylight saving time transitions + _, nowOffset := now.Zone() + _, nextMidnightOffset := nextMidnight.Zone() + offsetDifference := nextMidnightOffset - nowOffset + + return nextMidnight.Unix() - now.Unix() + int64(offsetDifference) } // 获取距离下个中午十二点时间戳的秒数