On Mon, 10 Mar 2003 [EMAIL PROTECTED] wrote:

> The callback receives a DateTime parameter. The callback must return 2
> values: the value of the recurrence just before the date (that is, the
> truncated value), and the value of the recurrence after the date.
>
> For example - a yearly recurrence:
>
> $yearly_recurrence = DateTime::Set->new(
>   callback => sub {
>     my $date = shift;
>     return (
>       $date->clone->truncate( 'year' ),
>       $date->clone->add( 'year' => 1 ) );
>   }
> }
>
> This way, there is no need for 'start' or 'freq' parameters.

I still don't see why the first return value is needed.  Can't the
recurrence just be:

 my $yearly = DateTime::Set->new( recurrence => \&next_year );

 # this is the current API, maybe it should change
 sub next_year { $_[0]->truncate( to => 'month' );
                 return $_{0] + DateTime::Duration->new( years => 1 ) }

Why does the DateTime::Set class need to get both dates back?  I think
that's what is confusing me.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to