Reinhold May wrote: > > Flavio, thanks a lot for the information. I had already looked > into the internal structure using the Data::Dumper package, but > couldn't really understand how it works. And to be honest, I > still can't understand what's going on. Most of the 'param' key > subs have "DUMMY" in it which can't really mean anything. >
The subs are provided by DateTime::Set->from_recurrence() and are named next($dt), current($dt), and previous($dt). Those subs are iterated to generate the recurrence sequence. See also: http://search.cpan.org/~fglock/DateTime-Set-0.14/lib/Set/Infinite/_recurrence.pm > > > So my question really is: is a recurrence set that is used to > > > create a SpanSet preserved in that SpanSet? If so, can I > > > extract it? > > > > I don't think it is advisable to do that. > > Note that the data structure becomes much more > > complex as you start doing operations like > > union/intersection/complement/... > > If it's not advisable, is it feasible? I mean, is there a way > to get the original set information from a spanset. If so, I > guess, it would even make the new structure less complex. > It's feasible only in the simplest case (a plain recurrence, before any set operations). In the more general case, only the iterate() solution is "right". > I'd really like to support unbounded sets as my design > wouldn't work without and I'd have to 'pollute' my code with > ugly workarounds. So if you could give me some advice, I'd be > really grateful. If Dave agrees, I'll implement this: --- DateTime::SpanSet --- * iterate This method apply a callback subroutine to all spans of a spanset. The callback parameter is a DateTime::Span. sub callback { $_[0]->set_time_zone( $tz ); } # assign a timezone to the spanset $set->iterate( \&callback ); # create a new spanset with the new timezone, # $set is unchanged $set2 = $set->clone->iterate( \&callback ); If the callback returns undef, the span is removed from the set. * as_set * start_set Creates a DateTime::Set using only the 'start' datetimes from each span. * end_set Creates a DateTime::Set using only the 'end' datetimes from each span. ------ - Flavio S. Glock