Codebase list golang-github-vbauerster-mpb / 41f374e
Check eta value for math.IsInf or math.IsNaN Vladimir Bauer 8 years ago
1 changed file(s) with 7 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
11
22 import (
33 "fmt"
4 "math"
45 "time"
56
67 "github.com/VividCortex/ewma"
5960 return s.onComplete.wc.FormatMsg(s.onComplete.msg, widthAccumulator, widthDistributor)
6061 }
6162
62 var str string
63 timeRemaining := time.Duration(st.Total-st.Current) * time.Duration(round(s.mAverage.Value()))
63 v := round(s.mAverage.Value())
64 if math.IsInf(v, 0) || math.IsNaN(v) {
65 v = .0
66 }
67 timeRemaining := time.Duration(st.Total-st.Current) * time.Duration(v)
6468 hours := int64((timeRemaining / time.Hour) % 60)
6569 minutes := int64((timeRemaining / time.Minute) % 60)
6670 seconds := int64((timeRemaining / time.Second) % 60)
6771
72 var str string
6873 switch s.style {
6974 case ET_STYLE_GO:
7075 str = fmt.Sprint(time.Duration(timeRemaining.Seconds()) * time.Second)