Update range handler in calendars

This commit is contained in:
Brian Miyaji
2017-11-05 22:23:13 +11:00
parent e92b659c4d
commit 2493697ec8

View File

@@ -3,6 +3,9 @@
* Calendar Class
*
* The SportsPress calendar class handles individual calendar data.
* Props @_drg_ for adjustments to range and timezone handling.
* https://wordpress.org/support/topic/suggestion-for-schedule-list-range-option/
* https://wordpress.org/support/topic/timezone-issues-with-schedule-calendar-list/
*
* @class SP_Calendar
* @version 2.2
@@ -265,9 +268,9 @@ class SP_Calendar extends SP_Custom_Post {
}
public function range( $where = '' ) {
$to = new DateTime( $this->to );
$to->modify( '+1 day' );
$where .= " AND post_date BETWEEN '" . $this->from . "' AND '" . $to->format( 'Y-m-d' ) . "'";
$to = new DateTime( $this->to, new DateTimeZone( get_option( 'timezone_string' ) ) );
$from = new DateTime( $this->from, new DateTimeZone( get_option( 'timezone_string' ) ) );
$where .= " AND post_date BETWEEN '" . $from->format( 'Y-m-d' ) . "' AND '" . $to->format( 'Y-m-d' ) . "'";
return $where;
}
}