DateTime::Cron::Simple(3pm)

DateTime::Cron::Simple3pm

Parse a cron entry and check against current time

Usage

  use DateTime::Cron::Simple;
  $c = DateTime::Cron::Simple->new($cron);
  $boolean = $c->validate_time;
  $c->new_cron($cron);

Overview

This module is a quick and dirty way to determine if a cron time format is valid for the current date and time.

A cron entry follows the cron format from crontab(5).

The validate_time function uses the current date and time for comparison, but will also accept a valid DateTime object as a parameter.

Functions

new
    $c = DateTime::Cron::Simple->new('0-59/2 10,12 * * 5');

Creates a cron entry.

new_cron
    $c->new_cron($cron);

Updates the cron entry to the given argument.

validate_time
    $boolean = $c->validate_time;
    $boolean = $c->validate_time($dt);

Validates a datetime against the cron entry. If the argument is ommitted, it validates against the current time ("DateTime-"now>).

_parse_cron_field
    $data = $c->_parse_cron_field($field, $min, $max)

Examples

  use DateTime::Cron::Simple;
  $c = DateTime::Cron::Simple->new('0-59/2 10,12 * * 5');
  if($c->validate_time) { ... }
  $c->new_cron('* * 1 * 0');
  if($c->validate_time) { ... }

Authors/maintainers

The original author of this module is

Brendan Fagan <suburbanantihero (at) yahoo (dot) com>.

At version 0.3, a full rewrite was done to set it free from license issues. The current maintainer is

Adriano Ferreira <ferreira (at) cpan (dot) org>.

Comments, bug reports, patches and flames are still appreciated.

From perl-datetime-cron-simple 0.3-4 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.