* Load zoneinfo from TZ and ZONEINFO env (#2279)

This commit is contained in:
lxowalle
2026-04-03 10:12:15 +08:00
committed by GitHub
parent 8aa110c02a
commit 849e37cf79
2 changed files with 16 additions and 0 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 20 KiB

+16
View File
@@ -9,6 +9,7 @@ package main
import (
"fmt"
"os"
"time"
"github.com/spf13/cobra"
@@ -68,6 +69,21 @@ const (
func main() {
fmt.Printf("%s", banner)
tz_env := os.Getenv("TZ")
if tz_env != "" {
fmt.Println("TZ environment:", tz_env)
zoneinfo_env := os.Getenv("ZONEINFO")
fmt.Println("ZONEINFO environment:", zoneinfo_env)
loc, err := time.LoadLocation(tz_env)
if err != nil {
fmt.Println("Error loading time zone:", err)
} else {
fmt.Println("Time zone loaded successfully:", loc)
time.Local = loc //nolint:gosmopolitan // We intentionally set local timezone from TZ env
}
}
cmd := NewPicoclawCommand()
if err := cmd.Execute(); err != nil {
os.Exit(1)