1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
Description: The value of right bracket time can render negative when averagetime is zero. Making it zero explicitly if that is the case.
This is definitely not the best way to fix it, hence forwarded upstream with the problem
Author: Nilesh Patra <nilesh@debian.org>
Forwarded: https://github.com/schollz/progressbar/issues/103
Last-Update: 2021-06-26
--- a/progressbar.go
+++ b/progressbar.go
@@ -730,6 +730,11 @@
if c.predictTime {
leftBrac = (time.Duration(time.Since(s.startTime).Seconds()) * time.Second).String()
rightBrac = (time.Duration((1/averageRate)*(float64(c.max)-float64(s.currentNum))) * time.Second).String()
+ zerosec, _ := time.ParseDuration("0s")
+ rightsec, _ := time.ParseDuration(rightBrac)
+ if rightsec.Seconds() < zerosec.Seconds() {
+ rightBrac = "0s"
+ }
}
if c.fullWidth && !c.ignoreLength {
|