* Load zoneinfo from TZ and ZONEINFO env (#2279)
This commit is contained in:
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 |
|
|
@ -9,6 +9,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
|
@ -68,6 +69,21 @@ const (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Printf("%s", banner)
|
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()
|
cmd := NewPicoclawCommand()
|
||||||
if err := cmd.Execute(); err != nil {
|
if err := cmd.Execute(); err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue