\n};
#foreach my $key ( sort keys %arr) { print qq{K: $key V: $arr{$key} \n}; }
# Passed either $arr{date} or $arr{startdate} and $arr{enddate}
# if date is could be today, yesterday, thisweek, or lastweek.
# if today or yesterday, set $singleDay; other cases set startdate and enddate.
# Set Dates - FIX THIS AFTER DONE; remove stuff we don't need.
#($sec, $min, $hour, $mday, $mon, $year, $wday,
# $yday, $iddst) = localtime(time);
my @tim = localtime(time);
my $year = $tim[5] + 1900;
my $month = $tim[4] + 1;
my $day = $tim[3];
my $jd = julian_day($year,$month,$day);
if (length($month) == 1){ $month = "0".$month;}
if (length($day) == 1){ $day = "0".$day;}
my $today = "$year-$month-$day";
my $currdate = "$year-$month-$day";
my $currdate1 = "$month[$month] $day, $year";
my $dow = day_of_week($jd + 1); # a number from 0 (Sunday) to 6 (Saturday)
# Branch to different pages
if ( not $arr{page} ) {
showStartPage();
} elsif ($arr{page} == 2) {
delete $arr{page};
writeRecords();
} else { # and continue on below...
delete $arr{page};
}
# foreach my $key ( sort keys %arr) { print qq{K: $key V: $arr{$key} \n}; }
# Now setup date range values.
my ($singleday, $startdate, $enddate, $prevday);
if ( $arr{date} ) {
if ( $arr{date} eq $lex{Today} ) {
$singleday = $currdate;
} elsif ( $arr{date} eq $lex{Yesterday} ) {
my $prevjd;
if ( $dow == 2 ) { # Monday
$prevjd = $jd - 3;
} else {
$prevjd = $jd - 1
}
$singleday = join('-', inverse_julian_day( $prevjd ));
} elsif ( $arr{date} eq $lex{'This Week'} ) {
# set startdate and enddate
my $mondayjd = $jd - ($tim[6]-1); #This will now give Monday of this week.
my $fridayjd = $mondayjd + 4;
my ($y,$m,$d) = inverse_julian_day($mondayjd);
if (length($m) == 1){ $m = "0".$m;}
if (length($d) == 1){ $d = "0".$d;}
$startdate = "$y-$m-$d";
my ($y,$m,$d) = inverse_julian_day($fridayjd);
if (length($m) == 1){ $m = "0".$m;}
if (length($d) == 1){ $d = "0".$d;}
$enddate = "$y-$m-$d";
} elsif ($arr{date} eq $lex{'Last Week'}) {
my $mondayjd = $jd - ($tim[6]-1); #This will now give Monday of this week.
my $mondayjd = $mondayjd - 7; # last monday.
my $fridayjd = $mondayjd + 4; # last friday.
my ($y,$m,$d) = inverse_julian_day($mondayjd);
if (length($m) == 1){ $m = "0".$m;}
if (length($d) == 1){ $d = "0".$d;}
$startdate = "$y-$m-$d";
my ($y,$m,$d) = inverse_julian_day($fridayjd);
if (length($m) == 1){ $m = "0".$m;}
if (length($d) == 1){ $d = "0".$d;}
$enddate = "$y-$m-$d";
} else { # an error... no match
print qq{
$lex{'Missing Date'}
\n};
print qq{\n};
exit;
}
} elsif ($arr{startdate} and $arr{enddate}) {
$startdate = $arr{startdate};
$enddate = $arr{enddate};
} else { # another error... no date or no startdate/enddate
print qq{