diff --git a/cmd/cli/command.go b/cmd/cli/command.go index eae6dfc..175839a 100644 --- a/cmd/cli/command.go +++ b/cmd/cli/command.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "fmt" "os" otlh "github.com/xifanyan/otlh/pkg" @@ -58,6 +59,21 @@ var ( CheckInputOnly, SkipInputCheck, }, + Before: func(c *cli.Context) error { + allowedTimezones := map[string]bool{ + "CST": true, + "EST": true, + "MST": true, + "PST": true, + "UTC": true, + } + + tz := c.String("timezone") + if !allowedTimezones[tz] { + return fmt.Errorf("timezone %s is not supported (UTC|CST|EST|MST|PST only)", tz) + } + return nil + }, } VerifyCmd = &cli.Command{ diff --git a/cmd/cli/flag.go b/cmd/cli/flag.go index 08450fb..b611ddc 100644 --- a/cmd/cli/flag.go +++ b/cmd/cli/flag.go @@ -99,7 +99,7 @@ var ( Timezone = &cli.StringFlag{ Name: "timezone", Aliases: []string{"tz"}, - Usage: "timezone for dates used in input file e.g., PST or EST", + Usage: "timezone for dates used in input file, supproted timezones: PST|EST|MST|CST", Value: "UTC", } ) diff --git a/pkg/utils.go b/pkg/utils.go index b0c6810..842e384 100644 --- a/pkg/utils.go +++ b/pkg/utils.go @@ -115,12 +115,14 @@ func IsValidEmailAddress(email string) bool { func GetTimezoneLocation(tz string) string { switch tz { - case "PST": - return "America/Los_Angeles" + case "CST": + return "America/Chicago" case "EST": return "America/New_York" case "MST": return "America/Denver" + case "PST": + return "America/Los_Angeles" // Add more cases for other timezones if needed default: return "UTC"