]> Raphaël G. Git Repositories - airbundle/commitdiff
Avoid double month append
authorRaphaël Gertz <git@rapsys.eu>
Sun, 29 Nov 2020 05:59:24 +0000 (06:59 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Sun, 29 Nov 2020 05:59:24 +0000 (06:59 +0100)
Repository/SessionRepository.php

index 2a11c59a53878508463df4ec3d7dc2e7570a06db..afe7335aba744fcecc40214fda2c1d4fac65bd85 100644 (file)
@@ -156,10 +156,14 @@ class SessionRepository extends \Doctrine\ORM\EntityRepository {
                                'sessions' => []
                        ];
 
-                       //Append month for first day of month
+                       //Detect month change
                        if ($month != $date->format('m')) {
                                $month = $date->format('m');
-                               $calendar[$Ymd]['title'] .= '/'.$month;
+                               //Append month for first day of month
+                               //XXX: except if today to avoid double add
+                               if ($date->format('U') != strtotime('today')) {
+                                       $calendar[$Ymd]['title'] .= '/'.$month;
+                               }
                        }
                        //Deal with today
                        if ($date->format('U') == ($today = strtotime('today'))) {
@@ -316,10 +320,14 @@ class SessionRepository extends \Doctrine\ORM\EntityRepository {
                                'sessions' => []
                        ];
 
-                       //Append month for first day of month
+                       //Detect month change
                        if ($month != $date->format('m')) {
                                $month = $date->format('m');
-                               $calendar[$Ymd]['title'] .= '/'.$month;
+                               //Append month for first day of month
+                               //XXX: except if today to avoid double add
+                               if ($date->format('U') != strtotime('today')) {
+                                       $calendar[$Ymd]['title'] .= '/'.$month;
+                               }
                        }
                        //Deal with today
                        if ($date->format('U') == ($today = strtotime('today'))) {