diff options
Diffstat (limited to 'app/helpers.php')
| -rw-r--r-- | app/helpers.php | 18 |
1 files changed, 16 insertions, 2 deletions
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 @@ <?php +use Carbon\Carbon; function replaceSpecialChars($string) { $string = str_replace("<i>", "<i>", $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); +} |
