From 534d00a975f8123309b915d3965c5eec60aa5a5a Mon Sep 17 00:00:00 2001 From: hahwu <31872165+hahwu@users.noreply.github.com> Date: Mon, 31 Mar 2025 10:10:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8F=E4=BB=A4=E6=97=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/GoUtil/timeUtil.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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) } // 获取距离下个中午十二点时间戳的秒数