From: David Meritt Date: Sun, 30 Dec 2018 09:46:04 +0000 (+1300) Subject: Finally fix time till next recording. X-Git-Tag: 1.0.0~41 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ce4a30d53459ef44fa5048b14c2a1bd15cffc7b;p=mythtv-status.git Finally fix time till next recording. The Delta_Format method sometimes uses negative numbers, like: Next Recording In: 1 Day, -1 Hour, -34 Minutes This is painful to try and pass. This commit finally resolves this long standing annoyance and now uses: Next Recording In: 22 Hours, 25 Minutes Thanks David for the patch, I was about to fix this myself once and for all when I re-discovered your patch. --- diff --git a/bin/mythtv-status b/bin/mythtv-status index 68175bc..fb76a8f 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -625,19 +625,26 @@ my @blocks = ( my $err; my $delta = DateCalc($c->{'date'} || 'now', $next_time, \$err, 1); my $seconds = Delta_Format($delta, 'approx', 0, '%sh'); + my $remsec = $seconds; # Remaining seconds + my $str = ''; - # If the next recording is more than 1 day in the future, - # print out the days and hours. - my $str; - if ($seconds > 24 * 3600) { - $str = Delta_Format($delta, 0, '%dh Days, %hv Hours'); - } else { - $str = Delta_Format($delta, 0, '%hh Hours, %mv Minutes'); + # Days + if ($remsec > 24 * 3600) { + $str = sprintf("%d Days, ", $remsec / 24 / 3600); + $remsec = $remsec % (24 * 3600); } - + # Hours + if ($remsec > 3600) { + $str .= sprintf("%d Hours, ", $remsec / 3600); + $remsec = $remsec % 3600; + } + # Minutes + if ($remsec > 60) { + $str .= sprintf("%d Minutes", $remsec / 60); + } + # Clean up the string. + $str =~ s/, $//; $str =~ s/\b1 (Day|Hour|Minute)s/1 $1/g; - $str =~ s/\b0 (Days|Hours)(, )?//; - $str =~ s/, 0 Minutes$//; if ($seconds <= $c->{'recording_in_warn'}) { $warn_present ||= 1; diff --git a/debian/changelog b/debian/changelog index a85caa4..522891c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,6 @@ mythtv-status (0.10.8-1.1) UNRELEASED; urgency=medium - * New upstream release. + * New upstream release (Closes #853857). -- Andrew Ruthven Mon, 12 Nov 2018 23:19:17 +1300