Matt Sisk wrote:
> what is the midpoint of a span? 

With DateTime::Span:

 $mid_point = 
    $span->start->add_duration(
        seconds => $span->duration->seconds / 2 
    );

With DateTime:

  $mid_point = 
    $start->add_duration(
        seconds => $end->subtract_datetime_absolute( 
            $start 
        )->seconds / 2 
    );

(you may want to account for fractional
seconds too)

How about a DateTime::Span->midpoint method?

- Flavio S. Glock


Reply via email to