Backport the CoreLibs/Basic changes to the oldTemplateLayout branch
This commit is contained in:
@@ -1374,7 +1374,10 @@ class Basic
|
|||||||
if (!$hour || !$min) {
|
if (!$hour || !$min) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (($hour < 0 && $hour > 24) || ($min < 0 && $hour > 60) || ($sec && $sec < 0 && $sec > 60)) {
|
if (($hour < 0 || $hour > 24) ||
|
||||||
|
($min < 0 || $hour > 60) ||
|
||||||
|
($sec && ($sec < 0 || $sec > 60))
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1446,6 +1449,40 @@ class Basic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// METHOD: calcDaysInterval
|
||||||
|
// PARAMS: start date, end date
|
||||||
|
// RETURN: overall days, week days, weekend days as array 0...2 or named
|
||||||
|
// DESC : calculates the days between two dates
|
||||||
|
private function calcDaysInterval($start_date, $end_date, $return_named = false)
|
||||||
|
{
|
||||||
|
// pos 0 all, pos 1 weekday, pos 2 weekend
|
||||||
|
$days = array ();
|
||||||
|
$start = new \DateTime($start_date);
|
||||||
|
$end = new \DateTime($end_date);
|
||||||
|
|
||||||
|
$days[0] = $end->diff($start)->days;
|
||||||
|
|
||||||
|
$period = new \DatePeriod($start, new \DateInterval('P1D'), $end);
|
||||||
|
|
||||||
|
foreach ($period as $dt) {
|
||||||
|
$curr = $dt->format('D');
|
||||||
|
if ($curr == 'Sat' || $curr == 'Sun') {
|
||||||
|
$days[2] ++;
|
||||||
|
} else {
|
||||||
|
$days[1] ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($return_named === true) {
|
||||||
|
return array (
|
||||||
|
'overall' => $days[0],
|
||||||
|
'weekday' => $days[1],
|
||||||
|
'weekend' => $days[2]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return $days;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// METHOD: createThumbnail
|
// METHOD: createThumbnail
|
||||||
// WAS : CreateThumbnail
|
// WAS : CreateThumbnail
|
||||||
// PARAMS: pic -> picture where from we create a thumbnail
|
// PARAMS: pic -> picture where from we create a thumbnail
|
||||||
|
|||||||
Reference in New Issue
Block a user