Description
Description
At present the remaining time on the progress bar is not that helpful. If the remaining time is between 24 and 47 hours it will just read "1 days remaining".
Similarly if the time remaining is 1 hour 55 minutes, the text will actually display "1 hour remaining".
Obviously this isn't that helpful when planning around a process finishing.
In all my projects I now add this:
ProgressBar::setPlaceholderFormatterDefinition('remaining', function($bar) {
$remaining = $bar->getRemaining();
$hours = floor($remaining / 3600);
$minutes = floor(($remaining / 60) % 60);
$seconds = $remaining % 60;
return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
});
With this, when using the format: %current%/%max% [%bar%] %percent:3s%% %elapsed:6s% taken %remaining:-6s% remaining
, I will get the following:
This: 5/169200 [>---------------------------] 0% 5 secs taken 46:59:55 remaining
Instead of this: 5/169200 [>---------------------------] 0% 5 secs taken 1 day remaining
Or in the case of a 1 hour 48 minute process:
This: 5/6500 [>---------------------------] 0% 5 secs taken 01:48:15 remaining
Instead of this: 5/6500 [>---------------------------] 0% 5 secs taken 1 hr remaining
This could be implemented by updating Symfony\Component\Console\Helper
To use the same logic as above. Although this would have the side effect of changing all dates. So it would in fact look like this:
5/6500 [>---------------------------] 0% 00:00:05 taken 01:48:15 remaining
I don't have an issue with that, but perhaps it's not desired?
I can create a PR if this is okay, but i've never contributed to Symfony before so figured I would start by creating an issue.
Example
No response