aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_date.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-04-19 09:16:48 +0200
committerGravatar GitHub <noreply@github.com> 2023-04-19 09:16:48 +0200
commitef82e218ea7f7a6b007e0558c0b90d0e2ba95155 (patch)
tree01b9a3ab2307d492266a67ad665cfe8caf11de34 /lib/lib_date.php
parent687d0b40a89bfaa5fcf99e76b3094c7c4e744f73 (diff)
PHPStan Level 7 Minz_ActionController and lib_date (#5313)
Diffstat (limited to 'lib/lib_date.php')
-rw-r--r--lib/lib_date.php29
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/lib_date.php b/lib/lib_date.php
index d9e1610e6..c1b40ecf6 100644
--- a/lib/lib_date.php
+++ b/lib/lib_date.php
@@ -56,10 +56,11 @@ function _dateCeiling(string $isoDate): string {
return $x[0] . '1231T' . $t;
case 6:
$d = @strtotime($x[0] . '01');
- return $x[0] . date('t', $d) . 'T' . $t;
- default:
- return $x[0] . 'T' . $t;
+ if ($d != false) {
+ return $x[0] . date('t', $d) . 'T' . $t;
+ }
}
+ return $x[0] . 'T' . $t;
}
function _noDelimit(?string $isoDate): ?string {
@@ -101,10 +102,14 @@ function parseDateInterval(string $dateInterval): array {
try {
$di2 = new DateInterval($d2);
$dt1 = @date_create(); //new DateTime() would create an Exception if the default time zone is not defined
- if ($min !== null && $min !== false) {
- $dt1->setTimestamp($min);
+ if ($dt1 === false) {
+ $max = false;
+ } else {
+ if ($min !== null && $min !== false) {
+ $dt1->setTimestamp($min);
+ }
+ $max = $dt1->add($di2)->getTimestamp() - 1;
}
- $max = $dt1->add($di2)->getTimestamp() - 1;
} catch (Exception $e) {
$max = false;
}
@@ -118,12 +123,16 @@ function parseDateInterval(string $dateInterval): array {
try {
$di1 = new DateInterval($d1);
$dt2 = @date_create();
- if ($max !== null && $max !== false) {
- $dt2->setTimestamp($max);
+ if ($dt2 === false) {
+ $min = false;
+ } else {
+ if ($max !== null && $max !== false) {
+ $dt2->setTimestamp($max);
+ }
+ $min = $dt2->sub($di1)->getTimestamp() + 1;
}
- $min = $dt2->sub($di1)->getTimestamp() + 1;
} catch (Exception $e) {
- $min = false;
+ $min = false;
}
}
return array($min, $max);