Skip to content

Commit

Permalink
added support for CST
Browse files Browse the repository at this point in the history
  • Loading branch information
rebely3ll committed Aug 12, 2024
1 parent b7a0fdc commit 3b7272e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
16 changes: 16 additions & 0 deletions cmd/cli/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"fmt"
"os"

otlh "github.com/xifanyan/otlh/pkg"
Expand Down Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
)
Expand Down
6 changes: 4 additions & 2 deletions pkg/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3b7272e

Please sign in to comment.