From: Andrew Ruthven Date: Sat, 9 Feb 2013 10:55:51 +0000 (+1300) Subject: Process the ISO timestamps for the in progress recordings as well. X-Git-Tag: 0.10.4~10 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82a8b8fd15f7aa3465c6052ab5e75d8223b88b78;p=mythtv-status.git Process the ISO timestamps for the in progress recordings as well. --- diff --git a/bin/mythtv-status b/bin/mythtv-status index f000283..debb240 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -311,8 +311,16 @@ my @blocks = ( . ($c->{'encoder_details'} ? ", Enc: __encoderId__, Chan: __chanNum__" : '') . ") Ends: __endTime__", 'rewrite' => { - '/endTime/' => { '.*T' => '' }, + '&endTime' => sub { + my ($value, $vars) = @_; + + if ($value =~ /Z$/) { + return process_iso_date($value, { date => 0 }); + } else { + return $value =~ s/.*T//; + } }, + }, 'subs' => { 'find_next' => sub { $warn_present ||= 1; $next_time = 'now' } } @@ -934,8 +942,15 @@ sub process_auto_expire { return join("\n", @lines); } +# If either date or time are set to 0, then we don't display that bit of +# info. For example: +# process_iso_date($date, { date => 0 }) +# Will only show the time. sub process_iso_date { my $date = shift; + my $options = shift; + $options->{'date'} //= 1; + $options->{'time'} //= 1; # 2012-10-17T23:50:08Z my $d = new Date::Manip::Date; @@ -950,7 +965,12 @@ sub process_iso_date { # Sample of what MythTV uses: # Thu 18 Oct 2012, 10:20 - return $d->printf("%Y-%m-%d %X"); + my $format = ''; + $format .= '%Y-%m-%d' if $options->{'date'}; + $format .= ' ' if $options->{'date'} && $options->{'time'}; + $format .= '%X' if $options->{'time'}; + + return $d->printf($format); } sub substitute_vars {