统一时间格式和时区

This commit is contained in:
yml2213
2026-07-31 12:57:17 +08:00
parent 667bfbde06
commit 949a0eb8f7
24 changed files with 342 additions and 49 deletions
@@ -0,0 +1,21 @@
package timeutil
import (
"testing"
"time"
)
func TestFormatAPITimeUsesBusinessTimezone(t *testing.T) {
value := time.Date(2026, 7, 30, 9, 53, 58, 147355000, time.UTC)
if got := FormatAPITime(value); got != "2026-07-30T17:53:58+08:00" {
t.Fatalf("unexpected api time: %s", got)
}
}
func TestStartOfDayUsesBusinessTimezone(t *testing.T) {
value := time.Date(2026, 7, 30, 18, 30, 0, 0, time.UTC)
got := StartOfDay(value)
if got.Format(APITimeLayout) != "2026-07-31T00:00:00+08:00" {
t.Fatalf("unexpected day start: %s", got.Format(APITimeLayout))
}
}