I don't think you need specify the start/end date unless you want override the value of the current time or specify a different time interval. Perl can figure out the current time and add 1 week to that just fine. Here is a relatively verbose example which I hope gives you a starting point. It only uses Date::Manip for determining the date when specified on the cmdline.
Not sure if you wanted to help on finding the files which actually matched this range too? Readup on localtime to see which array slots code for the values you want and stat to see the information on how to determine when a file was updated/created/last accessed.
#!/usr/bin/perl -w
use strict;
use POSIX;
use Getopt::Long;
use Date::Manip;
use constant SECONDS_IN_MINUTE => 60;
use constant MINUTES_IN_HOUR => 60;
use constant HOURS_IN_DAY => 24;
use constant DAYS_IN_WEEK => 7;
# set some defaults
my $sdate = time;
my $weekseconds = SECONDS_IN_MINUTE * MINUTES_IN_HOUR *
HOURS_IN_DAY * DAYS_IN_WEEK;
my $edate = $sdate + ( $weekseconds );
# which can be overridden by your cmd line options
# I didn't add anything for the -brtype etc
GetOptions(
'sdate:s' => sub { $sdate = &process_date($_[1])},
'edate:s' => sub { $edate = &process_date($_[1])});
printf("start time is %s, end time is %s\n",
strftime("%d %b %Y %H:%M:%S", localtime($sdate)),
strftime("%d %b %Y %H:%M:%S", localtime($edate)));
sub process_date {
my $d = shift;
my $date = &ParseDate($d);
if( ! $date ) {
die("cannot determine date from $d\n");
}
return &UnixDate($date, "%s");
}
|