report date building bug fixes

git-svn-id: http://scm.dspace.org/svn/repo/trunk@1190 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Richard Jones
2005-04-21 08:14:16 +00:00
parent 1fa8cb061e
commit c3ad17909e
2 changed files with 46 additions and 22 deletions

View File

@@ -92,21 +92,33 @@ $out_directory = "/dspace/log/";
($second, $minute, $hour, $day, $month, $year, $week_day, $day_of_year, $is_dst) = localtime(time); ($second, $minute, $hour, $day, $month, $year, $week_day, $day_of_year, $is_dst) = localtime(time);
# set up the variables to use in the loop # set up the variables to use in the loop
$year_offset = -1 * (($year + 1900) - $start_year);
$no_months = (-1 * $year_offset * 12) + ($month - $start_month + 1); # number of years after the current year (will mostly be negative)
# <current year> = (<perl year> + 1900)
# <start year offset> = <start year> - <current year>
$year_offset = $start_year - ($year + 1900);
# total number of months between now and the start date (negated to be positive in general)
# <months in year offset> = |<start year offset>| * 12
# <difference in current year months> = (<current perl month> + 1) - <start month>
# <total number of months> = <months in year offset> + <difference in current year months>
# we use -1 to make <start year offset> positive since it should always be negative
$no_months = (-1 * ($year_offset * 12)) + (($month + 1) - $start_month);
# start day of every month
$start_day = "01"; $start_day = "01";
# for every month ...
for ($i = 0; $i < $no_months; $i++) for ($i = 0; $i < $no_months; $i++)
{ {
# first get the current month being aggregated, and make sure that the # the month of the year (horrid modular maths)
# year wrapps accordingly $this_month = (($start_month + $i - 1) % 12) + 1;
$this_month = $start_month + $i;
if ($this_month > 12) # number of years gone through since we started the loop
{ $year_count = floor(($i + $start_month - 1) / 12);
$this_month %= 12;
$year_offset++; # the year of the current analysis period
} $this_year = $year + $year_offset + $year_count + 1900;
$this_year = $year + $year_offset + 1900;
# set the end day for the processing # set the end day for the processing
if ($this_month == 1 || $this_month == 3 || $this_month == 5 || $this_month == 7 || $this_month == 8 || $this_month == 10 || $this_month == 12) if ($this_month == 1 || $this_month == 3 || $this_month == 5 || $this_month == 7 || $this_month == 8 || $this_month == 10 || $this_month == 12)

View File

@@ -96,21 +96,33 @@ $out_directory = "/dspace/reports/";
($second, $minute, $hour, $day, $month, $year, $week_day, $day_of_year, $is_dst) = localtime(time); ($second, $minute, $hour, $day, $month, $year, $week_day, $day_of_year, $is_dst) = localtime(time);
# set up the variables to use in the loop # set up the variables to use in the loop
$year_offset = -1 * (($year + 1900) - $start_year);
$no_months = (-1 * $year_offset * 12) + ($month - $start_month + 1); # number of years after the current year (will mostly be negative)
# <current year> = (<perl year> + 1900)
# <start year offset> = <start year> - <current year>
$year_offset = $start_year - ($year + 1900);
# total number of months between now and the start date (negated to be positive in general)
# <months in year offset> = |<start year offset>| * 12
# <difference in current year months> = (<current perl month> + 1) - <start month>
# <total number of months> = <months in year offset> + <difference in current year months>
# we use -1 to make <start year offset> positive since it should always be negative
$no_months = (-1 * ($year_offset * 12)) + (($month + 1) - $start_month);
# start day of every month
$start_day = "01"; $start_day = "01";
# for every month ...
for ($i = 0; $i < $no_months; $i++) for ($i = 0; $i < $no_months; $i++)
{ {
# first get the current month being aggregated, and make sure that the # the month of the year (horrid modular maths)
# year wrapps accordingly $this_month = (($start_month + $i - 1) % 12) + 1;
$this_month = $start_month + $i;
if ($this_month > 12) # number of years gone through since we started the loop
{ $year_count = floor(($i + $start_month - 1) / 12);
$this_month %= 12;
$year_offset++; # the year of the current analysis period
} $this_year = $year + $year_offset + $year_count + 1900;
$this_year = $year + $year_offset + 1900;
# input and output file paths # input and output file paths
$in = $in_directory . $in_prefix . $this_year . "-" . $this_month . $in_suffix; $in = $in_directory . $in_prefix . $this_year . "-" . $this_month . $in_suffix;