On Fri, 29 Sep 2006, Adriano Ferreira wrote:

    use DateTime::Cron::Simple;
    my $c = DateTime::Cron::Simple->new($cron);
    print "ok"  if $c->validate_time($dt); # $dt is a DateTime
object or DateTime->now by default

There is also "$c->new_cron($cron)" to change the cron entry
represented by the object, but it doesn't add anything really worthy.

The main point is the 'validate_time' method. What does it do? Verify
that a date matches the specification given by the cron entry. Just
this.

     '2009-09-01T00:00:00' matches '* * * * *'
     '2009-09-01T00:00:00' matches '0 * * * *'
     '2009-09-01T00:01:00' does not matches '0 * * * *'
     '2009-09-01T00:00:00' matches '* 0-2 1,10,20 * *'

At a first glance, it seems DateTime::Event objects don't do this. But

Sure they do. The recurrence modules should return sets (or spans or spansets). The DateTime::Set API includes an intersects() method which does exactly this, returns true if the datetime is included in the set.


-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/

Reply via email to