@ 2018-10-25T23:37:41Z <?php
//$current_date = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
//$permit_active_date = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$current_date = date_create("2018-10-25 00:00:00"); //mktime(0, 0, 0, 10, 25, 2018);
$permit_active_date = date_create("2018-10-25 00:00:00");
$pay_frequency = "BW";
$UCDHS_MasterPaySchedule = array (
"BW" => array (
array (
"file_submit_date" => date_create("2018-09-14 00:00:00"),
"pay_check_date" => date_create("2018-09-19 00:00:00"),
"park_period_start" => date_create("2018-10-01 00:00:00"),
"park_period_end" => date_create("2018-10-15 00:00:00"),
"check_num" => 1
),
array (
"file_submit_date" => date_create("2018-09-28 00:00:00"),
"pay_check_date" => date_create("2018-10-03 00:00:00"),
"park_period_start" => date_create("2018-10-16 00:00:00"),
"park_period_end" => date_create("2018-10-31 00:00:00"),
"check_num" => 2
),
array (
"file_submit_date" => date_create("2018-10-12 00:00:00"),
"pay_check_date" => date_create("2018-10-17 00:00:00"),
"park_period_start" => date_create("2018-11-01 00:00:00"),
"park_period_end" => date_create("2018-11-15 00:00:00"),
"check_num" => 3
),
array (
"file_submit_date" => date_create("2018-11-08 00:00:00"),
"pay_check_date" => date_create("2018-11-14 00:00:00"),
"park_period_start" => date_create("2018-11-16 00:00:00"),
"park_period_end" => date_create("2018-11-30 00:00:00"),
"check_num" => 4
),
array (
"file_submit_date" => date_create("2018-11-21 00:00:00"),
"pay_check_date" => date_create("2018-11-28 00:00:00"),
"park_period_start" => date_create("2018-12-01 00:00:00"),
"park_period_end" => date_create("2018-12-15 00:00:00"),
"check_num" => 5
),
array (
"file_submit_date" => date_create("2018-12-07 00:00:00"),
"pay_check_date" => date_create("2018-12-12 00:00:00"),
"park_period_start" => date_create("2018-12-16 00:00:00"),
"park_period_end" => date_create("2018-12-31 00:00:00"),
"check_num" => 6
)
)
);
//reduce array to pay schedule
// $arrPaySchedule = $UCDHS_MasterPaySchedule[$pay_frequency];
//find pay cycle where parking period includes permit start date
$pay_cycle_for_active_date = get_pay_cycle_for_active_date($current_date, $permit_active_date, $UCDHS_MasterPaySchedule[$pay_frequency]);
print $pay_cycle_for_active_date;
/**
* Number of days between two dates.
*
* @param date $dt1 First date
* @param date $dt2 Second date
* @return int
*/
function daysBetween($dt1, $dt2) {
// return date_diff(
// date_create($dt2),
// date_create($dt1)
// )->format('%a');
return date_diff(
$dt2,
$dt1
)->format('%a');
}
function get_pay_cycle_for_active_date($current_date, $permit_active_date, $arr_pay_schedule) {
// note: function assumes that pay period data is ordered earliest to latest, in the arrPaySchedule array
//default values:
$current_period_id = -1;
$active_period_id = -1;
//$return_file_submit_date
//pay_check_date
//park_period_start
//park_period_end
//check_num
//loop through pay periods...
foreach($arr_pay_schedule as $period_num => $period) {
//find current parking period
if ($current_date >= $period["park_period_start"] && $current_date <= $period["park_period_end"]) {
$current_period_id = $period_num;
}
//find parking period which contains permit_active_date
if ($permit_active_date >= $period["park_period_start"] && $permit_active_date <= $period["park_period_end"]) {
$active_period_id = $period_num;
}
//determine number of days permit is valid in perid permit becomes valid
$days_valid_in_active_period = daysBetween($permit_active_date, $period["park_period_end"]);
}
echo "current_period_id = ".$current_period_id."\f\r";
echo "active_period_id = ".$active_period_id."\f\r";
echo "days_valid_in_active_period = ".$days_valid_in_active_period."\f\r";
echo "permit_active_date = ".date_format($permit_active_date,'Y-m-d')."\f\r";
echo "period['park_period_end'] = ".$period["park_period_end"]."\f\r";
return "";
// $arrSelectedSchedule = array_filter($arrPaySchedule, function($e) use($permit_active_date) {return ($e["park_period_start"]<=$permit_active_date && $e["park_period_end"]>=$permit_active_date);});
// print_r($arrSelectedSchedule);
// return array_search()
// return count(array_filter($arrPaySchedule, function($e) use($permit_active_date) {return ($e["park_period_start"]<=$permit_active_date && $e["park_period_end"]>=$permit_active_date);}));
}
//$min=mktime(0,0,0,10,1,2018);
//$max=mktime(0,0,0,10,4,2018);
//print count(array_filter($UCDHSPaySchedule["BW"], function($e) use($min,$max) {return ($e["permit_active_date"]>$min && $e["permit_active_date"]<$max);}));
//function gets the number of submittion dates between the $current_date and the submission date for permit starting on $active_date
//function get_cycle_count($current_date, $active_date, $UCDHSPaySchedule) {
//print count(array_filter($UCDHSPaySchedule["BW"], function($e) use($min,$max) {return ($e["permit_active_date"]>$min && //$e["permit_active_date"]<$max);}));
//}
//$cars = array (
//"Volvo" => array("Volvo",22,18),
//"BMW" => array("BMW",15,13),
//"Saab" => array("Saab",5,2),
//"Land Rover" => array("Land Rover",17,15)
//);
//print $cars['Volvo'][0];
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.3.6 0.016 0.003 18.80 8.3.5 0.011 0.004 18.57 8.3.4 0.015 0.000 18.98 8.3.3 0.010 0.006 18.88 8.3.2 0.004 0.004 19.12 8.3.1 0.000 0.008 23.64 8.3.0 0.000 0.008 20.64 8.2.18 0.010 0.010 18.41 8.2.17 0.013 0.010 22.96 8.2.16 0.014 0.000 20.52 8.2.15 0.008 0.000 24.18 8.2.14 0.009 0.000 24.66 8.2.13 0.008 0.000 18.22 8.2.12 0.004 0.004 26.35 8.2.11 0.007 0.003 19.31 8.2.10 0.008 0.003 17.89 8.2.9 0.003 0.005 17.88 8.2.8 0.004 0.004 17.97 8.2.7 0.006 0.003 18.05 8.2.6 0.004 0.004 18.16 8.2.5 0.003 0.006 18.10 8.2.4 0.004 0.004 19.42 8.2.3 0.000 0.007 19.34 8.2.2 0.004 0.004 18.30 8.2.1 0.006 0.003 18.24 8.2.0 0.000 0.010 18.02 8.1.28 0.012 0.003 25.92 8.1.27 0.004 0.004 20.78 8.1.26 0.006 0.006 26.35 8.1.25 0.008 0.000 28.09 8.1.24 0.003 0.007 22.46 8.1.23 0.011 0.000 22.05 8.1.22 0.006 0.003 17.91 8.1.21 0.004 0.004 18.77 8.1.20 0.000 0.010 17.73 8.1.19 0.004 0.004 17.61 8.1.18 0.003 0.006 18.10 8.1.17 0.005 0.003 18.76 8.1.16 0.004 0.004 18.89 8.1.15 0.000 0.007 18.96 8.1.14 0.000 0.007 22.07 8.1.13 0.004 0.007 20.34 8.1.12 0.000 0.007 17.76 8.1.11 0.000 0.007 17.64 8.1.10 0.000 0.008 17.59 8.1.9 0.004 0.004 17.73 8.1.8 0.005 0.002 17.61 8.1.7 0.003 0.005 17.69 8.1.6 0.005 0.005 17.61 8.1.5 0.004 0.004 17.61 8.1.4 0.003 0.006 17.67 8.1.3 0.004 0.004 17.73 8.1.2 0.003 0.005 17.89 8.1.1 0.008 0.000 17.83 8.1.0 0.005 0.003 17.73 8.0.30 0.000 0.007 18.77 8.0.29 0.004 0.004 17.25 8.0.28 0.000 0.008 18.63 8.0.27 0.004 0.004 17.38 8.0.26 0.003 0.003 18.57 8.0.25 0.010 0.000 17.16 8.0.24 0.000 0.007 17.29 8.0.23 0.000 0.007 17.26 8.0.22 0.004 0.007 17.18 8.0.21 0.004 0.004 17.11 8.0.20 0.000 0.007 17.15 8.0.19 0.002 0.005 17.16 8.0.18 0.003 0.005 17.15 8.0.17 0.004 0.004 17.21 8.0.16 0.004 0.004 17.30 8.0.15 0.000 0.007 17.16 8.0.14 0.005 0.003 17.14 8.0.13 0.000 0.006 13.56 8.0.12 0.003 0.005 17.16 8.0.11 0.000 0.008 17.22 8.0.10 0.004 0.004 17.10 8.0.9 0.003 0.006 17.09 8.0.8 0.010 0.009 17.19 8.0.7 0.000 0.007 17.02 8.0.6 0.005 0.002 17.22 8.0.5 0.005 0.003 17.11 8.0.3 0.011 0.007 17.32 8.0.2 0.010 0.010 17.40 8.0.1 0.000 0.007 17.29 8.0.0 0.012 0.007 17.03 7.4.33 0.003 0.003 15.55 7.4.32 0.007 0.000 16.55 7.4.30 0.000 0.008 16.80 7.4.29 0.007 0.000 16.68 7.4.28 0.006 0.003 16.70 7.4.27 0.004 0.004 16.71 7.4.26 0.000 0.007 16.80 7.4.25 0.004 0.004 16.64 7.4.24 0.000 0.008 16.60 7.4.23 0.007 0.000 16.79 7.4.22 0.000 0.008 16.72 7.4.21 0.011 0.008 16.80 7.4.20 0.005 0.002 16.79 7.4.16 0.013 0.005 16.66 7.4.14 0.011 0.009 17.86 7.4.13 0.006 0.012 16.59 7.4.12 0.010 0.009 16.72 7.4.11 0.012 0.006 16.82 7.4.10 0.010 0.007 16.69 7.4.9 0.004 0.014 16.68 7.4.8 0.012 0.012 19.39 7.4.7 0.008 0.008 16.77 7.4.6 0.007 0.010 16.79 7.4.5 0.013 0.003 16.83 7.4.4 0.006 0.012 16.54 7.4.0 0.004 0.014 15.40 7.3.33 0.003 0.003 13.37 7.3.32 0.005 0.000 13.62 7.3.31 0.000 0.009 16.51 7.3.30 0.000 0.008 16.52 7.3.29 0.004 0.003 16.62 7.3.28 0.006 0.009 16.57 7.3.26 0.010 0.009 16.69 7.3.24 0.010 0.010 16.72 7.3.23 0.016 0.003 16.52 7.3.21 0.014 0.003 16.70 7.3.20 0.016 0.000 16.82 7.3.19 0.012 0.006 16.55 7.3.18 0.013 0.003 16.80 7.3.17 0.013 0.012 16.68 7.3.16 0.007 0.014 16.60 7.2.33 0.013 0.010 17.00 7.2.32 0.012 0.006 16.93 7.2.31 0.011 0.007 16.99 7.2.30 0.000 0.017 17.14 7.2.29 0.014 0.011 16.80 7.2.11 0.055 0.007 15.05 7.2.10 0.062 0.003 15.02 7.2.9 0.055 0.003 15.11 7.2.8 0.077 0.010 14.96 7.2.7 0.079 0.017 15.39 7.2.6 0.062 0.003 15.33 7.2.5 0.086 0.003 15.48 7.2.4 0.065 0.004 15.36 7.2.3 0.071 0.006 15.23 7.2.2 0.048 0.018 15.15 7.2.1 0.054 0.013 15.45 7.2.0 0.066 0.009 15.13 7.1.23 0.047 0.007 14.10 7.1.22 0.048 0.011 14.30 7.1.21 0.061 0.006 14.17 7.1.20 0.062 0.006 14.18 7.1.19 0.047 0.012 14.11 7.1.18 0.088 0.010 14.18 7.1.17 0.061 0.016 14.22 7.1.16 0.058 0.007 14.03 7.1.15 0.064 0.013 14.32 7.1.14 0.054 0.010 14.34 7.1.13 0.010 0.017 14.10 7.1.12 0.014 0.006 14.19 7.1.11 0.006 0.012 14.09 7.1.10 0.047 0.007 14.13 7.1.9 0.020 0.007 14.13 7.1.8 0.071 0.003 14.20 7.1.7 0.064 0.010 14.33 7.1.6 0.079 0.007 32.29 7.1.5 0.092 0.010 32.22 7.1.4 0.112 0.007 32.06 7.1.3 0.173 0.014 32.15 7.1.2 0.107 0.012 31.94 7.1.1 0.147 0.010 14.26 7.1.0 0.092 0.010 14.06 5.6.38 0.008 0.014 14.73
preferences:dark mode live preview
84.46 ms | 400 KiB | 5 Q