Add airing date range to anime detail pages
This commit is contained in:
parent
1cb880f785
commit
cfc6324971
@ -17,6 +17,13 @@ use function Aviat\AnimeClient\getLocalImg;
|
|||||||
<td><?= $data['status'] ?></td>
|
<td><?= $data['status'] ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<?php if ( ! empty($data['airDate'])): ?>
|
||||||
|
<tr>
|
||||||
|
<td>Original Airing</td>
|
||||||
|
<td><?= $data['airDate'] ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Show Type</td>
|
<td>Show Type</td>
|
||||||
<td><?= (strlen($data['show_type']) > 3) ? ucfirst(strtolower($data['show_type'])) : $data['show_type'] ?></td>
|
<td><?= (strlen($data['show_type']) > 3) ? ucfirst(strtolower($data['show_type'])) : $data['show_type'] ?></td>
|
||||||
|
@ -121,6 +121,7 @@ final class AnimeTransformer extends AbstractTransformer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return AnimePage::from([
|
return AnimePage::from([
|
||||||
|
'airDate' => Kitsu::formatAirDates($base['startDate'], $base['endDate']),
|
||||||
'age_rating' => $base['ageRating'],
|
'age_rating' => $base['ageRating'],
|
||||||
'age_rating_guide' => $base['ageRatingGuide'],
|
'age_rating_guide' => $base['ageRatingGuide'],
|
||||||
'characters' => $characters,
|
'characters' => $characters,
|
||||||
|
@ -68,6 +68,57 @@ final class Kitsu {
|
|||||||
return AnimeAiringStatus::NOT_YET_AIRED;
|
return AnimeAiringStatus::NOT_YET_AIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reformat the airing date range for an Anime
|
||||||
|
*
|
||||||
|
* @param string|null $startDate
|
||||||
|
* @param string|null $endDate
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function formatAirDates(string $startDate = NULL, string $endDate = NULL): string
|
||||||
|
{
|
||||||
|
if (empty($startDate))
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$monthMap = [
|
||||||
|
'01' => 'Jan',
|
||||||
|
'02' => 'Feb',
|
||||||
|
'03' => 'Mar',
|
||||||
|
'04' => 'Apr',
|
||||||
|
'05' => 'May',
|
||||||
|
'06' => 'Jun',
|
||||||
|
'07' => 'Jul',
|
||||||
|
'08' => 'Aug',
|
||||||
|
'09' => 'Sep',
|
||||||
|
'10' => 'Oct',
|
||||||
|
'11' => 'Nov',
|
||||||
|
'12' => 'Dec',
|
||||||
|
];
|
||||||
|
|
||||||
|
[$startYear, $startMonth, $startDay] = explode('-', $startDate);
|
||||||
|
|
||||||
|
if ($startDate === $endDate)
|
||||||
|
{
|
||||||
|
return "{$monthMap[$startMonth]} $startDay, $startYear";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($endDate))
|
||||||
|
{
|
||||||
|
return "{$monthMap[$startMonth]} {$startYear} - ";
|
||||||
|
}
|
||||||
|
|
||||||
|
[$endYear, $endMonth] = explode('-', $endDate);
|
||||||
|
|
||||||
|
if ($startYear === $endYear)
|
||||||
|
{
|
||||||
|
return "{$monthMap[$startMonth]} - {$monthMap[$endMonth]} $startYear";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "{$monthMap[$startMonth]} {$startYear} - {$monthMap[$endMonth]} {$endYear}";
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPublishingStatus(string $kitsuStatus, string $startDate = NULL, string $endDate = NULL): string
|
public static function getPublishingStatus(string $kitsuStatus, string $startDate = NULL, string $endDate = NULL): string
|
||||||
{
|
{
|
||||||
$startPubDate = new DateTimeImmutable($startDate ?? 'tomorrow');
|
$startPubDate = new DateTimeImmutable($startDate ?? 'tomorrow');
|
||||||
|
@ -25,4 +25,6 @@ final class AnimePage extends Anime {
|
|||||||
public array $links = [];
|
public array $links = [];
|
||||||
|
|
||||||
public array $staff = [];
|
public array $staff = [];
|
||||||
|
|
||||||
|
public ?string $airDate = '';
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user