- wgint eta;
- int eta_hrs, eta_min, eta_sec;
-
- /* Don't change the value of ETA more than approximately once
- per second; doing so would cause flashing without providing
- any value to the user. */
- if (bp->total_length != size
- && bp->last_eta_value != 0
- && dl_total_time - bp->last_eta_time < 900)
- eta = bp->last_eta_value;
- else
- {
- /* Calculate ETA using the average download speed to predict
- the future speed. If you want to use a speed averaged
- over a more recent period, replace dl_total_time with
- hist->total_time and bp->count with hist->total_bytes.
- I found that doing that results in a very jerky and
- ultimately unreliable ETA. */
- double time_sofar = (double)dl_total_time / 1000;
- wgint bytes_remaining = bp->total_length - size;
- eta = (wgint) (time_sofar * bytes_remaining / bp->count);
- bp->last_eta_value = eta;
- bp->last_eta_time = dl_total_time;
- }
-
- eta_hrs = eta / 3600, eta %= 3600;
- eta_min = eta / 60, eta %= 60;
- eta_sec = eta;
-
- if (eta_hrs > 99)
- goto no_eta;
-
- if (eta_hrs == 0)
+ /* " eta ..m ..s"; wait for three seconds before displaying the ETA.
+ That's because the ETA value needs a while to become
+ reliable. */
+ if (bp->total_length > 0 && bp->count > 0 && dl_total_time > 3000)