Skip to content

Commit

Permalink
style: time/timeutil: update conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Sep 17, 2023
1 parent 1d6aaad commit 17cdd96
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions time/timeutil/duration_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ func parseDurationHours(d string) (time.Duration, error) {
d = strings.TrimSpace(d)
if d == "" || d == "0" {
return 0, nil
}
if f, err := strconv.ParseFloat(d, 64); err != nil {
} else if f, err := strconv.ParseFloat(d, 64); err != nil {
return 0, err
} else {
return time.Duration(int64(f * float64(NanosPerHour))), nil
Expand All @@ -356,8 +355,7 @@ func parseDurationMinutes(d string) (time.Duration, error) {
d = strings.TrimSpace(d)
if d == "" || d == "0" {
return 0, nil
}
if f, err := strconv.ParseFloat(d, 64); err != nil {
} else if f, err := strconv.ParseFloat(d, 64); err != nil {
return 0, err
} else {
return time.Duration(int64(f * float64(NanosPerMinute))), nil
Expand All @@ -368,8 +366,7 @@ func parseDurationSeconds(d string) (time.Duration, error) {
d = strings.TrimSpace(d)
if d == "" || d == "0" {
return 0, nil
}
if f, err := strconv.ParseFloat(d, 64); err != nil {
} else if f, err := strconv.ParseFloat(d, 64); err != nil {
return 0, err
} else {
return time.Duration(int64(f * float64(NanosPerSecond))), nil
Expand All @@ -380,8 +377,7 @@ func parseDurationMilliseconds(d string) (time.Duration, error) {
d = strings.TrimSpace(d)
if d == "" || d == "0" {
return 0, nil
}
if f, err := strconv.ParseFloat(d, 64); err != nil {
} else if f, err := strconv.ParseFloat(d, 64); err != nil {
return 0, err
} else {
return time.Duration(int64(f * float64(NanosPerMillisecond))), nil
Expand All @@ -392,8 +388,7 @@ func parseDurationMicroseconds(d string) (time.Duration, error) {
d = strings.TrimSpace(d)
if d == "" || d == "0" {
return 0, nil
}
if f, err := strconv.ParseFloat(d, 64); err != nil {
} else if f, err := strconv.ParseFloat(d, 64); err != nil {
return 0, err
} else {
return time.Duration(int64(f * float64(NanosPerMicrosecond))), nil
Expand All @@ -404,8 +399,7 @@ func parseDurationNanoseconds(d string) (time.Duration, error) {
d = strings.TrimSpace(d)
if d == "" || d == "0" {
return 0, nil
}
if f, err := strconv.ParseFloat(d, 64); err != nil {
} else if f, err := strconv.ParseFloat(d, 64); err != nil {
return 0, err
} else {
return time.Duration(int64(f)), nil
Expand Down

0 comments on commit 17cdd96

Please sign in to comment.