/**
  * Get the timestamp of the next occurrence.
  *
  * @param int $curdate The current timestamp of a given occurrence.
  *
  * @return int The timestamp of the next occurrence.
  */
 public function getNextDate($curdate)
 {
     $next_day_of_month = date('j', $curdate);
     if ($this->week_of_month && $this->day_of_week) {
         return $this->getNthDayOfWeek($curdate, $this->day_of_week, $this->week_of_month);
     } else {
         if (count($this->days_of_month) > 0) {
             $next_day_of_month = $this->getNextDayOfMonth($next_day_of_month);
             while (Tribe__Date_Utils::get_last_day_of_month($curdate) < $next_day_of_month) {
                 $next_day_of_month = $this->days_of_month[0];
                 $curdate = mktime(date('H', $curdate), date('i', $curdate), date('s', $curdate), date('n', $curdate) + $this->months_between, 1, date('Y', $curdate));
             }
         }
         if ($next_day_of_month > date('j', $curdate)) {
             // no need to jump ahead stay in current month
             return mktime(date('H', $curdate), date('i', $curdate), date('s', $curdate), date('n', $curdate), $next_day_of_month, date('Y', $curdate));
         } else {
             $nextdate = mktime(date('H', $curdate), date('i', $curdate), date('s', $curdate), date('n', $curdate) + $this->months_between, 1, date('Y', $curdate));
             while (Tribe__Date_Utils::get_last_day_of_month($nextdate) < $next_day_of_month) {
                 $nextdate = mktime(date('H', $curdate), date('i', $curdate), date('s', $curdate), date('n', $nextdate) + $this->months_between, 1, date('Y', $nextdate));
             }
             return mktime(date('H', $curdate), date('i', $curdate), date('s', $curdate), date('n', $nextdate), $next_day_of_month, date('Y', $nextdate));
         }
     }
 }
 public function setup_list($template_file)
 {
     if (basename(dirname($template_file)) . '/' . basename($template_file) == 'mini-calendar/list.php') {
         if ($this->args['count'] == 0) {
             return;
         }
         // make sure the widget taxonomy filter setting is respected
         add_action('pre_get_posts', array($this, 'set_count'), 1000);
         global $wp_query;
         $post_status = array('publish');
         if (is_user_logged_in()) {
             $post_status[] = 'private';
         }
         // hijack the main query to load the events via provided $args
         if (!is_null($this->args)) {
             $query_args = array('posts_per_page' => $this->args['count'], 'tax_query' => $this->args['tax_query'], 'eventDisplay' => 'custom', 'start_date' => $this->get_month(), 'post_status' => $post_status, 'is_tribe_widget' => true);
             // set end date if initial load, or ajax month switch
             if (!defined('DOING_AJAX') || defined('DOING_AJAX') && $_POST['action'] == 'tribe-mini-cal') {
                 $query_args['end_date'] = substr_replace($this->get_month(Tribe__Date_Utils::DBDATEFORMAT), Tribe__Date_Utils::get_last_day_of_month(strtotime($this->get_month())), -2);
                 // @todo use tribe_events_end_of_day() ?
                 $query_args['end_date'] = tribe_end_of_day($query_args['end_date']);
             }
             $wp_query = Tribe__Events__Query::getEvents($query_args, true);
         }
     }
 }