if ( !empty( $results ) ) {
foreach ( $results as $post ) {
+ if ( $debug ) {
+ echo '<div style="border:1px solid green;">';
+ }
++$event_counter;
//echo '<pre>$post: ' . print_r($post, true) . '</pre>';
$sql = "
'%s',
'%s',
);
- if ( $debug ) {
- //$this->wpdb->show_errors();
- }
$is_insert = $this->wpdb->insert(
GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events',
$event_import_data,
);
}
if ( $debug ) {
+ echo '<pre>$event_data: ' . print_r($event_data, true) . '</pre>';
echo '<pre>$categories: ' . print_r($categories, true) . '</pre>';
}
$week_of_month = 63;
$custom_times = array();
+ $curZone = date_default_timezone_get();
+ if ( $debug ) {
+ echo '<pre>$curZone: ' . print_r($curZone, true) . '</pre>';
+ }
+ if ( $event_data['timezone_name'] ) {
+ date_default_timezone_set( $event_data['timezone_name'] );
+ }
+ $curZone = date_default_timezone_get();
+ if ( $debug ) {
+ echo '<pre>$curZone: ' . print_r($curZone, true) . '</pre>';
+ }
$from_date = date( 'Y-m-d', $event_data['start'] );
if ( $debug ) {
echo '<pre>$from_date: ' . print_r($from_date, true) . '</pre>';
+ $from_date_time = date( 'Y-m-d H:m:s', $event_data['start'] );
+ echo '<pre>$from_date_time: ' . print_r($from_date_time, true) . '</pre>';
}
$to_date = date( 'Y-m-d', $event_data['end'] );
+ // check if the $to_date has 0 hr
+ // if the btime and etime are 00:00 then remove one day from $to_date
+ if ( date( 'H', $event_data['end'] ) === '00' ) {
+ $ending_datetime = new DateTime( $to_date );
+ $ending_datetime->modify('- 1 day');
+ $to_date = $ending_datetime->format( 'Y-m-d' );
+ }
if ( $debug ) {
echo '<pre>$to_date: ' . print_r($to_date, true) . '</pre>';
+ $to_date_time = date( 'Y-m-d H:m:s', $event_data['end'] );
+ echo '<pre>$to_date_time: ' . print_r($to_date_time, true) . '</pre>';
}
$btime = date( 'H:i', $event_data['start'] );
if ( $debug ) {
$etime = date( 'H:i', $event_data['end'] );
if ( $debug ) {
echo '<pre>$etime: ' . print_r($etime, true) . '</pre>';
- }
+ }
+
if ( $event_data['recurrence_rules'] ) {
$recurring_event = 1;
break;
case "YEARLY":
- $yearly_events++;
- $selected_from_date = substr($from_date, -2);
- $selected_from_date--;
- $selected_to_date = substr($to_date, -2);
- $selected_to_date--;
- $month_sum = 0;
- $yearly = $recurrence_rules[1];
- $yearly = substr($yearly,8);
- $month_ints = explode(',', $yearly);
- foreach($month_ints as $ints){
- $ints--;
- $ints = pow(2, $ints);
- $month_sum += $ints;
- }
- $month_of_year = $month_sum;
- if($selected_from_date == $selected_to_date){
- $selected_to_date++;
- }
- $day_of_month = pow(2,$selected_from_date ) + pow(2, $selected_to_date);
- if($month_sum){
- $by_day_of_month = 1;
+ if ( $recurrence_rules[1] ) {
+ $yearly_events++;
+ $selected_from_date = substr($from_date, -2);
+ $selected_from_date--;
+ $selected_to_date = substr($to_date, -2);
+ $selected_to_date--;
+ $month_sum = 0;
+ $yearly = $recurrence_rules[1];
+ $yearly = substr($yearly,8);
+ $month_ints = explode(',', $yearly);
+ if ( $debug ) {
+ echo '<pre>$month_ints: ' . print_r($month_ints, true) . '</pre>';
+ }
+ foreach($month_ints as $ints){
+ $ints--;
+ $ints = pow(2, $ints);
+ $month_sum += $ints;
+ }
+ $month_of_year = $month_sum;
+ if ( $debug ) {
+ echo '<pre>$month_of_year: ' . print_r($month_of_year, true) . '</pre>';
+ }
+ if($selected_from_date == $selected_to_date){
+ $selected_to_date++;
+ }
+ $day_of_month = pow(2,$selected_from_date ) + pow(2, $selected_to_date);
+ if ( $debug ) {
+ echo '<pre>$day_of_month: ' . print_r($day_of_month, true) . '</pre>';
+ }
+ if($month_sum){
+ $by_day_of_month = 1;
+ }
+ } else {
+ $ints = 0;
+ $month_sum = 0;
+ // get the month and day of month from $from_date and $to_date
+ $start_month = date( 'n', strtotime( $from_date ) );
+ $end_month = date( 'n', strtotime( $to_date ) );
+ for ( $index = ( $start_month - 1 ); $index <= ( $end_month -1 ); ++$index ) {
+ $ints = pow( 2, $index );
+ $month_sum += $ints;
+ }
+ $month_of_year = $month_sum;
+ // Now do the day_of_month
+ $ints = 0;
+ $day_of_month = 0;
+ $start_day = date( 'j', strtotime( $from_date ) );
+ if ( $debug ) {
+ echo '<pre>$start_day: ' . print_r($start_day, true) . '</pre>';
+ }
+ $end_day = date( 'j', strtotime( $to_date ) );
+ 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;
+ }
}
break;
case "MONTHLY":
die('no return id for location');
}
}
+ if ( $debug ) {
+ echo '</div>';
+ }
}
$return_string .= "<p>Adding $event_counter Events</p>";
}