feat: add timezone support for schedule and user runtime (#282)

This commit is contained in:
Yiming Qi
2026-03-26 01:32:02 +08:00
committed by GitHub
parent 3a7f5200ed
commit 03ba13e7e5
51 changed files with 793 additions and 100 deletions
+14
View File
@@ -9,6 +9,7 @@ import (
"time"
"github.com/memohai/memoh/internal/config"
"github.com/memohai/memoh/internal/timezone"
)
type RuntimeConfig struct {
@@ -17,6 +18,8 @@ type RuntimeConfig struct {
ServerAddr string
ContainerdSocketPath string
ContainerBackend string // "containerd" or "apple"
Timezone string
TimezoneLocation *time.Location
}
func ProvideRuntimeConfig(cfg config.Config) (*RuntimeConfig, error) {
@@ -34,12 +37,23 @@ func ProvideRuntimeConfig(cfg config.Config) (*RuntimeConfig, error) {
backend = "apple"
}
tzName := strings.TrimSpace(cfg.Timezone)
if envTZ := strings.TrimSpace(os.Getenv("TZ")); envTZ != "" {
tzName = envTZ
}
tzLocation, resolvedTZ, err := timezone.Resolve(tzName)
if err != nil {
return nil, err
}
ret := &RuntimeConfig{
JwtSecret: cfg.Auth.JWTSecret,
JwtExpiresIn: jwtExpiresIn,
ServerAddr: cfg.Server.Addr,
ContainerdSocketPath: cfg.Containerd.SocketPath,
ContainerBackend: backend,
Timezone: resolvedTZ,
TimezoneLocation: tzLocation,
}
if value := os.Getenv("HTTP_ADDR"); value != "" {