- $start = parsedate('00:00 '.($start + $offset - 1).' days ago') - 1;
- $end = $end ?
- parsedate('00:00 '.($end + $offset - 1).' days ago') - 1 :
- '';
- my $cutoff = parsedate('00:00 '.($offset - 1).' days ago') - 1;
-
- my $sql = &{$range_sub}( $start, $end, $cutoff ); #%opt?
+ my $cutoff = DateTime->now->set(hour => 23, minute => 59, second => 59);
+ $cutoff->subtract(days => $offset);
+
+ my $start = $cutoff->clone;
+ $start->subtract(days => $startdays);
+
+ my $end = $cutoff->clone;
+ $end->subtract(days => $enddays);
+
+ #warn "offset $offset (".$cutoff->epoch."), range $startdays-$enddays (".$start->epoch . '-' . ($enddays ? $end->epoch : '').")\n";
+ my $sql = &{$range_sub}( $start->epoch,
+ $enddays ? $end->epoch : '',
+ $cutoff->epoch ); #%opt?