league / period
Time range API for PHP
Fund package maintenance!
nyamsprod
Installs: 3 794 852
Dependents: 24
Suggesters: 1
Security: 0
Stars: 723
Watchers: 19
Forks: 45
Open Issues: 0
Requires
- php: ^8.1
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.52.1
- phpstan/phpstan: ^1.10.64
- phpstan/phpstan-deprecation-rules: ^1.1.4
- phpstan/phpstan-phpunit: ^1.3.16
- phpstan/phpstan-strict-rules: ^1.5.2
- phpunit/phpunit: ^10.5.15
- symfony/var-dumper: ^6.4.4
- dev-master / 5.x-dev
- 5.3.2
- 5.3.1
- 5.3.0
- 5.2.1
- 5.2.0
- 5.1.0
- 5.0.0
- 4.x-dev
- 4.12.0
- 4.11.0
- 4.10.0
- 4.9.0
- 4.8.1
- 4.8.0
- 4.7.1
- 4.7.0
- 4.6.0
- 4.5.0
- 4.4.0
- 4.3.1
- 4.3.0
- 4.2.0
- 4.1.0
- 4.0.1
- 4.0.0
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.1
- 3.0.0
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.0
- 1.0.1
- 1.0.0
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.0
- dev-feature/documentation
This package is auto-updated.
Last update: 2024-11-12 08:33:39 UTC
README
Period
is PHP's missing time range API. This package covers all basic operations regarding time ranges.
Highlights
- Represents Interval and Bounds as immutable value objects or enumeration
- Exposes named constructors to ease instantiation
- Covers all basic manipulations related to time range
- Enables working with simple or complex time ranges logic
- Fully documented
- Framework-agnostic
Documentation
Full documentation can be found at period.thephpleague.com.
System Requirements
You need PHP >= 8.1.0 but the latest stable version of PHP is recommended.
Install
Install Period
using Composer.
$ composer require league/period
or download the library and:
- use any other PSR-4 compatible autoloader.
- use the bundle autoloader script as shown below:
require 'path/to/period/repo/autoload.php'; use League\Period\Datepoint; Datepoint::fromDateString('2012-05-23')->month()->toIso80000('Y-m-d'); //returns [2012-05-01, 2012-06-01)
where path/to/period/repo
represents the path where the library was extracted.
Testing
Period
has:
- a PHPUnit test suite
- a code analysis compliance test suite using PHPStan.
- a coding style compliance test suite using PHP CS Fixer.
To run the tests, run the following command from the project folder.
$ composer test
Contributing
Contributions are welcome and will be fully credited. Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email nyamsprod@gmail.com instead of using the issue tracker.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see LICENSE for more information.