David Muir Sharnoff > Log-Parallel-0.303 > Log::Parallel::Durations



Annotate this POD

View/Report Bugs


 Log::Parallel::Durations - parse duration specifications


 use Log::Parallel::Durations;

 my $job = {
        frequency => 'daily',
        timespan => '30 days',
 my $jd = Time::JulianDay::julian_day(2008, 10, 22);
 my $jd_from_limit = Time::JulianDay::julian_day(2008, 8, 22);
 my $jd_to_limit = Time::JulianDay::julian_day(2008, 12, 14);

 ($timespec, @jd_range) = frequency_and_span($job, $jd, $jd_from_limit, $jd_to_limit);


This is a helper module for the process_logs. It parses duration and frequency specifications.

It understands frequencies:

 every 3 days
 every week
 each month on the 13th
 on the 1st each month
 on the 1st of each month
 every Tuesday
 on the 3rd Wednesday of each month

It understands durations:

 3 days
 1 quarter
 2 years

The API meets the needs of process_logs. Given a start time ($jd_from_limit) and an end time ($jd_to_limit) and a particular day ($jd) and a structure that specifies the duration and frequency ($job), it will return undef unless the particular day ($jd) happens to meet the specification. Most jobs are expected to run daily so most of the time this is efficient.

All dates are in Julian Days. Use Time::JulianDay.

See the code for more details.


This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.

syntax highlighting: