takuya/php-time-overlap

Check TimeInterval/Event/Calendar overlapping.

1.1 2022-12-23 08:56 UTC

This package is auto-updated.

Last update: 2024-05-06 11:15:14 UTC


README

This library for checking Events/Schedule TimeRange have Overlapping.

Check has overlapping.

Usage

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.

$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.

names-with-equal.png

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

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

composer require takuya/php-timerange-overlap

Testing

git clone https://github.com/takuya/php-timerange-overlap
cd php-timerange-overlap
composer install 
vendor/bin/phpunit