summaryrefslogtreecommitdiff
path: root/src/lib/job.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-12-21 16:15:16 +0000
committerCarl Hetherington <cth@carlh.net>2016-12-21 16:15:16 +0000
commit944ee5eafb01705e31076fe0dbd0b38003dfbb55 (patch)
tree266cea64f1258a5a8fa7e1e81d5a4c175d24f0cc /src/lib/job.cc
parentdc334f75b92a1a5480041ad7b351ee9d4cd77187 (diff)
Add approximate finish time to progress on jobs (#927).
Diffstat (limited to 'src/lib/job.cc')
-rw-r--r--src/lib/job.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/lib/job.cc b/src/lib/job.cc
index 167692863..dba21f91c 100644
--- a/src/lib/job.cc
+++ b/src/lib/job.cc
@@ -34,6 +34,7 @@
#include <boost/thread.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>
#include "i18n.h"
@@ -411,9 +412,22 @@ Job::status () const
s += buffer;
if (t > 10 && r > 0) {
- /// TRANSLATORS: remaining here follows an amount of time that is remaining
- /// on an operation.
- s += "; " + seconds_to_approximate_hms (r) + " " + _("remaining");
+ boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
+ boost::posix_time::ptime finish = now + boost::posix_time::seconds(r);
+ char finish_string[6];
+ snprintf (finish_string, sizeof(finish_string), "%02d:%02d", finish.time_of_day().hours(), finish.time_of_day().minutes());
+ string day;
+ if (now.date() != finish.date()) {
+ /// TRANSLATORS: the %1 in this string will be filled in with a day of the week
+ /// to say what day a job will finish.
+ day = String::compose (_(" on %1"), finish.date().day_of_week().as_long_string());
+ }
+ /// TRANSLATORS: "remaining; finishing at" here follows an amount of time that is remaining
+ /// on an operation; after it is an estimated wall-clock completion time.
+ s += String::compose(
+ _("; %1 remaining; finishing at %2%3"),
+ seconds_to_approximate_hms(r), finish_string, day
+ );
}
} else if (finished_ok ()) {
s = String::compose (_("OK (ran for %1)"), seconds_to_hms (_ran_for));