> 
> Hill, Ronald wrote:
> > > >   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)
> 
> Mmm. What does sunrise returns when you don't have nights?
> I suppose it would be 00:00 ?

If the sun is above the specified "horizon" 24 hours.     
sunrise is set to time when the sun is at south,   
minus 12 hours while sunset is set to the south  
time plus 12 hours. The day length would be 24 hours.

No Sunrise is sun is below the specified "horizon" 24 hours   
The Day length would be 0 hours, sunrise and sunset are
both set to the time when the sun is at south.

This is from Paul's C program that I converted for this
module. It certainly does not have to be this way. But I have
to return something :-)

Please see discussion on this subject here:
http://groups.google.com/groups?q=sunrise+group:comp.lang.perl.modules+autho
r:mothra%40nowhereatall.com&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3e551b72%40usen
et.ugs.com&rnum=4

I am still undecided as to what to do.

> 
> Anyway, it would return something like:
>  ... [2003-03-28 06:00 until 2003-03-28 19:00),
>      [2003-03-29 06:03 until 2003-03-29 19:03),
>      [2003-03-30 06:06 until 2003-03-30 19:09), ...
>  
> > > >
> > > >   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?
> 
> This one would return the nights:
>  ... [2003-03-28 19:00 until 2003-03-29 06:03),
>      [2003-03-29 19:03 until 2003-03-30 06:06) ...
> 
> > > > > 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!
> 
> The idea is that easter_sunday->as_set would return "start-of-event"
> info:
>  ... 2003-04-28 ,
>      2004-04-28 ...
> (these are not real easter sundays, just an example)
> (these are actually daytimes with 00:00:00 h/m/s)

OK, I see now. So far so good.

> 
> While easter_sunday->as_spanset would return "whole days", as spans:
>  ... [2003-04-28 00:00 until 2003-04-29 00:00),
>      [2004-04-28 00:00 until 2004-04-29 00:00) ...
> 
> > > >   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.
> 
> Intersection is what is in _both_ sets, like:
> A = ( 1, 3, 5, 7 )
> B = ( 1, 5, 9, 12 )
> A intersection B = ( 1, 5 )
> 
> In datetime context, we would get "sunrise until sunset, on easter
> sundays":
> 
> "daytime spans"
>  ... [2003-03-28 06:00 until 2003-03-28 19:00),
>      [2003-03-29 06:03 until 2003-03-29 19:03),
>      [2003-03-30 06:06 until 2003-03-30 19:09), ...
> "intersection" to "easter sunday spans":
>  ... [2003-04-28 00:00 until 2003-04-29 00:00),
>      [2004-04-28 00:00 until 2004-04-29 00:00) ...
> 
> gives:
> 
>  ... [2003-04-28 06:12 until 2003-04-29 19:12),
>      [2004-04-28 06:12 until 2004-04-29 19:12) ...
> 
> It could save some programming :)
> 
> > I hope this helps,
> 
> Sure! Thanks. I'll try to improve the docs in DateTime::Set now.

That would be great! I sure hope you can finish the API
so I can try it out!!

> 
> - Flavio S. Glock
> 

Thanks

Ron Hill

Reply via email to