summaryrefslogtreecommitdiff
path: root/app/helpers.php
diff options
context:
space:
mode:
authorhorus2020-09-17 23:37:00 +0200
committerhorus2020-09-17 23:37:00 +0200
commit0c521f4907ee74cda8d4b6810a5ccb21c175f857 (patch)
tree4c334a83f6281d0f23deb35077157811eae3ab16 /app/helpers.php
parent0e3b6263b4756ad93bb619ec34b7b121b87a097f (diff)
downloadsenpai-0c521f4907ee74cda8d4b6810a5ccb21c175f857.tar.gz
add season to anime model
Diffstat (limited to 'app/helpers.php')
-rw-r--r--app/helpers.php18
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("&lt;i&gt;", "<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);
+}