Created
July 6, 2019 22:57
-
-
Save FDSoftware/983cbe04a125786091d4408e9346b847 to your computer and use it in GitHub Desktop.
Misma mierda que https://gist.github.com/FDSoftware/bf991ac285dff16bc569cbc95da7da98 , pero mas "limpio"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//SRC: https://board.phpbuilder.com/d/10342598-quotconvert-quothoursminutesquot-to-quottotal-minutesquot-and-backquot/2 | |
function hoursToMinutes($hours) { | |
$minutes = 0; | |
if (strpos($hours, ':') !== false) { | |
// Split hours and minutes. | |
list($hours, $minutes) = explode(':', $hours); | |
} | |
return $hours * 60 + $minutes; | |
} | |
function hourCompare($h1, $h2) { | |
$hora = preg_split("/[\s;]+/", $h1); | |
$hora1 = preg_split("/[\s;]+/", $h2); | |
$x2 = 0; | |
$HA = hoursToMinutes($hora1[0]); | |
$HB = hoursToMinutes($hora1[1]); | |
$H1 = hoursToMinutes($hora[0]); | |
$H2 = hoursToMinutes($hora[1]); | |
if( $H1 > $HA and $H1 < $HB ){ //primer IF, hora inicio | |
$x2++; // evento cruzado | |
}else if( $H2 >= $HA and $H2 < $HB ){ //segundo IF, hora de finalizacion | |
$x2++; //evento cruzado (otra ve) | |
} | |
if($x2 != 0){ | |
return true; | |
}else{ | |
return false; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment