This works fine, actually:
use DateTime::Set;
print $DateTime::Set::VERSION, "\n";
$months = DateTime::Set->from_recurrence(
recurrence => sub {
return $_[0]->truncate(
to => 'month' )->add( months => 1 )
},
);
print $months->next( DateTime->now )->datetime, "\n";
print $months->previous( DateTime->now )->datetime,
"\n";
# 0.16
# 2004-07-01T00:00:00
# 2004-06-01T00:00:00
If your recurrence specification is well-behaved,
(don't use internals, etc) you don't have to test
for infinite-ness.
You only have to use
" return $_[0] if $_[0]->is_infinite; "
if your code can't handle DateTime::Infinite.
So my vote goes for not changing the parameters...
- Flavio S. Glock