Fix : improve date library
This commit is contained in:
parent
c21597e839
commit
0066dfd87c
@ -182,7 +182,7 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@ -218,6 +218,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) {
|
||||
@ -265,11 +266,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);
|
||||
@ -855,6 +856,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";
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user