Dave Rolsky wrote:
> Looking at this makes me think that instead, there should be multiple
> methods, so we'd have:
>   DateTime::SpanSet->from_recurrences( recurrences => [ \&r1, \&r2 ] );
>   DateTime::SpanSet->from_sets( sets => [ \&s1, \&s2 ] );

I think this doesn't make it clear that one set has "start-dates" and
the other set has "end-dates", such as in:

  DateTime::SpanSet->from_sets( sets => [ $sunrise, $sunset ] );

> If we go this way, I'd like to see something similar for DateTime::Set, so
> we could have DateTime::Set->from_recurrence and DateTime::Set->from_dates

Right. Check below which ones are ok:

- DateTime::Set constructors:

  from_dates ( dates => [ $dt1, $dt2, ... ] );

  from_recurrence ( recurrence => sub { ... }, %span );
    # %span defines an optional span:
    #    span => $span1
    #    begin => $dt1, before => $dt2

  # current API:
  new ( dates => [ $dt1, $dt2, ... ] );
  new ( recurrence => sub { ... }, start => $dt1, end => $dt2 );

- DateTime::Span constructors:

  from_date_and_duration ( date => $dt1, %duration );
    # %duration defines a duration
    #    duration => $dur1
    #    days => 1

  # current API:
  new ( begin/after => $dt1, before/end => $dt2 );

- DateTime::SpanSet constructors:

  from_spans ( spans => [ $span1, $span2 ] );

  from_set_and_duration ( set => $set1, %duration );
    # %duration defines a duration
    #    duration => $dur1
    #    days => 1

  from_sets ( start_set => $set1, end_set => $set2 );

  from_recurrences ( start_recurrence => sub { ... }, end_recurrence =>
sub { ... } );

  # current API:
  new ( spans => [ $span1, $span2 ] );


- Flavio S. Glock

Reply via email to