On Mon, 2 Jun 2003, Flavio S. Glock wrote:

> Dave Rolsky wrote:
> >
> > On Mon, 2 Jun 2003, Flavio S. Glock wrote:
> > > RFC - Do we need something like this?
> > >
> > >     $span = DateTime::Span->hour( $dt );
> > >     $span = DateTime::Span->day( $dt );
> > >     ...
> >
> > What does this do?
>
> It is a shortcut to build frequently-used spans:
>
>    $dt = DateTime->new(
>        year => 2003,
>        month => 10,
>        day => 5,
>        hour => 11 );
>    $span = DateTime::Span->day( $dt );
>    # "whole-day" span:
>    # [ 2003-10-05T00:00:00 .. 2003-10-05T23:59:59 ]
>
> this is a tipical application:
>
>    $set = DT::E::Recurrence->xxx;
>    $today_events = $set->as_list(
>        span => DateTime::Span->day( today )
>    );
>
>    $month_events = $set->as_list(
>        span => DateTime::Span->month( today )
>    );

I don't think "month" makes it clear that it's "this month" versus "the
date and one month after it".  I'm not averse to shortcuts, but they need
to have clearer names.


-dave

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

Reply via email to