Skip to content

Commit

Permalink
Merge pull request #287 from evarisk-micka/fix_between_days_function
Browse files Browse the repository at this point in the history
#283 #284 [Lib] fix: num_between_day return 1 if daysNumber is empty
  • Loading branch information
nicolas-eoxia authored Jul 6, 2023
2 parents 5215394 + 0547ea8 commit 2f83990
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/dolisirh_function.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1826,20 +1826,20 @@ function getTaskProgressColorClass($progress)
*
* @param int $timestampStart Timestamp start UTC
* @param int $timestampEnd Timestamp end UTC
* @param int $lastday Last day is included, 0: no, 1:yes
* @param int $lastDay Last day is included, 0: no, 1:yes
* @return int Number of days
* @seealso num_public_holiday(), num_open_day()
*/
function dolisirh_num_between_day($timestampStart, $timestampEnd, $lastday = 0)
function dolisirh_num_between_day($timestampStart, $timestampEnd, $lastDay = 0)
{
if ($timestampStart < $timestampEnd) {
if ($lastday == 1) {
if ($timestampStart <= $timestampEnd) {
if ($lastDay == 1) {
$bit = 0;
} else {
$bit = 1;
}
$nbjours = (int) round(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit;
$daysNumber = (int) round(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit;
}
//print ($timestampEnd - $timestampStart) - $lastday;
return $nbjours;

return $daysNumber;
}

0 comments on commit 2f83990

Please sign in to comment.