From a2bd75784cd7449c0ef3fd8c2020d02a319a9c97 Mon Sep 17 00:00:00 2001 From: Julian Gilbey Date: Sat, 7 Jul 2012 14:07:39 +1200 Subject: [PATCH] Change the DateCalc mode to resolve showing negative times for the next recording. Julian's bug report: Hello Andrew! I noticed a bizarre behaviour of mythtv-status: at 9pm, when the next recording was due at about 6pm the next day, it reported: "Next Recording In: -3 Hours, -7 Minutes", which is clearly nonsense. The attached patch fixes this, and two other bugs: - if the next recording is in longer than 1 day, it now gives the correct time - if the time is 1 Hour, 1 Minute, it says this correctly (instead of saying 1 Hour, 1 Minutes) --- bin/mythtv-status | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/mythtv-status b/bin/mythtv-status index c63394d..80e5336 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -439,11 +439,11 @@ my @blocks = ( if $next_time eq 'Never' || $next_time eq 'now'; my $err; - my $delta = DateCalc('now', $next_time, \$err, 1); + my $delta = DateCalc('now', $next_time, \$err, 0); my $str = Delta_Format($delta, 0, '%hh Hours, %mv Minutes'); - my $seconds = Delta_Format($delta, 0, '%sh'); + my $seconds = Delta_Format($delta, 'approx', 0, '%sh'); - $str =~ s/\b1 (Hour|Minute)s/1 $1/; + $str =~ s/\b1 (Hour|Minute)s/1 $1/g; $str =~ s/^0 Hours, //; $str =~ s/ 0 Minutes//; -- 2.30.2