PHPackages                             networkrailbusinesssystems/financial-calendar - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. networkrailbusinesssystems/financial-calendar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

networkrailbusinesssystems/financial-calendar
=============================================

Calculate the exact financial calendar period, week, quarter, and year, for any given date

2.0.0(1y ago)03.1k↓33.3%MITPHPPHP ^8

Since Apr 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Network-Rail-Business-Systems/financial-calendar)[ Packagist](https://packagist.org/packages/networkrailbusinesssystems/financial-calendar)[ RSS](/packages/networkrailbusinesssystems-financial-calendar/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (4)Used By (0)

Financial Calendar
==================

[](#financial-calendar)

[![Composer status](.github/composer.svg)](.github/composer.svg)[![Coverage status](.github/coverage.svg)](.github/coverage.svg)[![PHP version](.github/php.svg)](.github/php.svg)[![Tests status](.github/tests.svg)](.github/tests.svg)

Calculate the exact financial year, week-in-year, quarter, period, and week-in-period for any given date according to the Network Rail financial calendar.

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

[](#installation)

Financial Calendar may be used as a standalone class or as part of a Laravel project. Both Service Provider and Facade options are provided.

- PHP ^8
- Nesbot/Carbon ^2

You may include the library in your project using: `composer require networkrailbusinesssystems/financial-calendar`.

Usage
-----

[](#usage)

The Financial Calendar class may be directly included or called through the Laravel service provider.

Out of the box, with or without a specific facade call, it can be used both as an instanced class and as a facade.

```
$calendar = new FinancialCalendar('2018-05-08');

$calendar = FinancialCalendar::parse('2018-05-08');
```

### Date Formats

[](#date-formats)

Out of the box this class supports dates in the following formats:

- 2018-07-01 (Y-m-d)
- 2018-07-01 00:00:00 (Y-m-d h:i:s)
- Carbon instance
- DateTime instance
- 1530403200 (Timestamp)

You may pass a specific format as the second parameter of any method that accepts a date.

```
$calendar = new FinancialCalendar('01-01-2010', 'm-d-Y');

FinancialCalendar::parse('01-01-2010', 'm-d-Y');
```

Should you need support for another format, please submit a pull request.

### Year Start Dates

[](#year-start-dates)

By default every financial year begins on April 1st. If you require a calendar that begins on another date, simply call the `setYearStart` function.

#### Year Start Overrides

[](#year-start-overrides)

An array of known custom year starts can be supplied to `setYearStartOverrides`:

```
[ year => [month, day] ]

$yearStartOverrides = [
    2017 => [4, 2]
];

$calendar->setYearStartOverrides($yearStartOverrides);
```

Any known year starts for the financial calendar have been preset.

### Short Weeks

[](#short-weeks)

Sometimes the financial year is adjusted to prevent very short reporting weeks. This is compensated for with the following mechanisms:

#### Short Week Limit

[](#short-week-limit)

If the first week of the financial year is shorter than the set short week limit, it is automatically extended to the end of the next full working week.

#### Week Length Overrides

[](#week-length-overrides)

Should the automatic short week limit be insufficient, or a long week is required anywhere other than the first week, an array of week lengths is available.

The array contains a set of years, with pairs of week numbers and the length of that week, which can be applied by calling `setWeekLengthOverrides`:

```
[ year => [week => length] ]

$weekLengthOverrides = [
    2020 => [
        1 => 11
    ]
];

$calendar->setWeekLengthOverrides($weekLengthOverrides);
```

Any known week lengths for the financial calendar have been preset.

### Navigating the Calendar

[](#navigating-the-calendar)

Move the calendar to the next financial period or week:

```
$calendar
    ->nextPeriod()
    ->nextWeek();
```

If you would find other calendar navigating methods useful, get in touch or submit a PR.

### Trait

[](#trait)

If you are not storing the year and period in the database, or you need to be able to search for arbitrary dates based on a year or period in the financial calendar, you may use the `HasFinancialDates` trait on any eloquent model with an appropriate date column:

```
$myModel->forFinancialYear(2001)->get();
$myModel->forFinancialPeriod(2001, 12)->get();
```

### Endpoints

[](#endpoints)

You may utilise the calendar as an instanced or static class, and some commands support a fluent interface.

#### Instance

[](#instance)

FunctionParametersReturnsFluentnew FinancialCalendar$date, \[$format\]selfsetShortWeekLimit$limitselfYessetYearStart$month, $dayselfYessetWeekEnd$dayselfYessetDate$date, \[$format\]selfYesrecalculateselfYesnextPeriodselfYesnextWeekselfYesgetYearStart$yearCarbongetYearEnd$yearCarbongetPeriodStart$year, $periodCarbongetPeriodEnd$year, $periodCarbongetWeekEndintgetDateCarbonasArrayarrayasObjectstdClassPropertyTypedateCarbondayWeekEndsintdayWeekStartsintyearintweekInYearintquarterintperiodintweekInPeriodintshortWeekLimitint#### Static

[](#static)

FunctionParametersReturns::all$date, \[$format\]array::toArray$date, \[$format\]array::toObject$date, \[$format\]stdClass::parse$date, \[$format\]FinancialCalendar::period$date, \[$format\]int::quarter$date, \[$format\]int::weekInPeriod$date, \[$format\]int::weekInYear$date, \[$format\]int::year$date, \[$format\]int::startDateForYear$yearCarbon::endDateForYear$yearCarbon::startDateForPeriod$year, $periodCarbon::endDateForPeriod$year, $periodCarbon[![Endpoint Map](documents/program_flow.png)](documents/program_flow.png)

Testing
-------

[](#testing)

This helper has been tested using PHPUnit for accuracy and functionality, tested against actual calendar data.

- 54 tests with 8103 assertions
- Calculations verified for 2004 - 2035
- Date Calculation
- Accepted Date Formats
- Class Usage

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance47

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~543 days

Total

3

Last Release

391d ago

Major Versions

1.1.0 → 2.0.02025-04-16

PHP version history (2 changes)1.0.0PHP ^8

1.1.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17785811?v=4)[Anthony Edmonds](/maintainers/AnthonyEdmonds)[@AnthonyEdmonds](https://github.com/AnthonyEdmonds)

---

Top Contributors

[![AnthonyEdmonds](https://avatars.githubusercontent.com/u/17785811?v=4)](https://github.com/AnthonyEdmonds "AnthonyEdmonds (23 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/networkrailbusinesssystems-financial-calendar/health.svg)

```
[![Health](https://phpackages.com/badges/networkrailbusinesssystems-financial-calendar/health.svg)](https://phpackages.com/packages/networkrailbusinesssystems-financial-calendar)
```

###  Alternatives

[ashallendesign/short-url

A Laravel package for creating shortened URLs for your web apps.

1.4k1.9M4](/packages/ashallendesign-short-url)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[intervention/zodiac

Zodiac Sign Calculator

58191.7k](/packages/intervention-zodiac)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)[solspace/craft-calendar

The most powerful event management and calendaring plugin!

1830.8k1](/packages/solspace-craft-calendar)

PHPackages © 2026

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