#!/usr/bin/perl -w use strict; use diagnostics; use DateTime; use DateTime::Set; use Test::More; my $biweekly = DateTime::Set->from_recurrence( 'recurrence' => sub { return $_[0]->truncate('to' => 'day')->add('days' => 14) }, 'start' => DateTime->today() ); print 'FIRST 5 ELEMENTS OF SET', $/; my $iterator = $biweekly->iterator; for (0..4) { my $date = $iterator->next; print $date->datetime, $/; } print $/; print 'TESTING whether Date is in set...', $/; my $date = DateTime->today(); is($biweekly->contains($date), 1, $date->ymd . ' *IS* in the bi-weekly set'); $date->add('days' => 7); is($biweekly->contains($date), 0, $date->ymd . ' is *NOT* the bi-weekly set'); $date->add('days' => 7); is($biweekly->contains($date), 1, $date->ymd . ' *IS* the bi-weekly set'); $date->add('days' => 7); is($biweekly->contains($date), 0, $date->ymd . ' is *NOT* the bi-weekly set'); $date->add('days' => 7); is($biweekly->contains($date), 1, $date->ymd . ' *IS* the bi-weekly set'); # ... done_testing(); #### FIRST 5 ELEMENTS OF SET 2013-05-12T00:00:00 2013-05-26T00:00:00 2013-06-09T00:00:00 2013-06-23T00:00:00 2013-07-07T00:00:00 TESTING whether Date is in set... ok 1 - 2013-05-12 *IS* in the bi-weekly set not ok 2 - 2013-05-19 is *NOT* the bi-weekly set # Failed test '2013-05-19 is *NOT* the bi-weekly set' # at ./off-friday line 28. # got: '1' # expected: '0' ok 3 - 2013-05-26 *IS* the bi-weekly set not ok 4 - 2013-06-02 is *NOT* the bi-weekly set # Failed test '2013-06-02 is *NOT* the bi-weekly set' # at ./off-friday line 32. # got: '1' # expected: '0' ok 5 - 2013-06-09 *IS* the bi-weekly set 1..5 # Looks like you failed 2 tests of 5.