Skip to content

Commit

Permalink
check timerange validity
Browse files Browse the repository at this point in the history
  • Loading branch information
nilic committed Jul 16, 2023
1 parent d44bf78 commit 96636a9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@ func main() {
if cCtx.String("from") == "" {
return fmt.Errorf("start of the time range missing, please use --from <value in RFC3339> to specify")
}
_, err := time.Parse(time.RFC3339, s)
to, err := time.Parse(time.RFC3339, s)
if err != nil {
return fmt.Errorf("invalid time format for end of the time range, please use RFC3339")
}
from, _ := time.Parse(time.RFC3339, cCtx.String("from"))
if !to.After(from) {
return fmt.Errorf("end of the time range should be later than start of the time range")
}
return nil
},
},
Expand Down

0 comments on commit 96636a9

Please sign in to comment.