Corrected time-calculation of last interval.

This commit is contained in:
Peter Fabian 2019-01-22 19:50:35 +01:00
parent 8a9a2c0673
commit 012e14c589
1 changed files with 8 additions and 4 deletions

View File

@ -284,13 +284,15 @@ class WC_Admin_Reports_Data_Store {
$new_end_date = clone $new_start_date;
for ( $i = 0; $i < $intervals_query['per_page']; $i++ ) {
if ( $new_end_date > $latest_end_date ) {
$new_end_date = $latest_end_date;
$end_iteration = 0;
break;
}
$new_end_date = WC_Admin_Reports_Interval::iterate( $new_end_date, $query_args['interval'] );
$end_iteration ++;
}
if ( $new_end_date > $latest_end_date ) {
$new_end_date = $latest_end_date;
$end_iteration = 0;
}
if ( $end_iteration ) {
$new_end_date_timestamp = (int) $new_end_date->format( 'U' ) - 1;
$new_end_date->setTimestamp( $new_end_date_timestamp );
@ -313,13 +315,15 @@ class WC_Admin_Reports_Data_Store {
$new_start_date = clone $new_end_date;
for ( $i = 0; $i < $intervals_query['per_page']; $i++ ) {
if ( $new_start_date < $earliest_start_date ) {
$new_start_date = $earliest_start_date;
$start_iteration = 0;
break;
}
$new_start_date = WC_Admin_Reports_Interval::iterate( $new_start_date, $query_args['interval'], true );
$start_iteration ++;
}
if ( $new_start_date < $earliest_start_date ) {
$new_start_date = $earliest_start_date;
$start_iteration = 0;
}
if ( $start_iteration ) {
// TODO: is this correct? should it only be added if iterate runs? other two iterate instances, too?
$new_start_date_timestamp = (int) $new_start_date->format( 'U' ) + 1;