feat: refact timezone calling

This commit is contained in:
engigu
2026-02-09 18:39:41 +08:00
parent eb05eafb72
commit f693c32554
10 changed files with 64 additions and 18 deletions
+5 -1
View File
@@ -4,6 +4,8 @@ import (
"database/sql/driver"
"fmt"
"time"
"github.com/engigu/baihu-panel/internal/systime"
)
const TimeFormat = "2006-01-02 15:04:05"
@@ -16,6 +18,8 @@ func (t LocalTime) MarshalJSON() ([]byte, error) {
if tt.IsZero() {
return []byte("null"), nil
}
// 统一输出为东八区时间
tt = systime.InCST(tt)
return []byte(fmt.Sprintf(`"%s"`, tt.Format(TimeFormat))), nil
}
@@ -66,5 +70,5 @@ func (t LocalTime) Time() time.Time {
}
func Now() LocalTime {
return LocalTime(time.Now())
return LocalTime(systime.Now())
}