#!/usr/bin/perl -w
##########################################################################
# $Id: applydate,v 1.1 2002/10/27 14:05:40 kirk Exp $
##########################################################################

use POSIX qw(strftime);

my $time = time;

if ( $ENV{'LOGWATCH_DATE_RANGE'} eq 'yesterday') {
   $SearchDate = strftime("%a %b %d", localtime($time-86400));
   $SearchYear = strftime("%Y", localtime($time-86400));
}
elsif ( $ENV{'LOGWATCH_DATE_RANGE'} eq 'today') {
   $SearchDate = strftime("%a %b %d", localtime($time));
   $SearchYear = strftime("%Y", localtime($time));
}
elsif ( $ENV{'LOGWATCH_DATE_RANGE'} eq 'all') {
   $SearchDate = "... ... ..";
   $SearchYear = "....";
}

# Make sure '01' becomes '.1' so it will match ' 1'
$SearchDate =~ s/0(\d)/.$1/;

while (defined($ThisLine = <STDIN>)) {
   if ($ThisLine =~ s/$SearchDate ..:..:.. [^ ]+ $SearchYear - //o) {
      print $ThisLine;
   }
}

