Algorithm-Cron

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.05    BUGFIXES:
         * Bugfix to mday+month rollover logic (thanks Nic Sandfield)

0.04    BUGFIXES:
         * Bugfix to mon */skip globbing (thanks Nic Sandfield)

0.03    BUGFIXES:
         * Bugfix to month rollover logic (thanks Nic Sandfield)

0.02    BUGFIXES:
         * Generate mday and wday names in C locale

0.01    First version, released on an unsuspecting world.

README  view on Meta::CPAN

     hour => "3-6"
     hour => "3,4,5,6"

    Ranges can also be prefixed by a value to give the increment for values
    in that range.

     min => "*/10"
     min => "0,10,20,30,40,50"

    The `mon' and `wday' fields also allow symbolic month or weekday names
    in place of numeric values. These names are always in the C locale,
    regardless of the system's locale settings.

     mon => "mar-sep"

     wday => "mon,wed,fri"

    Specifying `sun' as the end of a `wday' range, or giving the numeric
    value of `7' is also supported.

     wday => "fri-sun"
     wday => "5-7"

lib/Algorithm/Cron.pm  view on Meta::CPAN


use strict;
use warnings;

our $VERSION = '0.10';

my @FIELDS = qw( sec min hour mday mon year wday );
my @FIELDS_CTOR = grep { $_ ne "year" } @FIELDS;

use Carp;
use POSIX qw( mktime strftime setlocale LC_TIME );
use Time::timegm qw( timegm );

=head1 NAME

C<Algorithm::Cron> - abstract implementation of the F<cron(8)> scheduling
algorithm

=head1 SYNOPSIS

 use Algorithm::Cron;

lib/Algorithm/Cron.pm  view on Meta::CPAN

 hour => "3-6"
 hour => "3,4,5,6"

Ranges can also be prefixed by a value to give the increment for values in
that range.

 min => "*/10"
 min => "0,10,20,30,40,50"

The C<mon> and C<wday> fields also allow symbolic month or weekday names in
place of numeric values. These names are always in the C locale, regardless of
the system's locale settings.

 mon => "mar-sep"

 wday => "mon,wed,fri"

Specifying C<sun> as the end of a C<wday> range, or giving the numeric value
of C<7> is also supported.

 wday => "fri-sun"
 wday => "5-7"

lib/Algorithm/Cron.pm  view on Meta::CPAN

   hour => 23,
   mday => 31,
   mon  => 11,
   wday => 6,
);

my %MONTHS;
my %WDAYS;
# These always want to be in LC_TIME=C
{
   my $old_loc = setlocale( LC_TIME );
   setlocale( LC_TIME, "C" );

   %MONTHS = map { lc(strftime "%b", 0,0,0, 1, $_, 70), $_ } 0 .. 11;

   # 0 = Sun. 4th Jan 1970 was a Sunday
   %WDAYS  = map { lc(strftime "%a", 0,0,0, 4+$_, 0, 70), $_ } 0 .. 6;

   setlocale( LC_TIME, $old_loc );
}

sub _expand_set
{
   my ( $spec, $kind ) = @_;

   return undef if $spec eq "*";

   my @vals;
   foreach my $val ( split m/,/, $spec ) {



( run in 2.203 seconds using v1.01-cache-2.11-cpan-ceb78f64989 )