#!/usr/bin/perl
use IO::Socket;
use Date::Manip;
&Date_Init("Language=German","DateFormat=non-US");

push (@INC, "./inc");
require ("helperfunc.pl");

$delete1 = UnixDate(DateCalc("heute", "- 2 tage",\$err,0),"%d");
$delete2 = UnixDate(DateCalc("heute", "- 3 tage",\$err,0),"%d");
$delete3 = UnixDate(DateCalc("heute", "- 4 tage",\$err,0),"%d");
$delete4 = UnixDate(DateCalc("heute", "- 5 tage",\$err,0),"%d");
$delete5 = UnixDate(DateCalc("heute", "- 6 tage",\$err,0),"%d");

my ($sim,$verbose) = 0;
my $Dest = "localhost";
my $Port = 2001;

our $SVDRP = SVDRP->new($Dest,$Port,$verbose,$sim);

$SVDRP->command("lstt");
while($_ = $SVDRP->readoneline) {
	chomp;
	last if(/^No timers defined/);
	my($id, $temp) = split(/ /, $_, 2);
	my($tmstatus, $vdr_id, $dor, $start, $stop, $prio, $lft, $title, $summary) = split(/\:/, $temp, 9);
if ($dor < 10) {
  $dor = "0$dor";
  }
 if ($dor eq $delete1 || $dor eq $delete2 || $dor eq $delete3 || $dor eq $delete4 || $dor eq $delete5) {
   push @delete, $id;
   }
}

deltimers(@delete);
$SVDRP->close;
