Download the PHP package danoha/date-range without Composer
On this page you can find all versions of the php package danoha/date-range. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package date-range
DateRange
Working with date ranges made easy.
Installation
Works best with composer. :ok_hand:
If you do not use composer or its autoloading, require
src/DateRange.php
and src/DateRangeCollection.php
.
Then use \Danoha\DateRange
and \Danoha\DateRangeCollection
classes
directly in your code.
Usage
Working with date range:
Work with date range collection:
To get your ranges back:
Every method that accepts collection also accepts array of ranges (which can be arrays, too):
Note: definite intervals are handled as inclusive on both sides.
Available range methods
Note: all methods returning range return new instance.
That means calling $range->join(...)
twice on the same
range will create two instances and neither of them will
contain both joined ranges.
- getFrom - returns first date in range,
- getTo - returns last date in range,
- unwrap - gets range in array format,
- intersect - finds intersection between current and given range,
- overlaps - tests if current and given range overlap,
- join - finds common range between current and given range,
- isRightAfter - tests if current range is right after given range,
- isRightBefore - tests if current range is right before given range,
- subtract - returns collection of differences between current and given range,
- includes - tests if range includes given date or range,
- includesDate - tests if range includes given date,
- includesRange - tests if range includes given range,
- equals - tests if current range is equal to given range.
Available collection methods
Note: all methods returning collection return new instance.
That means calling $coll->add(...)
twice on the same
collection will create two instances and neither of them will
contain both added ranges.
- getRanges - gets ranges in current collection,
- unwrap - gets underlying date ranges in array format,
- add - adds given ranges to collection,
- includes - tests if collection includes given date or range,
- join - adds given ranges to current collection and joins ranges in current collection if possible,
- intersect - calculates all intersections with given ranges,
- subtract - subtracts given ranges from current collection.