mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make the elapsed time display in the jobs dialog more human friendly. Fixes #1719059 [Show hours run in jobs window](https://bugs.launchpad.net/calibre/+bug/1719059)
This commit is contained in:
parent
be464001e2
commit
4bae60751b
@ -38,6 +38,24 @@ class AdaptSQP(SearchQueryParser):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def human_readable_interval(secs):
|
||||||
|
secs = int(secs)
|
||||||
|
days = secs // 86400
|
||||||
|
hours = secs // 3600 % 24
|
||||||
|
minutes = secs // 60 % 60
|
||||||
|
seconds = secs % 60
|
||||||
|
parts = []
|
||||||
|
if days > 0:
|
||||||
|
parts.append('%dd' % days)
|
||||||
|
if hours > 0:
|
||||||
|
parts.append('%dh' % hours)
|
||||||
|
if minutes > 0:
|
||||||
|
parts.append('%dm' % minutes)
|
||||||
|
if secs > 0:
|
||||||
|
parts.append('%ds' % seconds)
|
||||||
|
return ' '.join(parts)
|
||||||
|
|
||||||
|
|
||||||
class JobManager(QAbstractTableModel, AdaptSQP): # {{{
|
class JobManager(QAbstractTableModel, AdaptSQP): # {{{
|
||||||
|
|
||||||
job_added = pyqtSignal(int)
|
job_added = pyqtSignal(int)
|
||||||
@ -128,7 +146,7 @@ class JobManager(QAbstractTableModel, AdaptSQP): # {{{
|
|||||||
rtime = job.running_time
|
rtime = job.running_time
|
||||||
if rtime is None:
|
if rtime is None:
|
||||||
return None
|
return None
|
||||||
return ('%dm %ds'%(int(rtime)//60, int(rtime)%60))
|
return human_readable_interval(rtime)
|
||||||
if col == 4 and job.start_time is not None:
|
if col == 4 and job.start_time is not None:
|
||||||
return (strftime(u'%H:%M -- %d %b', time.localtime(job.start_time)))
|
return (strftime(u'%H:%M -- %d %b', time.localtime(job.start_time)))
|
||||||
if role == Qt.DecorationRole and col == 0:
|
if role == Qt.DecorationRole and col == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user