Download the PHP package cmixin/enhanced-period without Composer
On this page you can find all versions of the php package cmixin/enhanced-period. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cmixin/enhanced-period
More information about cmixin/enhanced-period
Files in cmixin/enhanced-period
Package enhanced-period
Short Description Carbon mixin to convert `Carbon\CarbonPeriod` to `Spatie\Period\Period` and vice versa
License MIT
Informations about the package enhanced-period
enhanced-period
Carbon mixin to convert Carbon\CarbonPeriod
to Spatie\Period\Period
and vice versa.
Professionally supported nesbot/carbon is now available
Install
Usage
Both output (using the default Carbon\CarbonPeriod
cast to string):
See all methods you can call on
Spatie\Period\Period
objects.
And here are the methods you can call directly on CarbonPeriod
instances:
length
overlapsWith
You can pass to overlapsWith
: Spatie\Period\Period
, CarbonPeriod
, DatePeriod
or
arguments to construct a CarbonPeriod
.
Note: ->overlapsWith
will give different results from ->overlaps
because it use internally
Spatie\Period\Period
and its precision mask (use floor rounding).
touchesWith
You can pass to overlapsWith
: Spatie\Period\Period
, CarbonPeriod
, DatePeriod
or
arguments to construct a CarbonPeriod
.
Note: ->touchesWith
will give different results from ->isConsecutiveWith
because it use internally
Spatie\Period\Period
and its precision mask (use floor rounding).
duration
Warning: this method requires spatie/period >= 2.0
Get a representation of the iteration duration.
overlap
Warning: does not match spatie/period 1 overlap() method because of
upcoming renaming, it's
for now called overlapSingle
in spatie/period.
Return overlap period between current and a given other period.
overlapAny
Warning: due to
upcoming renaming, it's
for now called overlap
in spatie/period.
Return overlap chunks that are present in at least 2 periods.
overlapAll
Return the merged overlap of all periods.
diffAny
Warning: due to
upcoming renaming, it's
for now called diffSingle
in spatie/period.
Returns the difference between the current period and an other given one.
diff
Returns periods in the current ones that are not covered by periods passed as arguments.
gap
Returns the gap period between the current one and the one passed as argument.
fromEnhancedPeriod
Convert a Spatie period into a Carbon period, you can pass true
as a second argument
to select Carbon
as date class rather than CarbonImmutable
(by default).
fromNullableEnhancedPeriod
Same as fromEnhancedPeriod
but allow null value.
fromPeriodCollection
Convert PeriodCollection
object into an array of CarbonPeriod
instances.
You can pass true
as a second argument to select Carbon
as date class rather
than CarbonImmutable
(by default).
convertDateIntervalToPrecision
Convert DateInterval
objects (such as CarbonInterval
) into a Spatie precision mask
if it exists, throws an RuntimeException
if it does not match any mask.
convertDateIntervalToPrecision
Convert Spatie precision mask into a CarbonInterval
.
All versions of enhanced-period with dependencies
nesbot/carbon Version ^2.23.0-beta.1 || ^3.0@dev || ^4.0@dev
spatie/period Version ^1.4.3 || ^2.0.0