Cron-Toolkit

 view release on metacpan or  search on metacpan

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

      }

      # flip if no match found in this field
      $tm = $self->_set_date( $tm, $node->field_type, $lowval );
      $tm = $self->_plus_one( $tm, $self->{nodes}[ $i + 1 ]->field_type );
   }

   # 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

   my $max_tm = Time::Moment->new( year => 2099, month => 12, day => 31,
                                   hour => 23, minute => 59, second => 59 );
   my $max_iter = $tm->delta_days($max_tm) || 1;

   for my $day ( 1 .. $max_iter ) {
      return $tm->epoch if $self->_is_match($tm);
      $tm = $tm->plus_days(1);
   }
   return;



( run in 0.543 second using v1.01-cache-2.11-cpan-4ab04211f4c )