Need idea to convert the below php code to iOS
Run this php code u will understand it will explain you more
Just a shift calculation.
Any idea pls share with me...
Code:
<?php
function intersection($s1, $e1, $s2, $e2)
{
if ($e1 < $s2)
return 0;
if ($s1 > $e2)
return 0;
if ($s1 < $s2)
$s1 = $s2;
if ($e1 > $e2)
$e1 = $e2;
return $e1 - $s1;
}
$start = strtotime("18:30");
// $end = strtotime("24:00");
$end = strtotime("05:30") + 3600*24; // the work ended at 05:30 morning of the next day
$morning_start = strtotime("07:00");
$morning_end = strtotime("15:00");
$afternoon_start = strtotime("15:00");
$afternoon_end = strtotime("20:00");
$night_start = strtotime("20:00");
$night_end = strtotime("07:00") + 3600*24; // 07:00 of next day, add 3600*24 seconds
echo "morning: " . intersection( $start, $end, $morning_start, $morning_end ) / 3600 . " hours\n";
echo "afternoon: " . intersection( $start, $end, $afternoon_start, $afternoon_end ) / 3600 . " hours\n";
echo "night: " . intersection( $start, $end, $night_start, $night_end ) / 3600 . " hours\n";
?>
Run this php code u will understand it will explain you more
Just a shift calculation.
Any idea pls share with me...
Last edited by a moderator: