diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 558ba2aa322..f8d11b4bc82 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -207,7 +207,7 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforend */ function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0) { - $iResult = ($iHours * 3600) + ($iMinutes * 60) + $iSeconds; + $iResult = ((int) $iHours * 3600) + ((int) $iMinutes * 60) + (int) $iSeconds; return $iResult; } @@ -243,6 +243,7 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l if (empty($lengthOfWeek)) { $lengthOfWeek = 7; // 1 week = 7 days } + $nbHbyDay = $lengthOfDay / 3600; if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin' || $format == 'allhourminsec') { if ((int) $iSecond === 0) { @@ -290,11 +291,11 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l $sTime .= dol_print_date($iSecond, 'hourduration', true); } } elseif ($format == 'allhourminsec') { - return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))).':'.sprintf("%02d", ((int) ($iSecond % 60))); + return sprintf("%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (int) floor($iSecond/3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))).':'.sprintf("%02d", ((int) ($iSecond % 60))); } elseif ($format == 'allhourmin') { - return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))); + return sprintf("%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (int) floor($iSecond/3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600)/60))); } elseif ($format == 'allhour') { - return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))); + return sprintf("%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (int) floor($iSecond/3600))); } } elseif ($format == 'hour') { // only hour part $sTime = dol_print_date($iSecond, '%H', true); @@ -899,6 +900,15 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', } // Fronleichnam } + + if (in_array('genevafast', $specialdayrule)) { + // Geneva fast in Switzerland (Thursday after the first sunday in September) + $date_1sunsept = strtotime('next thursday', strtotime('next sunday', mktime(0, 0, 0, 9, 1, $annee))); + $jour_1sunsept = date("d", $date_1sunsept); + $mois_1sunsept = date("m", $date_1sunsept); + if ($jour_1sunsept == $jour && $mois_1sunsept == $mois) $ferie=true; + // Geneva fast in Switzerland + } } //print "ferie=".$ferie."\n";