AND post_status = 'publish'";
//$sql .= " AND ID IN ( SELECT post_id FROM " . $this->wpdb->prefix . "ai1ec_events
//WHERE end >= " . time() . " )";
- //$sql .= " AND ID IN ( 2469, 1640 )";
+ //$sql .= " AND ID IN ( 1647 )";
$sql .= " LIMIT $limit OFFSET $start";
$results = $this->wpdb->get_results( $sql, ARRAY_A );
if ( $debug ) {
echo '<pre>$end_day: ' . print_r($end_day, true) . '</pre>';
}
- for ( $index = ( $start_day - 1); $index <= ( $end_day -1 ); ++$index ) {
- $ints = pow( 2, $index );
- $day_of_month += $ints;
- }
-
- if($day_of_month){
- $by_day_of_month = 1;
+ if ( $start_day == $end_day ) {
+ for ( $index = ( $start_day - 1); $index <= ( $end_day -1 ); ++$index ) {
+ $ints = pow( 2, $index );
+ $day_of_month += $ints;
+ }
+ if($day_of_month){
+ $by_day_of_month = 1;
+ }
+ $ending_datetime = new DateTime( $to_date );
+ $ending_date = $ending_datetime->modify('2 years');
+ $to_date = $ending_date->format( 'Y-m-d' );
+ } else {
+ $serialized_custom_times = null;
+ $custom_dates_array = array();
+ $this_datetime = null;
+ // if the dates span more than one day need to build the custom dates array
+ $starting_datetime = new DateTime( $from_date );
+ $ending_datetime = new DateTime( $to_date );
+ // loop through for the next 2 years
+ for ( $year_index = 0; $year_index <= 2; ++$year_index ) {
+ if ( $year_index !== 0 ) {
+ // adjust the datetimes plus one year
+ $starting_datetime->modify( '+ 1 year' );
+ $ending_datetime->modify( '+ 1 year' );
+ }
+ $starting_time = $starting_datetime->format( 'U' );
+ $ending_time = $ending_datetime->format( 'U' );
+ for ($index = $starting_time; $index <= $ending_time; $index += 86400 ) {
+ $custom_dates_array[] = date( 'Y-m-d', $index );
+ }
+ }
+ if ( $debug ) {
+ echo '<pre>$custom_dates_array: ' . print_r($custom_dates_array, true) . '</pre>';
+ }
+ $serialized_custom_times = serialize( $custom_dates_array );
}
}
- $ending_datetime = new DateTime( $to_date );
- $ending_date = $ending_datetime->modify('2 years');
- $to_date = $ending_date->format( 'Y-m-d' );
break;
case "MONTHLY":
$monthly_events++;