Cover V12, I05
may2003.tar

Listing 2 Create the CACHEFILE parameter for a date range

# Creates a list of CACHEFILE parameters that can be substituted into
# the Analog Config File. A CACHEFILE parameter is created naming the specific
# cache file for the virtual host and date
sub createCacheFileStr {
    my ($path, $vhost, $from, $to) = @_[0..3];
    my $cachefilestr;
    
    my @date_list  = getDateRangeArray($from, $to);
    
#   Creates the parameter for every date in the array
    for my $date (@date_list) {
            my ($year, $month, $day) = split /-/, $date;
            if ( length($cachefilestr) != 0) { $cachefilestr .= "CACHEFILE "; }
            $cachefilestr .= "$path/$vhost/$year/$month/${date}.cache\n";
    }
    return $cachefilestr;
}

# Creates an array of all dates between From ($_[0]) and To ($_[1])
sub getDateRangeArray {
    my ($from_yr, $from_mt, $from_day)      = zeroPadDate(split /-/, $_[0]);
    my ($to_yr,   $to_mt,   $to_day)        = zeroPadDate(split /-/, $_[1]);
    my @local_date_list;

    ($to_yr, $to_mt, $to_day) = zeroPadDate(
Add_Delta_YMD($to_yr, $to_mt, $to_day,0,0,1)
);

    while ( !($from_yr == $to_yr  && $from_mt == $to_mt && $from_day == $to_day )) {
        push @local_date_list, "$from_yr-$from_mt-$from_day";
        ($from_yr, $from_mt, $from_day) = zeroPadDate(
Add_Delta_YMD ($from_yr, $from_mt, $from_day, 0, 0, 1));
    }
    return @local_date_list;
}

# All month and day strings must be two characters.
sub zeroPadDate {
    my ($year, $month, $day) = @_[0..2];
    if ( length($month) == 1 )   { $month  = '0' . $month; }
    if ( length($day)   == 1 )   { $day    = '0' . $day;   }
    return ($year, $month, $day);
}