X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fjob.cc;fp=src%2Flib%2Fjob.cc;h=bf0879d926ebb77d0cf9461af9aa8c52fd1d79bc;hp=912c6a6ef3c961374a81bd4863509a94d0c524f2;hb=29e45a5b851a3117ef568c72a4aab068a80a3430;hpb=556d0dfce7577d6bad33d246a37f00a7627c295a diff --git a/src/lib/job.cc b/src/lib/job.cc index 912c6a6ef..bf0879d92 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "i18n.h" @@ -59,7 +60,6 @@ Job::Job (shared_ptr film) , _start_time (0) , _sub_start_time (0) , _progress (0) - , _ran_for (0) { } @@ -351,7 +351,7 @@ Job::set_state (State s) _state = s; if (_state == FINISHED_OK || _state == FINISHED_ERROR || _state == FINISHED_CANCELLED) { - _ran_for = time(0) - _start_time; + _finish_time = time(nullptr); finished = true; _sub_name.clear (); } @@ -589,7 +589,19 @@ Job::status () const ); } } else if (finished_ok ()) { - s = String::compose (_("OK (ran for %1)"), seconds_to_hms (_ran_for)); + auto time_string = [](time_t time) { + auto tm = localtime(&time); + char buffer[8]; + snprintf(buffer, sizeof(buffer), "%02d:%02d", tm->tm_hour, tm->tm_min); + return string(buffer); + }; + auto const duration = _finish_time - _start_time; + if (duration < 600) { + /* It took less than 10 minutes; it doesn't seem worth saying when it started and finished */ + s = String::compose(_("OK (ran for %1)"), seconds_to_hms(duration)); + } else { + s = String::compose(_("OK (ran for %1 from %2 to %3)"), seconds_to_hms(duration), time_string(_start_time), time_string(_finish_time)); + } } else if (finished_in_error ()) { s = String::compose (_("Error: %1"), error_summary ()); } else if (finished_cancelled ()) {