@@ -17,26 +17,44 @@ public static function getSeason($today, $jsonFileUrl): array {
1717 // convert $today passed to 4-character mmdd format
1818 // since we don't care about the specific year
1919 $ timestamp = Date::createFromFormat ('Y-m-d ' , $ today );
20+ $ currentYear = Date::createFromFormat ('Y-m-d ' , $ today )->format ('Y ' );
2021
21- // create $currentSeason to hold an array of data to return
22+ $ wrapper = option ('scottboms.microseasons.wrapper ' ) ?? 'div ' ;
23+ $ class = option ('scottboms.microseasons.class ' ) ?? 'microseasons ' ;
24+ $ includedates = option ('scottboms.microseasons.includedates ' ) ?? True ;
25+
26+ // initialize $currentSeason to hold an array of data to return
2227 $ currentSeason = array ();
2328
2429 // check which season the current date falls within
2530 foreach ($ seasonsArray as $ season ) {
26- $ start = Date::createFromFormat ('Y-m-d ' , $ season ["start " ]);
27- $ end = Date::createFromFormat ('Y-m-d ' , $ season ["end " ]);
31+ // handle updating the raw dates from the json values
32+ $ start = Date::createFromFormat ('Y-m-d ' , $ currentYear . '- ' . substr ($ season ["start " ], 5 ));
33+ $ end = Date::createFromFormat ('Y-m-d ' , $ currentYear . '- ' . substr ($ season ["end " ], 5 ));
2834
2935 // adjust the start and end dates to handle year transitions
3036 if ($ start > $ end ) {
31- if ($ timestamp >= $ start || $ timestamp < $ end ) {
37+ if ($ timestamp >= $ start || $ timestamp <= $ end ) {
3238 $ season ['start ' ] = $ start ->format (option ("scottboms.microseasons.dateformat " )) ?? $ start ->format ('M d ' );
3339 $ season ['end ' ] = $ end ->format (option ("scottboms.microseasons.dateformat " )) ?? $ end ->format ('M d ' );
40+ $ season ['wrapper ' ] = $ wrapper ;
41+ $ season ['class ' ] = $ class ;
42+ $ season ['includedates ' ] = $ includedates ;
43+ $ season ['year ' ] = $ currentYear ;
44+ $ season ['start ' ] = $ season ['start ' ];
45+ $ season ['end ' ] = $ season ['end ' ];
3446 return $ currentSeason [] = $ season ; // return the matching season
3547 }
3648 } else {
37- if ($ timestamp >= $ start && $ timestamp < $ end ) {
49+ if ($ timestamp >= $ start && $ timestamp <= $ end ) {
3850 $ season ['start ' ] = $ start ->format (option ("scottboms.microseasons.dateformat " )) ?? $ start ->format ('M d ' );
3951 $ season ['end ' ] = $ end ->format (option ("scottboms.microseasons.dateformat " )) ?? $ end ->format ('M d ' );
52+ $ season ['wrapper ' ] = $ wrapper ;
53+ $ season ['class ' ] = $ class ;
54+ $ season ['includedates ' ] = $ includedates ;
55+ $ season ['year ' ] = $ currentYear ;
56+ $ season ['start ' ] = $ season ['start ' ];
57+ $ season ['end ' ] = $ season ['end ' ];
4058 return $ currentSeason [] = $ season ; // return the matching season
4159 }
4260 }
0 commit comments