From 0c521f4907ee74cda8d4b6810a5ccb21c175f857 Mon Sep 17 00:00:00 2001 From: horus Date: Thu, 17 Sep 2020 23:37:00 +0200 Subject: add season to anime model --- app/helpers.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'app/helpers.php') diff --git a/app/helpers.php b/app/helpers.php index 5c65c57..9d1586c 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1,4 +1,5 @@ ", $string); @@ -67,8 +68,11 @@ function getAiringStatusCode($airing_status) { return $status[0]->id; } -function getCurrentSeason(){ - switch( date("m") ) { +function getSeason( $month = null ){ + if ( is_null($month) ) { + $month = date("m"); + } + switch( $month ) { case 1: case 2: case 3: return "Winter"; @@ -102,3 +106,13 @@ function compare($str1, $str2) { } return true; } + +function getSeasonFromDate($aired_at) { + if ( is_null($ared_at) ) { + return array("name" => null, "year" => null); + } + + $aired_from = Carbon::instance($aired_at); + + return array("name" => getSeason($aired_from->month), "year" => $aired_from->year); +} -- cgit v1.2.3