Download the PHP package networkrailbusinesssystems/financial-calendar without Composer

On this page you can find all versions of the php package networkrailbusinesssystems/financial-calendar. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package financial-calendar

Financial Calendar

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

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

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

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.

Date Formats

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

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

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

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

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

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

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

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

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:

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

Navigating the Calendar

Move the calendar to the next financial period or week:

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

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:

Endpoints

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

Instance

Function Parameters Returns Fluent
new FinancialCalendar $date, [$format] self
setShortWeekLimit $limit self Yes
setYearStart $month, $day self Yes
setWeekEnd $day self Yes
setDate $date, [$format] self Yes
recalculate self Yes
nextPeriod self Yes
nextWeek self Yes
getYearStart $year Carbon
getYearEnd $year Carbon
getPeriodStart $year, $period Carbon
getPeriodEnd $year, $period Carbon
getWeekEnd int
getDate Carbon
asArray array
asObject stdClass
Property Type
date Carbon
dayWeekEnds int
dayWeekStarts int
year int
weekInYear int
quarter int
period int
weekInPeriod int
shortWeekLimit int

Static

Function Parameters Returns
::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 $year Carbon
::endDateForYear $year Carbon
::startDateForPeriod $year, $period Carbon
::endDateForPeriod $year, $period Carbon

Testing

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


All versions of financial-calendar with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
nesbot/carbon Version ^3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package networkrailbusinesssystems/financial-calendar contains the following files

Loading the files please wait ....