PHPackages                             yue/yeararound - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. yue/yeararound

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

yue/yeararound
==============

Parse any month in any language then get season name

0.0.4(7y ago)240MIT

Since Mar 31Compare

[ Source](https://github.com/HiYue/YearAround)[ Packagist](https://packagist.org/packages/yue/yeararound)[ RSS](/packages/yue-yeararound/feed)WikiDiscussions Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (6)Used By (0)

Year-Around
===========

[](#year-around)

- Support English, Chinese, Japanese, French, Germany and Spanish
- 支持自动输出 中/英/日/德/法/西 的月份与季节
- Support Constellations
- 支持根据日期获取星座 可输出每个月可能的星座
- Parse any month in any language is the start or end of a season.
- 解析任意给定的日期来判定是否为一年中的某个季节的开始和结束
- When a year is not start from January, such as a Financial Year in Australia
- 方便的处理那些不是从一月开始的年的情况 比如财政年度可能是从7月份开始
- Configurations in .env file, compatible with Laravel framework
- 可以在 .env 文件中灵活定义配置参数 可以在Laravel中直接使用

Installation
------------

[](#installation)

### With Composer

[](#with-composer)

```
$ composer require yue/yeararound

```

How to Use 使用说明
---------------

[](#how-to-use-使用说明)

### Global configurations in flexible 灵活的自动配置 兼容Laravel

[](#global-configurations-in-flexible-灵活的自动配置-兼容laravel)

- YEAR\_AROUND\_START\_MONTH=7 // 全局配置以7月份作为起始年 默认或缺失此配置时 起始月份为1月
- YEAR\_AROUND\_HEMISPHERE=1 // 在北半球使用; 南半球使用设置为2 则季节会反转
- YEAR\_AROUND\_FORMAT\_SEPARATOR="-" // 年月之间的分隔符
- YEAR\_AROUND\_LANGUAGE="EN" // Default Language: English; Support CN/ES/FR/DE/JP 默认语言英语

```
/** File: .env.example */
YEAR_AROUND_START_MONTH=1
YEAR_AROUND_HEMISPHERE=1
YEAR_AROUND_FORMAT_SEPARATOR="-"
YEAR_AROUND_LANGUAGE="EN"

```

### Year, Season and Month 年月日

[](#year-season-and-month-年月日)

```
use Yue\YearAround\Context;
use Yue\YearAround\Contracts\ISeason;
use Yue\YearAround\Contracts\IMonth;
use Yue\YearAround\Utilities\DateParser;

$year = Context::CreateYear(2018);

// Check if the leap year
$isLeapYear = $year->isLeapYear(); // false 是否为闰年

$seasons = $year->getSeasons();

foreach($seasons as $season){
    /** @var ISeason $season */
    var_dump($season->getName());

    // Get months of each season, it will be adjusted by hemisphere setting in .env
    // 获取每个季度或者季节包含的月份 会根据 .env 文件中半球的设置自动生成
    $months = $season->getMonths();
    foreach($months as $month){
        /** @var IMonth $month */
        var_dump($month);
    }
}

// Can get the end day of any month in any year
// 可以获取某个月在任何年的最后一天
$feb = DateParser::GetMonth(2);
$lastDayInt = $feb->getLastDay(2000)->day; // It's 29 得到闰月值 29
$lastDayInt = $feb->getLastDay(2001)->day; // It's 28 得到闰月值 28
```

### Constellations 星座的获取

[](#constellations-星座的获取)

```
use Yue\YearAround\Context;
use Yue\YearAround\Contracts\IConstellation;
use Yue\YearAround\Utilities\DateParser;
use Yue\YearAround\Utilities\DictionaryFactory;

$constellation = Context::CreateConstellation(1,11,DictionaryFactory::GetInstance('en'));

var_dump($constellation->getName());    // Capricorn 摩羯座
var_dump($constellation->getFistDay()->format('d/M'));  // 22/Dec 从12月22日
var_dump($constellation->getLastDay()->format('d/M'));  // 19/Jan 至1月19日

// Get previous and next 获取前一个星座和下一个星座的名称
var_dump($constellation->prev()->getName());    // Sagittarius 前一个星座是射手座
var_dump($constellation->next()->getName());    // Aquarius 下一个星座是水瓶座

// Get constellation by give tpye 获取指定的星座
$leo = Context::CreateConstellation(null, null, null, IConstellation::Leo);
var_dump($leo->getName()); // Leo 狮子座
```

### Season start/end 判断是否季度开始/结束月份

[](#season-startend-判断是否季度开始结束月份)

```
use Yue\YearAround\Context;

$monthInt = 3;
$monthString1 = '3';
$monthString2 = '03';
$monthString3 = 'Mar';
$monthString4 = 'March';

$isEndOfAnySeason1 = Context::IsEndOfSeason($monthInt);      // True
$isEndOfAnySeason2 = Context::IsEndOfSeason($monthString1);  // True
$isEndOfAnySeason3 = Context::IsEndOfSeason($monthString2);  // True
$isEndOfAnySeason4 = Context::IsEndOfSeason($monthString3);  // True
$isEndOfAnySeason5 = Context::IsEndOfSeason($monthString4);  // True
```

### Year start/end 判断是否年度开始/结束月份

[](#year-startend-判断是否年度开始结束月份)

- It refers to the configured YEAR\_AROUND\_START\_MONTH; By default: 1 (January)
- 将根据在配置文件中的 YEAR\_AROUND\_START\_MONTH 项来判定年度的起始 默认为1

```
use Yue\YearAround\Context;

$year = Context::CreateYear(2018);
foreach ($year->getMonths() as $month) {
    /**
     * @var \Yue\YearAround\Contracts\IMonth $month
     */
    var_dump($month); // Jan/2018; Feb/2018; ...
}

// Sometime the first month of the year might not January
// 有时候一月并非首月, 比如澳洲的Financial Year是从7月开始到第二年6月结束
$AustralianFinancialYear = Context::CreateYear(2018, 7); // 2018财政年从7月开始
foreach ($AustralianFinancialYear->getMonths() as $month) {
    /**
     * @var \Yue\YearAround\Contracts\IMonth $month
     */
    var_dump($month); // from Jul/2018; Aug/2018; ... Jan/2019; Feb/2019
}

$AustralianFinancialYear->getFirstMonth();  // Jul/2018 获取年度首月 2018年7月
$AustralianFinancialYear->getLastMonth();   // Jun/2019 获取年度末月 2019年6月
```

Test
====

[](#test)

- composer test
- 运行 composer test 命令即可

Contributing
------------

[](#contributing)

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Make your changes
4. Run the tests, adding new ones for your own code if necessary (`phpunit`)
5. Commit your changes (`git commit -am 'Added some feature'`)
6. Push to the branch (`git push origin my-new-feature`)
7. Create new Pull Request

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

2646d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca95e38db285a8761092332d235ca17b3c3740081b44262931f76d64fe35ce26?d=identicon)[justinwangyue](/maintainers/justinwangyue)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yue-yeararound/health.svg)

```
[![Health](https://phpackages.com/badges/yue-yeararound/health.svg)](https://phpackages.com/packages/yue-yeararound)
```

###  Alternatives

[spatie/laravel-sitemap

Create and generate sitemaps with ease

2.6k15.9M139](/packages/spatie-laravel-sitemap)[statamic/cms

The Statamic CMS Core Package

4.8k3.5M922](/packages/statamic-cms)[bitrix24/b24phpsdk

An official PHP library for the Bitrix24 REST API

10139.4k5](/packages/bitrix24-b24phpsdk)[pimcore/studio-backend-bundle

Pimcore Studio Backend Bundle

20171.5k14](/packages/pimcore-studio-backend-bundle)[japanese-date/japanese-date

日本の暦、祝日を取り扱うライブラリ

169.9k](/packages/japanese-date-japanese-date)[grazulex/laravel-atlas

Laravel Atlas scans your Laravel project to generate a complete, structured map of its internal components — models, controllers, routes, jobs, observers, events, commands, and more — and exports visual or machine-readable representations in formats like Mermaid, Markdown, JSON, or PDF.

192.3k](/packages/grazulex-laravel-atlas)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
