From: Matt S Trout Date: Sat, 29 Aug 2009 17:50:54 +0000 (+0100) Subject: switch day diff calculation to epoch based so that "N hours short of M days" becomes... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=HEAD;p=engit%2FIron-Munger.git switch day diff calculation to epoch based so that "N hours short of M days" becomes M-1 days reliable --- diff --git a/lib/IronMunger/Calculate.pm b/lib/IronMunger/Calculate.pm index 43b7fe0..236953f 100644 --- a/lib/IronMunger/Calculate.pm +++ b/lib/IronMunger/Calculate.pm @@ -16,7 +16,10 @@ use Sub::Exporter -setup => { sub day_diff ($dt1, $dt2) { $dt1 = $dt1->at if $dt1->isa('IronMunger::Post'); $dt2 = $dt2->at if $dt2->isa('IronMunger::Post'); - $dt1->delta_days($dt2)->delta_days; + my $seconds = $dt2->epoch - $dt1->epoch; + $seconds = -$seconds if $seconds < 0; + int($seconds / 86400); + #$dt1->delta_days($dt2)->delta_days; } sub check_post_gap ($aperture, $days, @posts) {