/**
  * Returns an array of days in a certain week
  *
  * When a date is passed to the function, the weekday number of that day is calculated.
  * Then, looping from 0-6 (Sun - Sat), the dates of that week are calculated.
  *
  * @since 1.0.0
  * @param date $date Ex. 2011-01-01
  * @param date $startdate If passed, will only return dates after that day. Ex. 2011-01-01
  * @param array $weekdays From the recurrence form, the checkboxes corresponding to the weekdays.
  * @return string
  */
 function get_days_of_a_week($date, $start_date = 0, $end_date = 0, $weekdays = array())
 {
     $date = strtotime(epl_admin_dmy_convert($date));
     $start_date = strtotime(epl_admin_dmy_convert($start_date));
     $end_date = strtotime(epl_admin_dmy_convert($end_date));
     //usingn this method instead ofdate_i18n("W") since the latter method uses Monday as start of week
     $year = date_i18n("Y", $date);
     $jan1 = gmmktime(0, 0, 0, 1, 1, $year);
     $mydate = gmmktime(0, 0, 0, 11, 30, $year);
     $week_number = (int) (($date - $jan1) / (7 * 24 * 60 * 60)) + 1;
     // below, in the loop, for $n_d, the week number that is below 10 needs to be represented in 0# format
     if ($week_number < 10) {
         $week_number = "0" . $week_number;
     }
     //$week_number =date_i18n( "W", $date ); //Note that this number is derived with Monday as start of the week
     $_d = array();
     for ($day = 0; $day <= 6; $day++) {
         $n_d = strtotime($year . "W" . $week_number . $day);
         $newdate_year = date_i18n("Y", $n_d);
         $newdate_month = date_i18n("n", $n_d);
         $j = date_i18n("j", $n_d);
         //day 1-31
         $w = date_i18n("w", $n_d);
         //day of the week 0-6
         if ($n_d >= $start_date && $n_d <= $end_date && in_array($w, $weekdays)) {
             $this->dates[$newdate_year][$newdate_month][$j] = date_i18n('Y-m-d', $n_d);
         } else {
             unset($this->dates[$newdate_year][$newdate_month][$j]);
         }
     }
 }
function epl_get_regis_status($date_key = null)
{
    global $event_details, $capacity, $current_att_count, $available_space_arr;
    $today = date_i18n('m/d/Y H:i:s', EPL_TIME);
    $regis_start_date = epl_get_date_timestamp(epl_admin_dmy_convert(epl_get_element($date_key, $event_details['_epl_regis_start_date'], $today)));
    $regis_end_date = epl_get_date_timestamp(epl_admin_dmy_convert(epl_get_element($date_key, $event_details['_epl_regis_end_date'], $today)));
    $ok = epl_compare_dates($today, $regis_start_date, ">=");
    if (!$ok) {
        return epl__("Opens on") . ' ' . epl_formatted_date($event_details['_epl_regis_start_date'][$date_key]);
    }
    $ok = epl_compare_dates($today, strtotime('23:59:59', $regis_end_date), "<=");
    if (!$ok) {
        return epl__('Closed');
    }
    return epl__('Open');
}
function epl_get_date_timestamp($date = null)
{
    if (is_null($date) || $date == '') {
        return $date;
    }
    return is_numeric($date) && (int) $date == $date ? $date : strtotime(epl_admin_dmy_convert($date));
}
 function process_data_type(&$value, $data_type, $mode = 's')
 {
     switch ($data_type) {
         case "date":
             $value = epl_formatted_date(strtotime($value), "Y-m-d");
             break;
         case "unix_time":
             $value = strtotime(epl_admin_dmy_convert($value));
             break;
     }
 }