Skip to content

Commit

Permalink
Merge pull request #30 from panVag/29-call-to-a-member-function-forma…
Browse files Browse the repository at this point in the history
…t-on-false

#29 Call to a member function format() on false in AudioCore.php:543
  • Loading branch information
ewilan-riviere authored Jun 4, 2024
2 parents 4d4a633 + 297e5b1 commit 04469ec
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Models/AudioCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,16 @@ public static function fromQuicktime(Id3TagQuicktime $tag): AudioCore
if (strlen($creation_date) === 4) {
$core->setYear((int) $creation_date);
} else {
$creation_date = date_create_from_format('Y-m-d\TH:i:s\Z', $creation_date);
$core->setCreationDate($creation_date?->format('Y-m-d\TH:i:s\Z'));
$core->setYear((int) $creation_date?->format('Y'));
try {
$parsedCreationDate = new \DateTimeImmutable($creation_date);
} catch (\Exception $e) {
// ignore the issue so the rest of the data will be available
}

if (!empty($parsedCreationDate)) {
$core->setCreationDate($parsedCreationDate->format('Y-m-d\TH:i:s\Z'));
$core->setYear((int) $parsedCreationDate->format('Y'));
}
}
}

Expand Down

0 comments on commit 04469ec

Please sign in to comment.