Skip to content

Commit

Permalink
more failsafe check if date conversion fails
Browse files Browse the repository at this point in the history
  • Loading branch information
datengraben committed Feb 11, 2025
1 parent ba3291b commit be3cedc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Repository/TimeframeRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ public static function insertTimeframe ( \CommonsBooking\Model\Timeframe $timefr

$endTimestamp = $timeframe->getEndDate();

if ($endTimestamp == 0 || empty($endTimestamp)) {
//$EndDateTime = date('Y-m-d H:i:s', strtotime("+90 days"));
$EndDateTime = 'NULL';
} else {
$EndDateTime = date('Y-m-d H:i:s', $endTimestamp);
}
$dateConversionFails = false === date( 'Y-m-d H:i:s', $endTimestamp );
if ( $endTimestamp == 0 || empty( $endTimestamp ) || $dateConversionFails ) {
//$EndDateTime = date('Y-m-d H:i:s', strtotime("+90 days"));
$EndDateTime = 'NULL'; // TODO as 9999-01-01... in case of non-null enddatetime column change
} else {
$EndDateTime = date( 'Y-m-d H:i:s', $endTimestamp );
}


if (self::hasTimeframe($timeframe)) {
Expand Down

0 comments on commit be3cedc

Please sign in to comment.