This file is indexed.

/usr/bin/tv_augment_tz is in xmltv-util 0.5.63-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/perl

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

=pod

=head1 NAME

tv_augment_tz - Convert floating time to explicit time.

=head1 SYNOPSIS

tv_augment_tz [--help] [--output FILE] [--tz TIMEZONE] [FILE...]

=head1 DESCRIPTION

Read XMLTV data and augment all times with the correct offset. Times that are
already explicit will be converted to TIMEZONE as well.

B<--output FILE> write to FILE rather than standard output

B<--tz TIMEZONE> use TIMEZONE (e.g. Europe/Berlin) rather then the default of UTC

=head1 SEE ALSO

L<xmltv(5)>.

=head1 AUTHOR

Karl Dietz, <dekarl@spaetfruehstuecken.org>

=head1 BUGS

Guessing the right time when local time is abigous doesn't work properly.

=cut

use strict;
use warnings;

use XMLTV::Version '$Id: tv_augment_tz,v 1.1 2012/06/13 06:45:08 dekarl Exp $';

use Encode; # used to convert 'perl strings' into 'utf-8 strings'
use DateTime;
use Getopt::Long;
use XML::LibXML;

use XMLTV;
use XMLTV::Usage <<END
$0: Convert floating local time to explicit local time.
usage: $0 [--help] [--output FILE] [--tz TIMEZONE] [FILE...]
END
;


my ($opt_help, $opt_output, $opt_tz);
GetOptions('help' => \$opt_help,
           'output=s' => \$opt_output,
	   'tz=s' => \$opt_tz
)
  or usage(0);
usage(1) if $opt_help;
@ARGV = ('-') if not @ARGV;

if (!defined ($opt_tz)) {
  $opt_tz = 'UTC';
}

sub parse_date ( $ ) {
  my $raw = shift;
  my ($datetime, $tz) = split (/\s/, $raw);

  my ($year, $month, $day, $hour, $minute, $second) = (0, 0, 0, 0, 0, 0);

  if (length ($datetime) == 4+2+2+2+2+2) {
    ($year, $month, $day, $hour, $minute, $second) = ($datetime =~ m|(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)|);
  } elsif (length ($datetime) == 4+2+2+2+2) {
    ($year, $month, $day, $hour, $minute) = ($datetime =~ m|(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)|);
  } elsif (length ($datetime) == 4+2+2+2) {
    ($year, $month, $day, $hour, $minute) = ($datetime =~ m|(\d\d\d\d)(\d\d)(\d\d)(\d\d)|);
  } elsif (length ($datetime) == 4+2+2) {
    ($year, $month, $day, $hour, $minute) = ($datetime =~ m|(\d\d\d\d)(\d\d)(\d\d)|);
  } elsif (length ($datetime) == 4+2) {
    ($year, $month, $day, $hour, $minute) = ($datetime =~ m|(\d\d\d\d)(\d\d)|);
  } elsif (length ($datetime) == 4) {
    ($year, $month, $day, $hour, $minute) = ($datetime =~ m|(\d\d\d\d)|);
  }

  my $dt = DateTime->new (
    year      => $year,
    month     => $month,
    day       => $day,
    hour      => $hour,
    minute    => $minute,
    second    => $second
  );

  if ($tz) {
    $dt->set_time_zone ($tz);
  }

  return $dt;
}

# load XML
if ($ARGV[0]) {
  open *STDIN, '<', $ARGV[0];
}
binmode *STDIN; # drop all PerlIO layers possibly created by a use open pragma
my $doc = XML::LibXML->load_xml(IO => *STDIN);

my $starttimes = $doc->findnodes ('/tv/programme[@start]');
foreach my $node ($starttimes->get_nodelist ()) {
  my $time = $node->getAttribute ('start');
  $time = parse_date ($time)->set_time_zone ($opt_tz)->strftime ('%Y%m%d%H%M%S %z');
  $node->setAttribute('start', $time);
}

my $stoptimes = $doc->findnodes ('/tv/programme[@stop]');
foreach my $node ($stoptimes->get_nodelist ()) {
  my $time = $node->getAttribute ('stop');
  $time = parse_date ($time)->set_time_zone ($opt_tz)->strftime ('%Y%m%d%H%M%S %z');
  $node->setAttribute('stop', $time);
}

# save modified XML
if ($opt_output) {
  open *STDOUT, '>', $opt_output;
}
binmode *STDOUT; # as above
$doc->toFH(*STDOUT);