Hi Flavio,

[snipped]
> 
> Hi,
> 
> I'm sorry to bother you, but I really need to know if this makes sense
> to you.

No bother at all, mail from you or Dave is always welcome :-)
I have looked at the changes that you have provided and there
are some points that I simply don't understand. Bear in mind 
that this is comming from a junior level programmer (me)

> We are still working on the DateTime::Set API and docs, and 
> you are the first user :)

Wow!!, What about Rick Measham (author of the easter module)?
We may want to get him involved as well.

> 
> 
> Flavio S. Glock wrote:
> >
> > Hill, Ronald wrote:
> > > What I wanted to accomplish is to have the module accept a
> > > DateTime::Set object compute the rise/set times and return a new
> > > DateTime::Set object. Here is what I have done:

[my code snipped]

> > You could build a recurrence:
> > 
> >   sub sunrise_as_set {
> >     my $self = shift;
> >     my $class = ref($self);
> >     return DateTime::Set->new( recurrence => 
> >     $class::following_sunrise
> >     );
> >   }

OK so far, However, I would need to change my sub for this
(following_sunrise).
Currently, I return both rise/set times. I would need to break this down
to return just the sunrise only. No problem with that.
> > 
> >   sub sunset_as_set {
> >     my $self = shift;
> >     my $class = ref($self);
> >     return DateTime::Set->new( recurrence => 
>       $class::following_sunset );
> >   }

Add a sub (following_sunset) again, no problems here just return
sunset only.

> > 
> > Now, since you have rise/set times, you can build a 
> > "DateTime::SpanSet", which is a set of intervals.
> > 
> > We haven't finished the discussion on what is the syntax 
> > for creating a DateTime::SpanSet, but it would be something like this:
> > 
> >   sub daytime_as_spanset {
> >     my $self = shift;
> >     my $class = ref($self);
> >     my $sunrises = $self->sunrise_as_set;
> >     my $sunsets  = $self->sunset_as_set;
> >     return $sunrises->until( $sunsets );
> >   }

maybe sunrise_as_spanset? (land of the midnight sun)

> > 
> >   sub nighttime_as_spanset {
> >     my $self = shift;
> >     my $class = ref($self);
> >     my $sunrises = $self->sunrise_as_set;
> >     my $sunsets  = $self->sunset_as_set;
> >     return $sunsets->until( $sunrises );
> >   }
> > 
sunset_as_spanset?

[more of my code snipped]

> > 
> >   my $dt_span = DateTime::Span->new( begin => $dt1, end => $dt2 );
> >

OK generate the range of dates to search through. 
 
> > > my $easter = $easter_sunday->as_set(from=>$dt1, to=>$dt2, 
> inclusive=>1);
> > 
> >   # I would expect $easter_sunday->as_spanset to return
> >   # the time from sunday 00:00 until 23:59
> >   $easter = $easter_sunday->as_spanset->intersection( $dt_span );

This is what is throwing me for a loop. The easter_sunday method
is returning a date (year,month,day) with no time information
because it does not matter what time it is. Weather it is
noon or 3:00PM it is still easter!

> > 
[snipped]
> > 
> >   my $set2 = $sunrise->daytime_as_spanset->intersection ( $easter );

This took my some time to understand because of the term intersection.
When I see this I think of union, intersection in terms of arrays ie:
finding union of arrays intersection (differences) of arrays. However,
in context of your module, it means a while loop. This may need some
clarification in the documentation/examples.

> > 

[snipped]

> > 
> > I think we could just have a
> >   $set = $set->time_zone( 'America/Los_Angeles' );
> > method (but we don't have it yet).

I think this is a requirement to be able to set the timezone
in one swoop!

> > 
> > All this might seem a bit strange, but the idea of using 
> > sets is that
> > you don't have to use iterators -- you use set operations instead.
> > (you can also 'print $set' )

To me, most of this is very new. I am having a hard time getting use
to using the set operations. But with time I should get use to it.

> > 
> > Now show it:
> > 
> >   my $iter = $set2->iterator;
> >   while ( my $dt = $iter->next ) {
> >      print $dt->begin->datetime ." until ". 
> $dt->end->datetime ."\n";
> >   }
This looks good, just loop through and print.

All in All the concepts you have implemented in the module
sound great and will vastly improve dealing with date lists.

I hope this helps,

Thanks

Ron Hill

Reply via email to