note
fglock
<p>The problem is in the truncate('to' => 'day') step.
What you need is to truncate to "14th day", which is not that easy.</p>
<p>Do you think you can do with DateTime::Event::Recurrence or DateTime::Event::ICal? These modules provide a large set of recurrence modes.</p>
<code>#!/usr/bin/perl
use strict;
use warnings;
use DateTime::Event::Recurrence;
print "DateTime::Event::Recurrence: ", $/;
my $start = DateTime->today();
my $biweekly = DateTime::Event::Recurrence->daily(
interval => 14,
start => $start,
);
print 'TESTING whether Date is in set...', $/;
my $date = DateTime->today();
print $biweekly->contains($date), ' ', $date->ymd, $/;
$date->add('days' => 7);
print $biweekly->contains($date), ' ', $date->ymd, $/;
$date->add('days' => 7);
print $biweekly->contains($date), ' ', $date->ymd, $/;
$date->add('days' => 7);
print $biweekly->contains($date), ' ', $date->ymd, $/;
$date->add('days' => 7);
print $biweekly->contains($date), ' ', $date->ymd, $/;
$date->add('days' => 7);
print $biweekly->contains($date), ' ', $date->ymd, $/;
</code>
output:
<code>DateTime::Event::Recurrence:
TESTING whether Date is in set...
1 2013-05-15
0 2013-05-22
1 2013-05-29
0 2013-06-05
1 2013-06-12
0 2013-06-19</code>
1033231
1033231