PHPackages                             roussks/financial-year - 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. roussks/financial-year

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

roussks/financial-year
======================

A simple library for financial year date calculations. Includes an Interface and a DateTime implementation.

v1.3.0(2y ago)9240[8 issues](https://github.com/RoussKS/financial-year/issues)[4 PRs](https://github.com/RoussKS/financial-year/pulls)1MITPHPPHP ^7.1 || ^8.0CI failing

Since Jun 2Pushed 3w ago2 watchersCompare

[ Source](https://github.com/RoussKS/financial-year)[ Packagist](https://packagist.org/packages/roussks/financial-year)[ RSS](/packages/roussks-financial-year/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (18)Used By (1)

\\RoussKS\\FinancialYear - Financial Year PHP Library
=====================================================

[](#roussksfinancialyear---financial-year-php-library)

[![Latest Version](https://camo.githubusercontent.com/997c15612f8eb92e370ab005f72223a0f9820d85a50afd99f1f287ab474b3f14/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f526f7573734b532f66696e616e6369616c2d796561722e7376673f7374796c653d726f756e642d737175617265)](https://github.com/RoussKS/financial-year/releases)[![Build Status](https://github.com/RoussKS/financial-year/actions/workflows/test.yml/badge.svg)](https://github.com/RoussKS/financial-year/actions/workflows/test.yml/badge.svg)[![GitHub license](https://camo.githubusercontent.com/0749a93a5a8c322f05a17e1b04e3262c85a5eaa733ac0fdf7ab61529fcf637e1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f526f7573734b532f66696e616e6369616c2d796561722e737667)](https://github.com/RoussKS/financial-year/blob/master/LICENSE)

### Introduction / Background / Purpose

[](#introduction--background--purpose)

In my first working environment as a software/web developer, I stumbled upon the need to do different calculations for financial/accounting year purposes. The business also happened to have a non-standard calendar financial year (types explained below). Hence, each time we needed to get any sort of report (transactions, conversion rate, sales etc) we used a predefined list provided by our business analyst.

This library aims to solve this business problem in a consistent manner.

The calculation of week, period, year and end dates of those for the business.

According to [wikipedia](https://en.wikipedia.org/wiki/Fiscal_year)

> A fiscal year (or financial year, or sometimes budget year) is the period used by governments for accounting and budget purposes, which varies between countries. It is also used for financial reporting by business and other organizations.

An organisation financial year can be based on the following 2 methods:

1. Starting on the same date every year.
    - This is the *`calendar`* type for this library.
2. Ending on the same day of the week every year.
    - This is the *`business`* type for this library. > The "fiscal year's end" (FYE) is the date that marks the end of the fiscal year. Some companies—such as Cisco Systems\[1\]—end their fiscal year on the same day of the week each year, e.g. the day that is closest to a particular date (for example, the Friday closest to 31 December). Under such a system, some fiscal years will have 52 weeks and others 53 weeks.
    - A financial year of this type, always has 364 days a year and is divided in 13 periods (each period has 4 weeks, 28 days).
    - The current library will accommodate the 52-53 weeks methodology of financial year, where a 53rd week is added at the end of a financial year in order to cover for missing days from the previous 364 day years. This is a business domain decision, hence the library does not calculate when a year should be 52 or 53 weeks. It needs to be set by the user.

Available methods can be followed through the [RoussKS\\FinancialYear\\AdapterInterface](https://github.com/RoussKS/financial-year/blob/master/src/AdapterInterface.php) until a full-fledged readme is provided.

### Requirements

[](#requirements)

- PHP Version ^7.1 || ^8.0 ( 7.1 =&lt; PHP Version =&lt; 8.x.x according to [Composer docs version constraints](https://getcomposer.org/doc/articles/versions.md#caret-version-range-) )

### Installation

[](#installation)

```
composer require roussks/financial-year
```

### Basic Use

[](#basic-use)

```
require_once __DIR__ . '/vendor/autoload.php';

// DateTimeAdapter
// If instantiating with string, it must be of ISO-8601 format 'YYYY-MM-DD'
$startDate = new \DateTime('2019-01-01');

$fy = new \RoussKS\FinancialYear\DateTimeAdapter('calendar', $startDate);

echo $fy->getFyEndDate()->format('Y-m-d'); // 2019-12-31
```

### Docker images

[](#docker-images)

The library provides a sample Dockerfile to assist in development use if you want to contribute. This using the official php cli images. Copy the `Dockerfile.example` file to Dockerfile, uncommenting the required php version.

However, you are free to use any methodology you want for developing updates &amp; bugfixes.

### Run Tests

[](#run-tests)

The library has an extensive test suite to cover most scenarios &amp; negative paths.

Be aware that some configurations for phpunit are different between versions, so you might need to copy the `phpunit.xml.dist` file to `phpunit.xml` and make the necessary adjustments.

```
./vendor/phpunit/phpunit/phpunit
```

```
XDEBUG_MODE=coverage ./vendor/phpunit/phpunit/phpunit
```

```
# HTML coverage example
XDEBUG_MODE=coverage ./vendor/phpunit/phpunit/phpunit --coverage-html tests/report
```

### Run Static Analysis

[](#run-static-analysis)

The library uses PHPStan as a static analysis tool with the default level set to 5.

```
./vendor/bin/phpstan analyse
```

### Limitations

[](#limitations)

Unfortunately, the library does not support a start date of 29, 30, 31 of any month for *`calendar`* financial year type.

We do not expect much use for these dates for a calendar type financial year, as they would cause a considerable problem for accounting.

e.g. if a year starts on 31/1, does the first period end on 28/2? And the following period starts 1/3 effectively skipping a month?

If upon library usage, a user has encountered such a real business issue and can provide a mitigation logic, we can work on implementing it.

*Important*: This is allowed for a *`business`* type financial year.

### Future Plans

[](#future-plans)

- Update Readme or create Wiki page with more examples of all available methods.
- Introduce new extending library for [CarbonAdapter](https://github.com/roussks/financial-year-carbon) to work directly with [Carbon](https://github.com/briannesbitt/carbon) datetime instances.
- Introduce new extending library for [ChronosAdapter](https://github.com/roussks/financial-year-chronos) to work directly with [Chronos](https://github.com/cakephp/chronos) datetime instances.
- Introduce Laravel Package with different drivers for each of the adapters.

### Versioning

[](#versioning)

The current library will be using [Semantic Versioning](https://semver.org/)

Non-breaking changes will result in a MINOR or a PATCH version update as classified by SemVer.

Major version releases will not guarantee backwards compatibility.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance44

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity73

Established project with proven stability

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

Recently: every ~379 days

Total

12

Last Release

954d ago

PHP version history (3 changes)v1.0.0PHP &gt;=7.1

v1.0.5PHP ^7.1

v1.2.0PHP ^7.1 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7203382?v=4)[RoussKS](/maintainers/RoussKS)[@RoussKS](https://github.com/RoussKS)

---

Top Contributors

[![RoussKS](https://avatars.githubusercontent.com/u/7203382?v=4)](https://github.com/RoussKS "RoussKS (180 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/roussks-financial-year/health.svg)

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

###  Alternatives

[glhd/gretel

270349.6k5](/packages/glhd-gretel)[ideea/language-detector

Detect languages by text

334.4k](/packages/ideea-language-detector)

PHPackages © 2026

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