From: Andrew Ruthven Date: Tue, 29 Jan 2013 03:43:53 +0000 (+1300) Subject: If ISODate is present and is UTC, convert that to localtime and display it. X-Git-Tag: 0.10.4~14 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7b4d4a72a3f4a5de33c9b79e3ddcf963e9c9eff;p=mythtv-status.git If ISODate is present and is UTC, convert that to localtime and display it. --- diff --git a/ChangeLog b/ChangeLog index a55019a..71058bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-01-29 Andrew Ruthven + MythTV 0.26 now uses UTC in the time/date attributes in Status. + We now convert it to the local timezone. + 2012-07-07 Andrew Ruthven Switch to using the exact mode when working out the time to the next recording. Also, if the next recording is in 1 Hour, 1 Minute diff --git a/bin/mythtv-status b/bin/mythtv-status index 93ea250..403f090 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -19,6 +19,7 @@ use LWP::UserAgent; use XML::LibXML; use Date::Manip; +use Date::Manip::Date; use Getopt::Long; use Text::Wrap; use POSIX qw/strftime :sys_wait_h/; @@ -86,7 +87,7 @@ my @size_thresholds = ( my $return_code_only = 0; -my $VERSION = '0.10.2'; +my $VERSION = '0.10.3'; # Some display blocks are disabled by default: $c->{'display'}{'Shows due to Auto Expire'} = 0; @@ -206,9 +207,33 @@ my @blocks = ( 'name' => 'Status', 'type' => 'xpath', 'xpath' => "//Status", - 'attrs' => [ qw/time date/ ], - 'template' => "__date__, __time__", - 'format' => 'one line' + 'attrs' => [ qw/ISODate time date/ ], + 'template' => "__date__", + 'format' => 'one line', + 'rewrite' => { + '&date' => sub { + my ($value, $vars) = @_; + + if ($vars->{ISODate} =~ /Z$/) { + # 2012-10-17T23:50:08Z + my $d = new Date::Manip::Date; + $d->parse($vars->{ISODate}); + + # Work out our local timezone. The Date::Manip::Date + # docs say that convert will default to the local timezone, + # this appears to be lies. + my $dmb = $d->base(); + my ($tz) = $dmb->_now('tz',1); + $d->convert($tz); + + # Sample of what MythTV uses: + # Thu 18 Oct 2012, 10:20 + return $d->printf("%a %d %b %Y, %H:%M"); + } else { + return $vars->{date} . ", " . $vars->{time}; + } + }, + }, }, # Info about the encoders before TV OSD Declutter (Changeset 20037). diff --git a/debian/changelog b/debian/changelog index e3b93d4..602eb26 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +mythtv-status (0.10.3) unstable; urgency=low + + * New upstream release (Closes: LP#1096252). + + -- Andrew Ruthven Tue, 29 Jan 2013 16:37:53 +1300 + mythtv-status (0.10.2-3) unstable; urgency=low * Fix the use of motd as a facility name, shouldn't be $motd.