Dave Rolsky wrote:
Well, if you just want the _date_, it's pretty easy.
my $dur = $dt1->delta_days($dt2);
# or use Math::Round if you want my $mid = $dt1->add( days => int( $dur->delta_days / 2 ) );
If you want to account for the time then it gets funkier.
Hmm, indeed.
I need to approximate solar noon by deriving the midpoint between sunrise and sunset. I also need to approximate solar midnight by looking at the sunset from the prior day.
As a general problem, finding a fractional time between two points in time is not that unusual. I *suppose* I could convert to epoch, take the diff, and use that to create a new duration. But it seems unfortunate that I'd have to step out of the datetime API like that. The two endpoints are known quantities -- there is no abiguity in selecting a midpoint.
Is this sort of thing something that should exist in spans rather than expecting regular date math to handle?
Matt