public static function get_array_days_by_query($year, $month, $week, $query)
 {
     $elements = array("ids" => array(), "days" => array());
     $settings = unserialize(get_option("chronosly-settings"));
     if (!$month and !$week) {
         while ($query->have_posts()) {
             $query->the_post();
             if (!Post_Type_Chronosly::filter(get_the_ID())) {
                 continue;
             }
             $elements["ids"][] = get_the_ID();
             $meta = get_post_meta(get_the_ID());
             if (isset($meta["events"][0]) and $meta["events"][0]) {
                 $eventos = json_decode($meta["events"][0]);
                 $elements = Post_Type_Chronosly_Calendar::seasons($eventos, $year, $month, $week, $start_ini, $end, get_the_ID(), $elements);
             } else {
                 if (isset($meta["ev-from"][0])) {
                     //si empieza en el mismo año que el calendario debemos empezar en el dia especifico
                     if (date("Y", strtotime($meta["ev-from"][0])) == $year) {
                         $start = strtotime($meta["ev-from"][0]);
                     } else {
                         $start = strtotime("01-01-" . $year);
                     }
                     if (isset($meta["ev-to"][0]) and date("Y", strtotime($meta["ev-to"][0])) == $year) {
                         $end = strtotime($meta["ev-to"][0]);
                     } else {
                         $end = strtotime("31-12-" . $year);
                     }
                     if ($settings["chronosly_week_start"] == 1) {
                         //$start -= (60*60*24);
                         //$end -= (60*60*24);
                     }
                     $start_ini = $start;
                     $pos = Post_Type_Chronosly_Calendar::get_event_position_by_hour($meta, get_the_ID());
                     do {
                         if ($settings["hide_past_on_calendar"] != 1 or $start >= strtotime(date("Y-m-d"))) {
                             $elements["days"][date('Y-m-d', $start)][$pos] = get_the_ID();
                         }
                         $start = strtotime("+ 1 day", $start);
                     } while ($start <= $end);
                     //repeats
                     $elements = Post_Type_Chronosly_Calendar::repeats($meta, $year, $month, $week, $start_ini, $end, get_the_ID(), $elements);
                 }
             }
         }
     } else {
         if ($week) {
             while ($query->have_posts()) {
                 $query->the_post();
                 if (!Post_Type_Chronosly::filter(get_the_ID())) {
                     continue;
                 }
                 $elements["ids"][] = get_the_ID();
                 $meta = get_post_meta(get_the_ID());
                 if (isset($meta["events"][0]) and $meta["events"][0]) {
                     $eventos = json_decode($meta["events"][0]);
                     $elements = Post_Type_Chronosly_Calendar::seasons($eventos, $year, $month, $week, $start_ini, $end, get_the_ID(), $elements);
                 } else {
                     if (isset($meta["ev-from"][0])) {
                         //si empieza en el mismo año y week que el calendario debemos empezar en el dia especifico
                         if ($settings["chronosly_week_start"] == 1) {
                             $botom = strtotime($year . "W" . str_pad($week, 2, '0', STR_PAD_LEFT)) - 60 * 60 * 24;
                             $top = strtotime($year . "W" . str_pad($week + 1, 2, '0', STR_PAD_LEFT)) - 2 * 60 * 60 * 24;
                         } else {
                             $botom = strtotime($year . "W" . str_pad($week, 2, '0', STR_PAD_LEFT));
                             $top = strtotime($year . "W" . str_pad($week + 1, 2, '0', STR_PAD_LEFT)) - 60 * 60 * 24;
                         }
                         if (strtotime($meta["ev-from"][0]) >= $botom and strtotime($meta["ev-from"][0]) <= $top) {
                             $start = strtotime($meta["ev-from"][0]);
                         } else {
                             $start = $botom;
                         }
                         if (isset($meta["ev-to"][0]) and strtotime($meta["ev-to"][0]) <= $top) {
                             $end = strtotime($meta["ev-to"][0]);
                         } else {
                             $end = $top;
                         }
                         if ($settings["chronosly_week_start"] == 1) {
                             // $start -= (60*60*24);
                             // $end -= (60*60*24);
                         }
                         $start_ini = $start;
                         $pos = Post_Type_Chronosly_Calendar::get_event_position_by_hour($meta, get_the_ID());
                         do {
                             $elements["days"][date('Y-m-d', $start)][$pos] = get_the_ID();
                             $start = strtotime("+ 1 day", $start);
                         } while ($start <= $end);
                         //repeats
                         $elements = Post_Type_Chronosly_Calendar::repeats($meta, $year, $month, $week, $start_ini, $end, get_the_ID(), $elements);
                     }
                 }
             }
         } else {
             if ($month) {
                 while ($query->have_posts()) {
                     $query->the_post();
                     if (!Post_Type_Chronosly::filter(get_the_ID())) {
                         continue;
                     }
                     $elements["ids"][] = get_the_ID();
                     $meta = get_post_meta(get_the_ID());
                     if (isset($meta["events"][0]) and $meta["events"][0]) {
                         $eventos = json_decode($meta["events"][0]);
                         $elements = Post_Type_Chronosly_Calendar::seasons($eventos, $year, $month, $week, $start_ini, $end, get_the_ID(), $elements);
                     } else {
                         if (isset($meta["ev-from"][0])) {
                             //si empieza en el mismo año y mes que el calendario debemos empezar en el dia especifico
                             if (date("Y-m", strtotime($meta["ev-from"][0])) == date("Y-m", strtotime($year . "-" . $month))) {
                                 $start = strtotime($meta["ev-from"][0]);
                             } else {
                                 $start = strtotime("01-{$month}-{$year}");
                             }
                             //si acaba en este mes acabamos en el dia
                             if (isset($meta["ev-to"][0]) and date("Y-m", strtotime($meta["ev-to"][0])) == date("Y-m", strtotime($year . "-" . $month))) {
                                 $end = strtotime($meta["ev-to"][0]);
                             } else {
                                 $end = strtotime(date("Y-m-t", strtotime($year . "-" . $month)));
                             }
                             if ($settings["chronosly_week_start"] == 1) {
                                 // $start -= (60*60*24);
                                 // $end -= (60*60*24);
                             }
                             $start_ini = $start;
                             $pos = Post_Type_Chronosly_Calendar::get_event_position_by_hour($meta, get_the_ID());
                             do {
                                 $elements["days"][date('Y-m-d', $start)][$pos] = get_the_ID();
                                 $start = strtotime("+ 1 day", $start);
                             } while ($start <= $end);
                             //repeats
                             $elements = Post_Type_Chronosly_Calendar::repeats($meta, $year, $month, $week, $start_ini, $end, get_the_ID(), $elements);
                         }
                     }
                 }
             }
         }
     }
     return $elements;
 }