PHP code example of cmixin / season

1. Go to this page and download the library: Download cmixin/season library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cmixin / season example snippets


(new \Season\Season)->isInSummer('2022-06-25')
(new \Season\Season)->isInSummer(new DateTimeImmutable('2022-06-25'))
(new \Season\Season)->isInSummer(Carbon::now())

use Season\Season;

(new Season)->isInSummer('2022-06-25');
(new Season)->isInSummer(new DateTimeImmutable('2022-06-25'));

use Season\Season;

$season = new Season();
$season->isInSummer('2022-06-25');
$season->isInSummer(new DateTimeImmutable('2022-06-25'));

use Season\Season;
use Psr\Clock\ClockInterface;

class ProductController
{
    public function new(Season $season, ClockInterface $clock)
    {
        $seasonName = $season->getSeason($clock->now())->getName();
    }
}

use Carbon\Carbon;
use Cmixin\SeasonMixin;

// On Laravel, the mixin will be loaded by default.
// On other applications/framework, you can enable it with:
Carbon::mixin(SeasonMixin::class);

Carbon::parse('2022-06-25')->isInSummer();

[
    3  => 20, // spring
    6  => 21, // summer
    9  => 22, // fall
    12 => 21, // winter
]

use Season\Season;

$season = new Season([
    3  => 21, // spring
    6  => 21, // summer
    9  => 21, // fall
    12 => 21, // winter
]);

 return [
    3  => 21, // spring
    6  => 21, // summer
    9  => 21, // fall
    12 => 21, // winter
];

Carbon::setSeasonConfig([
    3  => 21, // spring
    6  => 21, // summer
    9  => 21, // fall
    12 => 21, // winter
]);

echo Carbon::now()->getSeason([
    3  => 21, // spring
    6  => 21, // summer
    9  => 21, // fall
    12 => 21, // winter
])->getName();