class CarbonPeriod implementsIterator,Countable,JsonSerializable
Substitution of DatePeriod with some modifications and many more features.
Traits
Constants
RECURRENCES_FILTER |
Built-in filter for limit by recurrences. |
END_DATE_FILTER |
Built-in filter for limit to an end. |
END_ITERATION |
Special value which can be returned by filters to end iteration. Also a filter. |
EXCLUDE_START_DATE |
Exclude start date from iteration. |
EXCLUDE_END_DATE |
Exclude end date from iteration. |
IMMUTABLE |
Yield CarbonImmutable instances. |
NEXT_MAX_ATTEMPTS |
Number of maximum attempts before giving up on finding next valid date. |
END_MAX_ATTEMPTS |
Number of maximum attempts before giving up on finding end date. |
Properties
staticprotectedarray | $macroContextStack | Stack of macro instance contexts. | from Mixin |
staticprotectedTranslatorInterface | $translator | Default translator. | from Localization |
protectedTranslatorInterface | $localTranslator | Specific translator of the current instance. | from Localization |
staticprotectedint | $humanDiffOptions | Options for diffForHumans(). | from Localization |
staticint | $PHPIntSize | Customizable PHP_INT_SIZE override. | from Options |
staticprotectedint|string | $weekStartsAt | First day of week. | from Options |
staticprotectedint|string | $weekEndsAt | Last day of week. | from Options |
staticprotectedarray | $weekendDays | Days of weekend. | from Options |
staticprotectedarray |
$regexFormats | Format regex patterns. | from Options |
staticprotectedarray | $regexFormatModifiers | Format modifiers (such as available in createFromFormat) regex patterns. | from Options |
staticprotectedbool | $monthsOverflow | Indicates if months should be calculated with overflow. | from Options |
staticprotectedbool | $yearsOverflow | Indicates if years should be calculated with overflow. | from Options |
staticprotectedbool | $strictModeEnabled | Indicates if the strict mode is in use. | from Options |
staticprotectedstring|callable|null | $formatFunction | Function to call instead of format. | from Options |
staticprotectedstring|callable|null | $createFromFormatFunction | Function to call instead of createFromFormat. | from Options |
staticprotectedstring|callable|null | $parseFunction | Function to call instead of parse. | from Options |
protectedbool|null | $localMonthsOverflow | Indicates if months should be calculated with overflow. | from Options |
protectedbool|null | $localYearsOverflow | Indicates if years should be calculated with overflow. | from Options |
protectedbool|null | $localStrictModeEnabled | Indicates if the strict mode is in use. | from Options |
protectedbool|null | $localHumanDiffOptions | Options for diffForHumans and forHumans methods. | from Options |
protectedstring|null | $localToStringFormat | Format to use on string cast. | from Options |
protectedstring|null | $localSerializer | Format to use on JSON serialization. | from Options |
protectedarray|null | $localMacros | Instance-specific macros. | from Options |
protectedarray|null | $localGenericMacros | Instance-specific generic macros. | from Options |
protectedstring|callable|null | $localFormatFunction | Function to call instead of format. | from Options |
staticprotectedarray | $macros | The registered macros. | |
protectedstring | $dateClass | Date class of iteration items. | |
protectedCarbonInterval | $dateInterval | Underlying date interval instance. Always present, one day by default. | |
protectedbool | $isDefaultInterval | Whether current date interval was set by default. | |
protectedarray | $filters | The filters stack. | |
protectedCarbonInterface | $startDate | Period start date. Applied on rewind. Always present, now by default. | |
protectedCarbonInterface|null | $endDate | Period end date. For inverted interval should be before the start date. Applied via a filter. | |
protectedint|null | $recurrences | Limit for number of recurrences. Applied via a filter. | |
protectedint | $options | Iteration options. | |
protectedint | $key | Index of current date. Always sequential, even if some dates are skipped by filters. | |
protectedCarbonInterface | $current | Current date. May temporarily hold unaccepted value when looking for a next valid date. | |
protectedDateTimeZone|null | $timezone | Timezone of current date. Taken from the start date. | |
protectedbool|string|null | $validationResult | The cached validation result for current date. | |
protectedmixed | $tzName | Timezone handler for settings() method. |
Methods
Register macros from a mixin object.
Stack a Carbon context from inside calls of self::this() and execute a given action.
Return the current context from inside a macro callee or a null if static.
Return the current context from inside a macro callee or a new one if static.
Return default humanDiff() options (merged flags as integer).
Get the default translator instance in use.
Set the default translator instance to use.
Return true if the current instance has its own translator.
Get the translator of the current instance or the default if none set.
Set the translator for the current instance.
Returns raw translation message for a given key.
Returns raw translation message for a given key.
Translate using translation string or callback available.
Translate using translation string or callback available.
Returns the alternative number for a given integer if available in the current locale.
Translate a time string from a locale to an other.
Translate a time string from the current locale ($date->locale()
) to an other.
Get/set the locale for the current instance.
Set the current translator locale and indicate if the source locale file exists.
Set the current locale to the given, execute the passed function, reset the locale to previous one, then return the result of the closure (or null if the closure was void).
Returns true if the given locale is internally supported and has short-units support.
Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
Returns the list of internally available locales and already loaded custom locales.
Returns list of Language object for each available locale. This object allow you to get the ISO name, native name, region and variant of the locale.
Initialize the default translator instance if necessary.
Get the locale of a given translator.
Throw an error if passed object is not LocaleAwareInterface.
Returns true if the strict mode is globally in use, false else.
Get the month overflow global behavior (can be overridden in specific instances).
Get the month overflow global behavior (can be overridden in specific instances).
Set the instance's timezone from a string or object and add/subtract the offset difference to start/end.
Make a CarbonPeriod instance from given variable if possible.
Create a new instance from a DatePeriod or CarbonPeriod object.
Create a new instance.
Create a new instance from an array of parameters.
Create CarbonPeriod from ISO 8601 string.
Return whether given interval contains non zero value of any time unit.
Return whether given variable is an ISO 8601 specification.
Parse given ISO 8601 string into an array of arguments.
Add missing parts of the target date from the soure date.
Register a custom macro.
Check if macro is registered.
Provide static proxy for instance aliases.
CarbonPeriod constructor.
Get a copy of the instance.
Get the getter for a property allowing both DatePeriod
snakeCase and camelCase names.
Get a property allowing both DatePeriod
snakeCase and camelCase names.
Get a property allowing both DatePeriod
snakeCase and camelCase names.
Check if an attribute exists on the object
No description
Set the iteration item class.
Returns iteration item date class.
Invert the period date interval.
Set start and end date.
Change the period options.
Get the period options.
Toggle given options on or off.
Toggle EXCLUDE_START_DATE option.
Toggle EXCLUDE_END_DATE option.
Get the underlying date interval.
Get start date of the period.
Get end date of the period.
Get number of recurrences.
Returns true if the start date should be excluded.
Returns true if the end date should be excluded.
Returns true if the start date should be included.
Returns true if the end date should be included.
Return the start if it's included by option, else return the start + 1 period interval.
Return the end if it's included by option, else return the end - 1 period interval.
Add a filter to the stack.
Prepend a filter to the stack.
Remove a filter by instance or name.
Return whether given instance or name is in the filter stack.
Get filters stack.
Set filters stack.
Reset filters stack.
Add a recurrences filter (set maximum number of recurrences).
Change the period start date.
Change the period end date.
No description
No description
No description
No description
No description
Skip iterations and returns iteration state (false if ended, true if still valid).
Format the date period as ISO 8601.
Convert the date period into a string.
Format the date period as ISO 8601.
Cast the current instance into the given class.
Return native DatePeriod PHP object matching the current instance.
Return true
if the period has no custom filter and is guaranteed to be endless.
Convert the date period into an array without changing current iteration state.
No description
Return the first date in the date period.
Return the last date in the date period.
Convert the date period into a string.
Add aliases for setters.
Set the instance's timezone from a string or object and apply it to start/end.
Returns the end is set, else calculated from start an recurrences.
Returns true if the current period overlaps the given one (if 1 parameter passed) or the period between 2 dates (if 2 parameters passed).
Execute a given function on each date of the period.
Execute a given function on each date of the period and yield the result of this function.
Determines if the instance is equal to another.
Determines if the instance is equal to another.
Determines if the instance is not equal to another.
Determines if the instance is not equal to another.
Determines if the start date is before an other given date.
Determines if the start date is before or the same as a given date.
Determines if the start date is after an other given date.
Determines if the start date is after or the same as a given date.
Determines if the start date is the same as a given date.
Determines if the end date is before an other given date.
Determines if the end date is before or the same as a given date.
Determines if the end date is after an other given date.
Determines if the end date is after or the same as a given date.
Determines if the end date is the same as a given date.
Return true if start date is now or later.
Return true if end date is now or later.
Return true if now is between start date (included) and end date (excluded).
Round the current instance at the given unit with given precision if specified and the given function.
Truncate the current instance at the given unit with given precision if specified.
Ceil the current instance at the given unit with given precision if specified.
Round the current instance second with given precision if specified (else period interval is used).
Round the current instance second with given precision if specified (else period interval is used).
Ceil the current instance second with given precision if specified (else period interval is used).
No description
Return true if the given date is between start and end.
Return true if the current period follows a given other period (with no overlap).
Return true if the given other period follows the current one (with no overlap).
Return true if the given period either follows or is followed by the current one.
Update properties after removing built-in filters.
Create a filter tuple from raw parameters.
Return whether given callable is a string pointing to one of Carbon's is* methods and should be automatically converted to a filter callback.
Recurrences filter callback (limits number of recurrences).
End iteration filter callback.
Handle change of the parameters.
Validate current date and stop iteration when necessary.
Check whether current value and key pass all the filters.
Keep incrementing the current date until a valid date is found or the iteration is ended.
Call given macro.
Return the Carbon instance passed through, a now instance in the same timezone if null given or parse the input if string given.
Resolve passed arguments or DatePeriod to a CarbonPeriod object.
Details
inIntervalRoundingat line23
protected
callRoundMethod(string$method,array$parameters)
inIntervalRoundingat line38
protected
roundWith($precision,$function)
at line579
staticvoid
mixin(object|string$mixin)
Register macros from a mixin object.
inMixinat line151
staticprotectedmixed
bindMacroContext(Mixin|null$context,callable$callable)
Stack a Carbon context from inside calls of self::this() and execute a given action.
inMixinat line177
staticprotectedMixin|null
context()
Return the current context from inside a macro callee or a null if static.
inMixinat line187
staticprotectedMixin
this()
Return the current context from inside a macro callee or a new one if static.
inLocalizationat line70
static
setHumanDiffOptions(int$humanDiffOptions)deprecated
deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method.
inLocalizationat line82
static
enableHumanDiffOption(int$humanDiffOption)deprecated
deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method.
inLocalizationat line94
static
disableHumanDiffOption(int$humanDiffOption)deprecated
deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method.
inLocalizationat line104
staticint
getHumanDiffOptions()
Return default humanDiff() options (merged flags as integer).
inLocalizationat line114
staticTranslatorInterface
getTranslator()
Get the default translator instance in use.
inLocalizationat line126
staticvoid
setTranslator(TranslatorInterface$translator)
Set the default translator instance to use.
inLocalizationat line136
bool
hasLocalTranslator()
Return true if the current instance has its own translator.
inLocalizationat line146
TranslatorInterface
getLocalTranslator()
Get the translator of the current instance or the default if none set.
inLocalizationat line158
$this
setLocalTranslator(TranslatorInterface$translator)
Set the translator for the current instance.
inLocalizationat line175
staticstring
getTranslationMessageWith(TranslatorInterface$translator,string$key,string|null$locale =null,string|null$default =null)
Returns raw translation message for a given key.
inLocalizationat line203
string
getTranslationMessage(string$key,string|null$locale =null,string|null$default =null,TranslatorInterface$translator =null)
Returns raw translation message for a given key.
inLocalizationat line218
staticstring
translateWith(TranslatorInterface$translator,string$key,array$parameters =[],null$number =null)
Translate using translation string or callback available.
inLocalizationat line252
string
translate(string$key,array$parameters =[],string|int|float|null$number =null,TranslatorInterface|null$translator =null,bool$altNumbers =false)
Translate using translation string or callback available.
inLocalizationat line270
string
translateNumber(int$number)
Returns the alternative number for a given integer if available in the current locale.
inLocalizationat line329
staticstring
translateTimeString(string$timeString,string|null$from =null,string|null$to =null,int$mode =CarbonInterface::TRANSLATE_ALL)
Translate a time string from a locale to an other.
inLocalizationat line425
string
translateTimeStringTo(string$timeString,string|null$to =null)
Translate a time string from the current locale ($date->locale()
) to an other.
inLocalizationat line438
$this|string
locale(string$locale =null,string...$fallbackLocales)
Get/set the locale for the current instance.
inLocalizationat line470
staticstring
getLocale()
Get the current translator locale.
inLocalizationat line483
staticbool
setLocale(string$locale)
Set the current translator locale and indicate if the source locale file exists.
Pass 'auto' as locale to use closest language from the current LC_TIME locale.
inLocalizationat line495
static
setFallbackLocale(string$locale)
Set the fallback locale.
inLocalizationat line520
staticstring|null
getFallbackLocale()
Get the fallback locale.
inLocalizationat line540
staticmixed
executeWithLocale(string$locale,callable$func)
Set the current locale to the given, execute the passed function, reset the locale to previous one, then return the result of the closure (or null if the closure was void).
inLocalizationat line557
staticbool
localeHasShortUnits(string$locale)
Returns true if the given locale is internally supported and has short-units support.
Support is considered enabled if either year, day or hour has a short variant translated.
inLocalizationat line578
staticbool
localeHasDiffSyntax(string$locale)
Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
Support is considered enabled if the 4 sentences are translated in the given locale.
inLocalizationat line609
staticbool
localeHasDiffOneDayWords(string$locale)
Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
Support is considered enabled if the 3 words are translated in the given locale.
inLocalizationat line627
staticbool
localeHasDiffTwoDayWords(string$locale)
Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
Support is considered enabled if the 2 words are translated in the given locale.
inLocalizationat line644
staticbool
localeHasPeriodSyntax(string$locale)
Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
Support is considered enabled if the 4 sentences are translated in the given locale.
inLocalizationat line661
staticarray
getAvailableLocales()
Returns the list of internally available locales and already loaded custom locales.
(It will ignore custom translator dynamic loading.)
inLocalizationat line676
staticLanguage[]
getAvailableLocalesInfo()
Returns list of Language object for each available locale. This object allow you to get the ISO name, native name, region and variant of the locale.
inLocalizationat line691
staticprotectedTranslatorInterface
translator()
Initialize the default translator instance if necessary.
inLocalizationat line710
protectedstring|null
getTranslatorLocale(null$translator =null)
Get the locale of a given translator.
If null or omitted, current local translator is used. If no local translator is in use, current global translator is used.
inLocalizationat line728
staticprotectedLocaleAwareInterface|null
getLocaleAwareTranslator(LocaleAwareInterface|null$translator =null)
Throw an error if passed object is not LocaleAwareInterface.
inOptionsat line246
static
useStrictMode(bool$strictModeEnabled =true)deprecated
deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method.
inOptionsat line257
staticbool
isStrictModeEnabled()
Returns true if the strict mode is globally in use, false else.
(It can be overridden in specific instances.)
inOptionsat line275
staticvoid
useMonthsOverflow(bool$monthsOverflow =true)deprecated
deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method. Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).
inOptionsat line291
staticvoid
resetMonthsOverflow()deprecated
deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method. Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).
inOptionsat line301
staticbool
shouldOverflowMonths()
Get the month overflow global behavior (can be overridden in specific instances).
inOptionsat line319
staticvoid
useYearsOverflow(bool$yearsOverflow =true)deprecated
deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method. Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).
inOptionsat line335
staticvoid
resetYearsOverflow()deprecated
deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method. Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).
inOptionsat line345
staticbool
shouldOverflowYears()
Get the month overflow global behavior (can be overridden in specific instances).
inOptionsat line367
$this|Options
settings(array$settings)
Set specific options.
- strictMode: true|false|null
- monthOverflow: true|false|null
- yearOverflow: true|false|null
- humanDiffOptions: int|null
- toStringFormat: string|Closure|null
- toJsonFormat: string|Closure|null
- locale: string|null
- timezone: \DateTimeZone|string|int|null
- macros: array|null
- genericMacros: array|null
inOptionsat line405
array
getSettings()
Returns current local settings.
inOptionsat line438
array
__debugInfo()
Show truthy properties on var_dump().
inOptionsat line455
protected
addExtraDebugInfos($infos)
at line1790
CarbonPeriod
shiftTimezone(DateTimeZone|string$timezone)
Set the instance's timezone from a string or object and add/subtract the offset difference to start/end.
at line342
staticCarbonPeriod|null
make(mixed$var)
Make a CarbonPeriod instance from given variable if possible.
at line358
staticCarbonPeriod
instance(CarbonPeriod|DatePeriod$period)
Create a new instance from a DatePeriod or CarbonPeriod object.
at line397
staticCarbonPeriod
create(...$params)
Create a new instance.
at line409
staticCarbonPeriod
createFromArray(array$params)
Create a new instance from an array of parameters.
at line422
staticCarbonPeriod
createFromIso(string$iso,int|null$options =null)
Create CarbonPeriod from ISO 8601 string.
at line442
staticprotectedbool
intervalHasTime(DateInterval$interval)
Return whether given interval contains non zero value of any time unit.
at line457
staticprotectedbool
isIso8601(mixed$var)
Return whether given variable is an ISO 8601 specification.
Note: Check is very basic, as actual validation will be done later when parsing. We just want to ensure that variable is not any other type of a valid parameter.
at line480
staticprotectedarray
parseIso8601(string$iso)
Parse given ISO 8601 string into an array of arguments.
at line515
staticprotectedstring
addMissingParts(string$source,string$target)
Add missing parts of the target date from the soure date.
at line540
staticvoid
macro(string$name,object|callable$macro)
Register a custom macro.
at line591
staticbool
hasMacro(string$name)
Check if macro is registered.
at line604
staticmixed
__callStatic(string$method,array$parameters)
Provide static proxy for instance aliases.
at line624
__construct(...$arguments)
CarbonPeriod constructor.
at line703
CarbonPeriod
copy()
Get a copy of the instance.
at line715
protectedcallable|null
getGetter(string$name)
Get the getter for a property allowing both DatePeriod
snakeCase and camelCase names.
at line747
bool|CarbonInterface|CarbonInterval|int|null
get(string$name)
Get a property allowing both DatePeriod
snakeCase and camelCase names.
at line765
bool|CarbonInterface|CarbonInterval|int|null
__get(string$name)
Get a property allowing both DatePeriod
snakeCase and camelCase names.
at line777
bool
__isset(string$name)
Check if an attribute exists on the object
at line789
CarbonPeriod
clone()
at line801
$this
setDateClass(string$dateClass)
Set the iteration item class.
at line823
string
getDateClass()
Returns iteration item date class.
at line837
$this
setDateInterval(DateInterval|string$interval)
Change the period date interval.
at line861
$this
invertDateInterval()
Invert the period date interval.
at line876
$this
setDates(DateTime|DateTimeInterface|string$start,DateTime|DateTimeInterface|string|null$end)
Set start and end date.
at line893
$this
setOptions(int|null$options)
Change the period options.
at line911
int
getOptions()
Get the period options.
at line926
$this
toggleOptions(int$options,bool|null$state =null)
Toggle given options on or off.
at line946
$this
excludeStartDate(bool$state =true)
Toggle EXCLUDE_START_DATE option.
at line958
$this
excludeEndDate(bool$state =true)
Toggle EXCLUDE_END_DATE option.
at line968
CarbonInterval
getDateInterval()
Get the underlying date interval.
at line980
CarbonInterface
getStartDate(string$rounding =null)
Get start date of the period.
at line994
CarbonInterface|null
getEndDate(string$rounding =null)
Get end date of the period.
at line1010
int|float|null
getRecurrences()
Get number of recurrences.
at line1020
bool
isStartExcluded()
Returns true if the start date should be excluded.
at line1030
bool
isEndExcluded()
Returns true if the end date should be excluded.
at line1040
bool
isStartIncluded()
Returns true if the start date should be included.
at line1050
bool
isEndIncluded()
Returns true if the end date should be included.
at line1060
CarbonInterface
getIncludedStartDate()
Return the start if it's included by option, else return the start + 1 period interval.
at line1077
CarbonInterface
getIncludedEndDate()
Return the end if it's included by option, else return the end - 1 period interval.
Warning: if the period has no fixed end, this method will iterate the period to calculate it.
at line1102
$this
addFilter(callable$callback,string$name =null)
Add a filter to the stack.
at line1123
$this
prependFilter(callable$callback,string$name =null)
Prepend a filter to the stack.
at line1141
$this
removeFilter(callable|string$filter)
Remove a filter by instance or name.
at line1166
bool
hasFilter(callable|string$filter)
Return whether given instance or name is in the filter stack.
at line1184
array
getFilters()
Get filters stack.
at line1196
$this
setFilters(array$filters)
Set filters stack.
at line1212
$this
resetFilters()
Reset filters stack.
at line1238
$this
setRecurrences(int|float|null$recurrences)
Add a recurrences filter (set maximum number of recurrences).
at line1269
$this
setStartDate(DateTime|DateTimeInterface|string$date,bool|null$inclusive =null)
Change the period start date.
at line1294
$this
setEndDate(DateTime|DateTimeInterface|string|null$date,bool|null$inclusive =null)
Change the period end date.
at line1325
valid()
at line1336
key()
at line1349
current()
at line1364
next()
at line1391
rewind()
at line1422
bool
skip(int$count =1)
Skip iterations and returns iteration state (false if ended, true if still valid).
at line1436
string
toIso8601String()
Format the date period as ISO 8601.
at line1460
string
toString()
Convert the date period into a string.
at line1494
string
spec()
Format the date period as ISO 8601.
at line1506
DatePeriod
cast(string$className)
Cast the current instance into the given class.
at line1534
DatePeriod
toDatePeriod()
Return native DatePeriod PHP object matching the current instance.
at line1546
isUnfilteredAndEndLess()
Return true
if the period has no custom filter and is guaranteed to be endless.
Note that we can't check if a period is endless as soon as it has custom filters
because filters can emit CarbonPeriod::END_ITERATION
to stop the iteration in
a way we can't predict without actually iterating the period.
at line1577
CarbonInterface[]
toArray()
Convert the date period into an array without changing current iteration state.
at line1602
count()
at line1612
CarbonInterface|null
first()
Return the first date in the date period.
at line1632
CarbonInterface|null
last()
Return the last date in the date period.
at line1644
string
__toString()
Convert the date period into a string.
at line1664
mixed
__call(string$method,array$parameters)
Add aliases for setters.
CarbonPeriod::days(3)->hours(5)->invert() ->sinceNow()->until('2010-01-10') ->filter(...) ->count()
Note: We use magic method to let static and instance aliases with the same names.
at line1767
CarbonPeriod
setTimezone(DateTimeZone|string$timezone)
Set the instance's timezone from a string or object and apply it to start/end.
at line1813
CarbonInterface
calculateEnd(string$rounding =null)
Returns the end is set, else calculated from start an recurrences.
at line1891
bool
overlaps(CarbonPeriod|DateTimeInterface|Carbon|CarbonImmutable|string$rangeOrRangeStart,DateTimeInterface|Carbon|CarbonImmutable|string|null$rangeEnd =null)
Returns true if the current period overlaps the given one (if 1 parameter passed) or the period between 2 dates (if 2 parameters passed).
at line1917
forEach(callable$callback)
Execute a given function on each date of the period.
at line1939
Generator
map(callable$callback)
Execute a given function on each date of the period and yield the result of this function.
at line1956
bool
eq(mixed$period)
Determines if the instance is equal to another.
Warning: if options differ, instances wil never be equal.
at line1969
bool
equalTo(mixed$period)
Determines if the instance is equal to another.
Warning: if options differ, instances wil never be equal.
at line1994
bool
ne(mixed$period)
Determines if the instance is not equal to another.
Warning: if options differ, instances wil never be equal.
at line2007
bool
notEqualTo(mixed$period)
Determines if the instance is not equal to another.
Warning: if options differ, instances wil never be equal.
at line2020
bool
startsBefore(mixed$date =null)
Determines if the start date is before an other given date.
(Rather start/end are included by options is ignored.)
at line2033
bool
startsBeforeOrAt(mixed$date =null)
Determines if the start date is before or the same as a given date.
(Rather start/end are included by options is ignored.)
at line2046
bool
startsAfter(mixed$date =null)
Determines if the start date is after an other given date.
(Rather start/end are included by options is ignored.)
at line2059
bool
startsAfterOrAt(mixed$date =null)
Determines if the start date is after or the same as a given date.
(Rather start/end are included by options is ignored.)
at line2072
bool
startsAt(mixed$date =null)
Determines if the start date is the same as a given date.
(Rather start/end are included by options is ignored.)
at line2085
bool
endsBefore(mixed$date =null)
Determines if the end date is before an other given date.
(Rather start/end are included by options is ignored.)
at line2098
bool
endsBeforeOrAt(mixed$date =null)
Determines if the end date is before or the same as a given date.
(Rather start/end are included by options is ignored.)
at line2111
bool
endsAfter(mixed$date =null)
Determines if the end date is after an other given date.
(Rather start/end are included by options is ignored.)
at line2124
bool
endsAfterOrAt(mixed$date =null)
Determines if the end date is after or the same as a given date.
(Rather start/end are included by options is ignored.)
at line2137
bool
endsAt(mixed$date =null)
Determines if the end date is the same as a given date.
(Rather start/end are included by options is ignored.)
at line2148
bool
isStarted()
Return true if start date is now or later.
(Rather start/end are included by options is ignored.)
at line2159
bool
isEnded()
Return true if end date is now or later.
(Rather start/end are included by options is ignored.)
at line2170
bool
isInProgress()
Return true if now is between start date (included) and end date (excluded).
(Rather start/end are included by options is ignored.)
at line2184
$this
roundUnit(string$unit,float|int|string|DateInterval|null$precision =1,string$function ='round')
Round the current instance at the given unit with given precision if specified and the given function.
at line2205
$this
floorUnit(string$unit,float|int|string|DateInterval|null$precision =1)
Truncate the current instance at the given unit with given precision if specified.
at line2218
$this
ceilUnit(string$unit,float|int|string|DateInterval|null$precision =1)
Ceil the current instance at the given unit with given precision if specified.
at line2231
$this
round(float|int|string|DateInterval|null$precision =null,string$function ='round')
Round the current instance second with given precision if specified (else period interval is used).
at line2246
$this
floor(float|int|string|DateInterval|null$precision =null)
Round the current instance second with given precision if specified (else period interval is used).
at line2258
$this
ceil(float|int|string|DateInterval|null$precision =null)
Ceil the current instance second with given precision if specified (else period interval is used).
at line2271
jsonSerialize()
at line2283
bool
contains(Carbon|CarbonPeriod|CarbonInterval|DateInterval|DatePeriod|DateTimeInterface|string|null$date =null)
Return true if the given date is between start and end.
at line2300
bool
follows($period,...$arguments)
Return true if the current period follows a given other period (with no overlap).
For instance, [2019-08-01 -> 2019-08-12] follows [2019-07-29 -> 2019-07-31] Note than in this example, follows() would be false if 2019-08-01 or 2019-07-31 was excluded by options.
at line2316
bool
isFollowedBy($period,...$arguments)
Return true if the given other period follows the current one (with no overlap).
For instance, [2019-07-29 -> 2019-07-31] is followed by [2019-08-01 -> 2019-08-12] Note than in this example, isFollowedBy() would be false if 2019-08-01 or 2019-07-31 was excluded by options.
at line2333
bool
isConsecutiveWith($period,...$arguments)
Return true if the given period either follows or is followed by the current one.
at line2343
protectedvoid
updateInternalState()
Update properties after removing built-in filters.
at line2363
protectedarray
createFilterTuple(array$parameters)
Create a filter tuple from raw parameters.
Will create an automatic filter callback for one of Carbon's is* methods.
at line2384
protectedbool
isCarbonPredicateMethod(callable$callable)
Return whether given callable is a string pointing to one of Carbon's is* methods and should be automatically converted to a filter callback.
at line2400
protectedbool|string
filterRecurrences(Carbon$current,int$key)
Recurrences filter callback (limits number of recurrences).
at line2416
protectedbool|string
filterEndDate(Carbon$current)
End date filter callback.
at line2434
protectedstring
endIteration()
End iteration filter callback.
at line2442
protected
handleChangedParameters()
Handle change of the parameters.
at line2461
protectedbool|string
validateCurrentDate()
Validate current date and stop iteration when necessary.
Returns true when current date is valid, false if it is not, or static::END_ITERATION when iteration should be stopped.
at line2476
protectedbool|string
checkFilters()
Check whether current value and key pass all the filters.
at line2507
protectedCarbonInterface
prepareForReturn(CarbonInterface$date)
Prepare given date to be returned to the external logic.
at line2525
protectedvoid
incrementCurrentDateUntilValid()
Keep incrementing the current date until a valid date is found or the iteration is ended.
at line2548
protectedmixed
callMacro(string$name,array$parameters)
Call given macro.
at line2569
protectedCarbonInterface
resolveCarbon(Carbon|CarbonPeriod|CarbonInterval|DateInterval|DatePeriod|DateTimeInterface|string|null$date =null)
Return the Carbon instance passed through, a now instance in the same timezone if null given or parse the input if string given.
at line2582
protectedCarbonPeriod
resolveCarbonPeriod(mixed$period,mixed...$arguments)
Resolve passed arguments or DatePeriod to a CarbonPeriod object.