Fix scheduler table displaying intervals greater than 24 hours

This commit is contained in:
JonnyWong16 2019-04-27 16:58:23 -07:00
parent 81d443f34c
commit ce4bfd56c2
2 changed files with 15 additions and 8 deletions

View file

@ -10,9 +10,9 @@ DOCUMENTATION :: END
</%doc>
<%!
import arrow
import datetime
import plexpy
from plexpy import common
from plexpy import common, helpers
scheduled_jobs = [j.id for j in plexpy.SCHED.get_jobs()]
%>
@ -32,15 +32,14 @@ DOCUMENTATION :: END
% if job in scheduled_jobs:
<%
sched_job = plexpy.SCHED.get_job(job)
run_interval = arrow.get(str(sched_job.trigger.interval), ['H:mm:ss', 'HH:mm:ss'])
next_run_interval = arrow.get(sched_job.next_run_time).timestamp - arrow.now().timestamp
now = datetime.datetime.now(sched_job.next_run_time.tzinfo)
%>
<tr>
<td>${sched_job.id}</td>
<td><i class="fa fa-sm fa-fw fa-check"></i> Active</td>
<td>${arrow.get(run_interval).format('HH:mm:ss')}</td>
<td>${arrow.get(next_run_interval).format('HH:mm:ss')}</td>
<td>${arrow.get(sched_job.next_run_time).format('YYYY-MM-DD HH:mm:ss')}</td>
<td>${helpers.format_timedelta_Hms(sched_job.trigger.interval)}</td>
<td>${helpers.format_timedelta_Hms(sched_job.next_run_time - now)}</td>
<td>${sched_job.next_run_time.strftime('%Y-%m-%d %H:%M:%S')}</td>
</tr>
% elif job in ('Check for server response', 'Check for active sessions', 'Check for recently added items') and plexpy.WS_CONNECTED:
<tr>

View file

@ -252,6 +252,14 @@ def human_duration(s, sig='dhms'):
return hd
def format_timedelta_Hms(td):
s = td.total_seconds()
hours = s // 3600
minutes = (s % 3600) // 60
seconds = s % 60
return '{:02d}:{:02d}:{:02d}'.format(int(hours), int(minutes), int(seconds))
def get_age(date):
try: