function addsql($date, $mins) { return tosql(fromsql($date) + $mins); }
$response[$event_id]['event_timefrom'] = addsql($event['event_timefrom'], $tzone); $response[$event_id]['event_timetill'] = addsql($event['event_timetill'], $tzone); } } echo json_encode($response); } else { echo json_encode(array()); } break; case 'get_year_events': if (isset($_GET["date"])) { $result = SQL::SelectAllYearEvents($settings->DbPrefix, (int) $_GET['date'], $user_id); $response = array(); foreach ($result as $value) { $from_timestamp = fromsql($value['event_timefrom']) + $tzone; $till_timestamp = fromsql($value['event_timetill']) + $tzone; $add_value_timefrom = date('Ymd', $from_timestamp); $add_value_timetill = date('Ymd', $till_timestamp); if ($add_value_timefrom == $add_value_timetill) { if (!in_array($add_value_timetill, $response)) { array_push($response, $add_value_timetill); } } else { $days = floor(($till_timestamp - $from_timestamp) / 86400); for ($i = 0; $i <= $days; $i++) { $add_date = date('Ymd', $from_timestamp + 86400 * $i); if (!in_array($add_date, $response)) { array_push($response, $add_date); } } }