Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/takuya/php-timerange-overlap
check time range has overlapping .
https://github.com/takuya/php-timerange-overlap
Last synced: 21 days ago
JSON representation
check time range has overlapping .
- Host: GitHub
- URL: https://github.com/takuya/php-timerange-overlap
- Owner: takuya
- License: gpl-3.0
- Created: 2022-12-22T18:56:47.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-21T11:19:48.000Z (29 days ago)
- Last Synced: 2024-10-21T16:29:42.135Z (28 days ago)
- Language: PHP
- Size: 390 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TimeRange Overlapping Checker.
![](https://github.com/takuya/php-timerange-overlap/workflows/main/badge.svg)
This library for checking Events/Schedule TimeRange have Overlapping.
## Check has overlapping.
## Usage
```php
use Takuya\PhpTimeOverlap\TimeRange;
$a = new TimeRange(new DateTime( '22:22' ),new DateTime( '23:22' ));
$b = new TimeRange(new DateTime( '22:44' ),new DateTime( '23:44' ));## check time overlap
$a->has_overlapping($b); // => true
```Other checking like this.
```php
$a->before($b);
$a->overlapped($b);
$a->during($b);
$a->overlaps($b);
$a->after($b);
$a->contains($b);
$a->same($b);
```## Supported patterns.
I named overlapping patterns like this.
EQUALS(ex A.end==B.start ) patterns are excluded intentionally. If equal ex.`A->end == B->start` compared,It will be
overlapping. Comparing equals "22:22-**22:25**" to "**22:25**-22:27" , do minus explicitly ( `-1 sec` before comparing)
.## Installation
from github
```shell
composer config repositories.'php-timerange-overlap' \
vcs https://github.com/takuya/php-timerange-overlap
composer require takuya/php-timerange-overlap:master
composer install
```from packgist
```shell
composer require takuya/php-timerange-overlap
```## Testing
```shell
git clone https://github.com/takuya/php-timerange-overlap
cd php-timerange-overlap
composer install
vendor/bin/phpunit
```