Skip to content

Commit 5969ead

Browse files
authored
use math.Round (#113)
1 parent 65fb477 commit 5969ead

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

types.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -345,18 +345,7 @@ func ParseTime(s string) (Time, error) {
345345
minute, _ := strconv.Atoi(s[2:4])
346346
second, _ := strconv.ParseFloat(s[4:], 64)
347347
whole, frac := math.Modf(second)
348-
return Time{true, hour, minute, int(whole), int(round(frac * 1000))}, nil
349-
}
350-
351-
// round is implemented here because it wasn't added until go1.10
352-
// this code is taken directly from the math.Round documentation
353-
// TODO: use math.Round after a reasonable amount of time
354-
func round(x float64) float64 {
355-
t := math.Trunc(x)
356-
if math.Abs(x-t) >= 0.5 {
357-
return t + math.Copysign(1, x)
358-
}
359-
return t
348+
return Time{true, hour, minute, int(whole), int(math.Round(frac * 1000))}, nil
360349
}
361350

362351
// Date type

0 commit comments

Comments
 (0)