if (modulo($_POST['tyear'], 4) == 0 and modulo($_POST['tyear'], 100) != 0 or modulo($_POST['tyear'], 400) == 0) { $leap = true; } else { $leap = false; } if ($leap == true and $_POST['tmonth'] == '02' and ($_POST['tday'] == '30' or $_POST['tday'] == '31')) { $_POST['tday'] = '29'; } if ($leap == false and $_POST['tmonth'] == '02' and ($_POST['tday'] == '29' or $_POST['tday'] == '30' or $_POST['tday'] == '31')) { $_POST['tday'] = '28'; } if (($_POST['tmonth'] == '04' or $_POST['tmonth'] == '06' or $_POST['tmonth'] == '09' or $_POST['tmonth'] == '11') and $_POST['tday'] == '31') { $_POST['tday'] = '30'; } $end_date = new dateTime($_POST['tyear'] . $_POST['tmonth'] . $_POST['tday'] . $_POST['ttime'], $target_timezone); $end_date->setTimezone($UK_time); if ($_POST['timezone'] < 0) { $start_date->modify("+" . abs($_POST['timezone']) . " hour"); $end_date->modify("+" . abs($_POST['timezone']) . " hour"); } elseif ($_POST['timezone'] > 0) { $start_date->modify("-" . $_POST['timezone'] . " hour"); $end_date->modify("-" . $_POST['timezone'] . " hour"); } $tmp_start_date = $start_date->format("YmdHis"); $tmp_end_date = $end_date->format("YmdHis"); $timezone = $_POST['timezone']; } // Process the posted modules $modules = array(); $first = true; for ($i = 0; $i < $_POST['module_no']; $i++) {
if ($_POST['tyear'] == '' and $_POST['tmonth'] == '' and $_POST['tday'] == '' and $_POST['thour'] == '' and $_POST['tminute'] == '') { $null_end_date = true; $tmp_end_date = NULL; } else { $leap = is_leap($_POST['tyear']); if ($leap == true and $_POST['tmonth'] == '02' and ($_POST['tday'] == '30' or $_POST['tday'] == '31')) { $_POST['tday'] = '29'; } if ($leap == false and $_POST['tmonth'] == '02' and ($_POST['tday'] == '29' or $_POST['tday'] == '30' or $_POST['tday'] == '31')) { $_POST['tday'] = '28'; } if (($_POST['tmonth'] == '04' or $_POST['tmonth'] == '06' or $_POST['tmonth'] == '09' or $_POST['tmonth'] == '11') and $_POST['tday'] == '31') { $_POST['tday'] = '30'; } $end_date = new dateTime($_POST['tyear'] . $_POST['tmonth'] . $_POST['tday'] . $_POST['thour'] . $_POST['tminute'], $target_timezone); $end_date->setTimezone($local_time); if ($_POST['timezone'] < 0) { $end_date->modify("+" . abs($_POST['timezone']) . " hour"); } elseif ($_POST['timezone'] > 0) { $end_date->modify("-" . $_POST['timezone'] . " hour"); } $properties->set_end_date($end_date->format('U')); $properties->set_raw_end_date($end_date->format('YmdHis')); } } $properties->set_timezone($_POST['timezone']); if (isset($_POST['calendar_year'])) { $calendar_year = $_POST['calendar_year'] == '' ? NULL : $_POST['calendar_year']; $properties->set_calendar_year($calendar_year); } if (isset($_POST['exam_duration_hours']) or isset($_POST['exam_duration_mins'])) {