From: Andrew Ruthven Date: Sat, 7 Jul 2012 02:19:29 +0000 (+1200) Subject: If the next scheduled recording is in more than 1 day, then use days. X-Git-Tag: debian-sid-0.10.2-1~8 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd3fb126deebc593c066a0649ac67dba67d0255f;p=mythtv-status.git If the next scheduled recording is in more than 1 day, then use days. --- 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;