From cd3fb126deebc593c066a0649ac67dba67d0255f Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 7 Jul 2012 14:19:29 +1200 Subject: [PATCH] If the next scheduled recording is in more than 1 day, then use days. --- ChangeLog | 3 +++ bin/mythtv-status | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67ebe1b..45f09ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ If the next recording is in $x Hours, 0 Minutes, remove the comma as well, previously it was outputing "$x Hours,". + If the next recording is in more than 1 day, then switch to showing + it in days and hours, for example "1 Day, 2 Hours". + 2012-07-06 Andrew Ruthven Correctly handle UTF-8 in the output from MythTV. diff --git a/bin/mythtv-status b/bin/mythtv-status index 17e6857..df4ef89 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -440,12 +440,20 @@ my @blocks = ( my $err; my $delta = DateCalc('now', $next_time, \$err, 0); - my $str = Delta_Format($delta, 0, '%hh Hours, %mv Minutes'); my $seconds = Delta_Format($delta, 'approx', 0, '%sh'); - $str =~ s/\b1 (Hour|Minute)s/1 $1/g; - $str =~ s/^0 Hours, //; - $str =~ s/, 0 Minutes//; + # 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, '%dd Days, %hv Hours'); + } else { + $str = Delta_Format($delta, 0, '%hh Hours, %mv Minutes'); + } + + $str =~ s/\b1 (Day|Hour|Minute)s/1 $1/g; + $str =~ s/(, )?0 Hours(, )?//; + $str =~ s/, 0 Minutes$//; if ($seconds <= $c->{'recording_in_warn'}) { $warn_present ||= 1; -- 2.30.2