Cron-Toolkit
view release on metacpan or search on metacpan
lib/Cron/Toolkit.pm view on Meta::CPAN
hour => 23,
minute => 59,
second => 59,
);
my $max_iter = $tm->delta_days($max_tm);
# the brute force approach for DMY is correct here because:
# 1) the design is simple and easy to understand and debug
# 2) solves all tricky end-of-month and leap year calculations
# 3) 365 iterations per one-year time window is good enough
for my $day ( 1 .. $max_iter ) {
return $tm->epoch if $self->_is_match($tm);
$tm = $tm->plus_days(1);
}
return;
}
sub previous {
my ( $self, $epoch_seconds ) = @_;
lib/Cron/Toolkit.pm view on Meta::CPAN
$tm = $self->_minus_one( $tm, $self->{nodes}[ $i + 1 ]->field_type );
}
# set year
my $year_node = $self->{nodes}[6];
my $year_highval = $year_node->highest($tm);
my $tm_year_high = $self->_set_date( $tm, $year_node->field_type, $year_highval );
$tm_year_high = $self->_plus_one( $tm_year_high, $year_node->field_type );
$tm = $tm_year_high if $tm->is_after($tm_year_high);
# calculate maximum iterations
my $min_tm = Time::Moment->new(
year => 1970,
month => 1,
day => 1,
hour => 0,
minute => 0,
second => 0,
);
my $min_iter = $min_tm->delta_days($tm);
( run in 1.459 second using v1.01-cache-2.11-cpan-96521ef73a4 )