mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 13:07:59 +01:00
Catching weird Carbon errors
This commit is contained in:
parent
7d9eaf9405
commit
3217062f92
1 changed files with 19 additions and 7 deletions
|
@ -80,7 +80,7 @@ class ParseTrackTagsCommand extends CommandBase
|
||||||
$this->track->track_number = null;
|
$this->track->track_number = null;
|
||||||
} else {
|
} else {
|
||||||
$this->track->track_number = filter_var($this->input['track_number'] ?? $parsedTags['track_number'], FILTER_SANITIZE_NUMBER_INT);
|
$this->track->track_number = filter_var($this->input['track_number'] ?? $parsedTags['track_number'], FILTER_SANITIZE_NUMBER_INT);
|
||||||
if ($this->track->track_number == null) {
|
if ($this->track->track_number === null) {
|
||||||
$this->track->track_number = 1;
|
$this->track->track_number = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,18 +463,30 @@ class ParseTrackTagsCommand extends CommandBase
|
||||||
switch (Str::length($dateString)) {
|
switch (Str::length($dateString)) {
|
||||||
// YYYY
|
// YYYY
|
||||||
case 4:
|
case 4:
|
||||||
return Carbon::createFromFormat('Y', $dateString)
|
try {
|
||||||
->month(1)
|
return Carbon::createFromFormat('Y', $dateString)
|
||||||
->day(1);
|
->month(1)
|
||||||
|
->day(1);
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// YYYY-MM
|
// YYYY-MM
|
||||||
case 7:
|
case 7:
|
||||||
return Carbon::createFromFormat('Y m', str_replace("-", " ", $dateString))
|
try {
|
||||||
->day(1);
|
return Carbon::createFromFormat('Y m', str_replace("-", " ", $dateString))
|
||||||
|
->day(1);
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// YYYY-MM-DD
|
// YYYY-MM-DD
|
||||||
case 10:
|
case 10:
|
||||||
return Carbon::createFromFormat('Y m d', str_replace("-", " ", $dateString));
|
try {
|
||||||
|
return Carbon::createFromFormat('Y m d', str_replace("-", " ", $dateString));
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue