Show elapsed time as D:HH:MM:SS after 1 day, to match the ETA format

This commit is contained in:
Andrew Wood
2023-07-16 22:29:18 +01:00
parent bcb33ce2aa
commit 001dfb71c2
3 changed files with 17 additions and 5 deletions
+1
View File
@@ -4,6 +4,7 @@ UNRELEASED
* fix: workaround for OS X 11 behaviour in configure script regarding stat64 at compile time (pull request [#57](https://github.com/a-j-wood/pv/pull/57) supplied by [Dave Beckett](https://github.com/dajobe))
* fix: add burst rate limit to transfer, so rate limits are not broken by bursty traffic (pull request [#62](https://github.com/a-j-wood/pv/pull/62) supplied by [Volodymyr Bychkovyak](https://github.com/vbychkoviak))
* fix: corrected "`--force`" option so it will still output progress when not in the same process group as the owner of the terminal - corrects [GH#23 "No output with "`-f`" when run in background after 1.6.6"](https://github.com/a-j-wood/pv/issues/23) and helps to correct [GH#31 "No output written from inside zsh <() construct"](https://github.com/a-j-wood/pv/issues/31)
* fix: corrected elapsed time display to show as D:HH:MM:SS after 1 day, like the ETA does - corrects [GH#16 "Show days in same format in ETA as in elapsed time"](https://github.com/a-j-wood/pv/issues/16)
* feature: the "`--size`" option now accepts "`@filename`" to use the size of another file (pull request [#57](https://github.com/a-j-wood/pv/pull/57) supplied by [Dave Beckett](https://github.com/dajobe))
* feature: the "`--watchfd`" option is now available on OS X (pull request [#60](https://github.com/a-j-wood/pv/pull/60) supplied by [christoph-zededa](https://github.com/christoph-zededa))
* feature: new "`--average-rate-window`" option, to set the window over which the average rate is calculated, also used for ETA (modified from pull request [#65](https://github.com/a-j-wood/pv/pull/65) supplied by [lemonsqueeze](https://github.com/lemonsqueeze))
-1
View File
@@ -5,7 +5,6 @@ Bugs
* ([GH#5](https://github.com/a-j-wood/pv/issues/5)) Transfer IPC leadership on exit of leader
* ([GH#13](https://github.com/a-j-wood/pv/issues/13)) Use `clock_gettime()` in ETA calculation to cope with machine suspend/resume (Mateju Miroslav)
* ([GH#16](https://github.com/a-j-wood/pv/issues/16)) Show days in same format in ETA as in elapsed time
* ([GH#18](https://github.com/a-j-wood/pv/issues/18)) No output in Cygwin from 1.6.19 onwards (Jacek M. Holeczek)
* ([GH#20](https://github.com/a-j-wood/pv/issues/20)) Terminal state is not restored correctly in all cases (VA)
* ([GH#24](https://github.com/a-j-wood/pv/issues/24)) Race condition with multiple "`pv -c`" leaves terminal state inconsistent (Lars Ellenberg, Viktor Ashirov)
+16 -4
View File
@@ -702,10 +702,22 @@ static char *pv__format(pvstate_t state,
if (elapsed_sec > (long double) 360000000.0L)
elapsed_sec = (long double) 360000000.0L;
sprintf(state->str_timer, "%ld:%02ld:%02ld",
((long) elapsed_sec) / 3600,
(((long) elapsed_sec) / 60) % 60,
((long) elapsed_sec) % 60);
/*
* If the elapsed time is more than a day, include a day count as
* well as hours, minutes, and seconds.
*/
if (elapsed_sec > (long double) 86400.0L) {
sprintf(state->str_timer, "%ld:%02ld:%02ld:%02ld",
((long) elapsed_sec) / 86400,
(((long) elapsed_sec) / 3600) % 24,
(((long) elapsed_sec) / 60) % 60,
((long) elapsed_sec) % 60);
} else {
sprintf(state->str_timer, "%ld:%02ld:%02ld",
((long) elapsed_sec) / 3600,
(((long) elapsed_sec) / 60) % 60,
((long) elapsed_sec) % 60);
}
}
/* Rate - set up the display string. */