blob: 07ac0dde93d771723436720ed35b505a654b1e64 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3/**
4 * This file is part of the Carbon package.
5 *
6 * (c) Brian Nesbitt <brian@nesbot.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11namespace Carbon\Traits;
12
13use BadMethodCallException;
14use Carbon\Carbon;
15use Carbon\CarbonInterface;
16use Carbon\CarbonPeriod;
17use Carbon\CarbonTimeZone;
18use Carbon\Exceptions\BadComparisonUnitException;
19use Carbon\Exceptions\ImmutableException;
20use Carbon\Exceptions\InvalidTimeZoneException;
21use Carbon\Exceptions\InvalidTypeException;
22use Carbon\Exceptions\UnknownGetterException;
23use Carbon\Exceptions\UnknownMethodException;
24use Carbon\Exceptions\UnknownSetterException;
25use Carbon\Exceptions\UnknownUnitException;
26use Closure;
27use DateInterval;
28use DatePeriod;
29use DateTime;
30use DateTimeImmutable;
31use DateTimeInterface;
32use DateTimeZone;
33use InvalidArgumentException;
34use ReflectionException;
35use ReturnTypeWillChange;
36use Throwable;
37
38/**
39 * A simple API extension for DateTime.
40 *
41 * <autodoc generated by `composer phpdoc`>
42 *
43 * @property int $year
44 * @property int $yearIso
45 * @property int $month
46 * @property int $day
47 * @property int $hour
48 * @property int $minute
49 * @property int $second
50 * @property int $micro
51 * @property int $microsecond
52 * @property int|float|string $timestamp seconds since the Unix Epoch
53 * @property string $englishDayOfWeek the day of week in English
54 * @property string $shortEnglishDayOfWeek the abbreviated day of week in English
55 * @property string $englishMonth the month in English
56 * @property string $shortEnglishMonth the abbreviated month in English
57 * @property string $localeDayOfWeek the day of week in current locale LC_TIME
58 * @property string $shortLocaleDayOfWeek the abbreviated day of week in current locale LC_TIME
59 * @property string $localeMonth the month in current locale LC_TIME
60 * @property string $shortLocaleMonth the abbreviated month in current locale LC_TIME
61 * @property int $milliseconds
62 * @property int $millisecond
63 * @property int $milli
64 * @property int $week 1 through 53
65 * @property int $isoWeek 1 through 53
66 * @property int $weekYear year according to week format
67 * @property int $isoWeekYear year according to ISO week format
68 * @property int $dayOfYear 1 through 366
69 * @property int $age does a diffInYears() with default parameters
70 * @property int $offset the timezone offset in seconds from UTC
71 * @property int $offsetMinutes the timezone offset in minutes from UTC
72 * @property int $offsetHours the timezone offset in hours from UTC
73 * @property CarbonTimeZone $timezone the current timezone
74 * @property CarbonTimeZone $tz alias of $timezone
75 * @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday)
76 * @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday)
77 * @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday
78 * @property-read int $daysInMonth number of days in the given month
79 * @property-read string $latinMeridiem "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark)
80 * @property-read string $latinUpperMeridiem "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark)
81 * @property-read string $timezoneAbbreviatedName the current timezone abbreviated name
82 * @property-read string $tzAbbrName alias of $timezoneAbbreviatedName
83 * @property-read string $dayName long name of weekday translated according to Carbon locale, in english if no translation available for current language
84 * @property-read string $shortDayName short name of weekday translated according to Carbon locale, in english if no translation available for current language
85 * @property-read string $minDayName very short name of weekday translated according to Carbon locale, in english if no translation available for current language
86 * @property-read string $monthName long name of month translated according to Carbon locale, in english if no translation available for current language
87 * @property-read string $shortMonthName short name of month translated according to Carbon locale, in english if no translation available for current language
88 * @property-read string $meridiem lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
89 * @property-read string $upperMeridiem uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
90 * @property-read int $noZeroHour current hour from 1 to 24
91 * @property-read int $weeksInYear 51 through 53
92 * @property-read int $isoWeeksInYear 51 through 53
93 * @property-read int $weekOfMonth 1 through 5
94 * @property-read int $weekNumberInMonth 1 through 5
95 * @property-read int $firstWeekDay 0 through 6
96 * @property-read int $lastWeekDay 0 through 6
97 * @property-read int $daysInYear 365 or 366
98 * @property-read int $quarter the quarter of this instance, 1 - 4
99 * @property-read int $decade the decade of this instance
100 * @property-read int $century the century of this instance
101 * @property-read int $millennium the millennium of this instance
102 * @property-read bool $dst daylight savings time indicator, true if DST, false otherwise
103 * @property-read bool $local checks if the timezone is local, true if local, false otherwise
104 * @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise
105 * @property-read string $timezoneName the current timezone name
106 * @property-read string $tzName alias of $timezoneName
107 * @property-read string $locale locale of the current instance
108 *
109 * @method bool isUtc() Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.)
110 * @method bool isLocal() Check if the current instance has non-UTC timezone.
111 * @method bool isValid() Check if the current instance is a valid date.
112 * @method bool isDST() Check if the current instance is in a daylight saving time.
113 * @method bool isSunday() Checks if the instance day is sunday.
114 * @method bool isMonday() Checks if the instance day is monday.
115 * @method bool isTuesday() Checks if the instance day is tuesday.
116 * @method bool isWednesday() Checks if the instance day is wednesday.
117 * @method bool isThursday() Checks if the instance day is thursday.
118 * @method bool isFriday() Checks if the instance day is friday.
119 * @method bool isSaturday() Checks if the instance day is saturday.
120 * @method bool isSameYear(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same year as the instance. If null passed, compare to now (with the same timezone).
121 * @method bool isCurrentYear() Checks if the instance is in the same year as the current moment.
122 * @method bool isNextYear() Checks if the instance is in the same year as the current moment next year.
123 * @method bool isLastYear() Checks if the instance is in the same year as the current moment last year.
124 * @method bool isSameWeek(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same week as the instance. If null passed, compare to now (with the same timezone).
125 * @method bool isCurrentWeek() Checks if the instance is in the same week as the current moment.
126 * @method bool isNextWeek() Checks if the instance is in the same week as the current moment next week.
127 * @method bool isLastWeek() Checks if the instance is in the same week as the current moment last week.
128 * @method bool isSameDay(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same day as the instance. If null passed, compare to now (with the same timezone).
129 * @method bool isCurrentDay() Checks if the instance is in the same day as the current moment.
130 * @method bool isNextDay() Checks if the instance is in the same day as the current moment next day.
131 * @method bool isLastDay() Checks if the instance is in the same day as the current moment last day.
132 * @method bool isSameHour(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same hour as the instance. If null passed, compare to now (with the same timezone).
133 * @method bool isCurrentHour() Checks if the instance is in the same hour as the current moment.
134 * @method bool isNextHour() Checks if the instance is in the same hour as the current moment next hour.
135 * @method bool isLastHour() Checks if the instance is in the same hour as the current moment last hour.
136 * @method bool isSameMinute(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same minute as the instance. If null passed, compare to now (with the same timezone).
137 * @method bool isCurrentMinute() Checks if the instance is in the same minute as the current moment.
138 * @method bool isNextMinute() Checks if the instance is in the same minute as the current moment next minute.
139 * @method bool isLastMinute() Checks if the instance is in the same minute as the current moment last minute.
140 * @method bool isSameSecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same second as the instance. If null passed, compare to now (with the same timezone).
141 * @method bool isCurrentSecond() Checks if the instance is in the same second as the current moment.
142 * @method bool isNextSecond() Checks if the instance is in the same second as the current moment next second.
143 * @method bool isLastSecond() Checks if the instance is in the same second as the current moment last second.
144 * @method bool isSameMicro(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone).
145 * @method bool isCurrentMicro() Checks if the instance is in the same microsecond as the current moment.
146 * @method bool isNextMicro() Checks if the instance is in the same microsecond as the current moment next microsecond.
147 * @method bool isLastMicro() Checks if the instance is in the same microsecond as the current moment last microsecond.
148 * @method bool isSameMicrosecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone).
149 * @method bool isCurrentMicrosecond() Checks if the instance is in the same microsecond as the current moment.
150 * @method bool isNextMicrosecond() Checks if the instance is in the same microsecond as the current moment next microsecond.
151 * @method bool isLastMicrosecond() Checks if the instance is in the same microsecond as the current moment last microsecond.
152 * @method bool isCurrentMonth() Checks if the instance is in the same month as the current moment.
153 * @method bool isNextMonth() Checks if the instance is in the same month as the current moment next month.
154 * @method bool isLastMonth() Checks if the instance is in the same month as the current moment last month.
155 * @method bool isCurrentQuarter() Checks if the instance is in the same quarter as the current moment.
156 * @method bool isNextQuarter() Checks if the instance is in the same quarter as the current moment next quarter.
157 * @method bool isLastQuarter() Checks if the instance is in the same quarter as the current moment last quarter.
158 * @method bool isSameDecade(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same decade as the instance. If null passed, compare to now (with the same timezone).
159 * @method bool isCurrentDecade() Checks if the instance is in the same decade as the current moment.
160 * @method bool isNextDecade() Checks if the instance is in the same decade as the current moment next decade.
161 * @method bool isLastDecade() Checks if the instance is in the same decade as the current moment last decade.
162 * @method bool isSameCentury(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same century as the instance. If null passed, compare to now (with the same timezone).
163 * @method bool isCurrentCentury() Checks if the instance is in the same century as the current moment.
164 * @method bool isNextCentury() Checks if the instance is in the same century as the current moment next century.
165 * @method bool isLastCentury() Checks if the instance is in the same century as the current moment last century.
166 * @method bool isSameMillennium(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same millennium as the instance. If null passed, compare to now (with the same timezone).
167 * @method bool isCurrentMillennium() Checks if the instance is in the same millennium as the current moment.
168 * @method bool isNextMillennium() Checks if the instance is in the same millennium as the current moment next millennium.
169 * @method bool isLastMillennium() Checks if the instance is in the same millennium as the current moment last millennium.
170 * @method CarbonInterface years(int $value) Set current instance year to the given value.
171 * @method CarbonInterface year(int $value) Set current instance year to the given value.
172 * @method CarbonInterface setYears(int $value) Set current instance year to the given value.
173 * @method CarbonInterface setYear(int $value) Set current instance year to the given value.
174 * @method CarbonInterface months(int $value) Set current instance month to the given value.
175 * @method CarbonInterface month(int $value) Set current instance month to the given value.
176 * @method CarbonInterface setMonths(int $value) Set current instance month to the given value.
177 * @method CarbonInterface setMonth(int $value) Set current instance month to the given value.
178 * @method CarbonInterface days(int $value) Set current instance day to the given value.
179 * @method CarbonInterface day(int $value) Set current instance day to the given value.
180 * @method CarbonInterface setDays(int $value) Set current instance day to the given value.
181 * @method CarbonInterface setDay(int $value) Set current instance day to the given value.
182 * @method CarbonInterface hours(int $value) Set current instance hour to the given value.
183 * @method CarbonInterface hour(int $value) Set current instance hour to the given value.
184 * @method CarbonInterface setHours(int $value) Set current instance hour to the given value.
185 * @method CarbonInterface setHour(int $value) Set current instance hour to the given value.
186 * @method CarbonInterface minutes(int $value) Set current instance minute to the given value.
187 * @method CarbonInterface minute(int $value) Set current instance minute to the given value.
188 * @method CarbonInterface setMinutes(int $value) Set current instance minute to the given value.
189 * @method CarbonInterface setMinute(int $value) Set current instance minute to the given value.
190 * @method CarbonInterface seconds(int $value) Set current instance second to the given value.
191 * @method CarbonInterface second(int $value) Set current instance second to the given value.
192 * @method CarbonInterface setSeconds(int $value) Set current instance second to the given value.
193 * @method CarbonInterface setSecond(int $value) Set current instance second to the given value.
194 * @method CarbonInterface millis(int $value) Set current instance millisecond to the given value.
195 * @method CarbonInterface milli(int $value) Set current instance millisecond to the given value.
196 * @method CarbonInterface setMillis(int $value) Set current instance millisecond to the given value.
197 * @method CarbonInterface setMilli(int $value) Set current instance millisecond to the given value.
198 * @method CarbonInterface milliseconds(int $value) Set current instance millisecond to the given value.
199 * @method CarbonInterface millisecond(int $value) Set current instance millisecond to the given value.
200 * @method CarbonInterface setMilliseconds(int $value) Set current instance millisecond to the given value.
201 * @method CarbonInterface setMillisecond(int $value) Set current instance millisecond to the given value.
202 * @method CarbonInterface micros(int $value) Set current instance microsecond to the given value.
203 * @method CarbonInterface micro(int $value) Set current instance microsecond to the given value.
204 * @method CarbonInterface setMicros(int $value) Set current instance microsecond to the given value.
205 * @method CarbonInterface setMicro(int $value) Set current instance microsecond to the given value.
206 * @method CarbonInterface microseconds(int $value) Set current instance microsecond to the given value.
207 * @method CarbonInterface microsecond(int $value) Set current instance microsecond to the given value.
208 * @method CarbonInterface setMicroseconds(int $value) Set current instance microsecond to the given value.
209 * @method CarbonInterface setMicrosecond(int $value) Set current instance microsecond to the given value.
210 * @method CarbonInterface addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval).
211 * @method CarbonInterface addYear() Add one year to the instance (using date interval).
212 * @method CarbonInterface subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval).
213 * @method CarbonInterface subYear() Sub one year to the instance (using date interval).
214 * @method CarbonInterface addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
215 * @method CarbonInterface addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed.
216 * @method CarbonInterface subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
217 * @method CarbonInterface subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed.
218 * @method CarbonInterface addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
219 * @method CarbonInterface addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
220 * @method CarbonInterface subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
221 * @method CarbonInterface subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
222 * @method CarbonInterface addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
223 * @method CarbonInterface addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
224 * @method CarbonInterface subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
225 * @method CarbonInterface subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
226 * @method CarbonInterface addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
227 * @method CarbonInterface addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
228 * @method CarbonInterface subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
229 * @method CarbonInterface subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
230 * @method CarbonInterface addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval).
231 * @method CarbonInterface addMonth() Add one month to the instance (using date interval).
232 * @method CarbonInterface subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval).
233 * @method CarbonInterface subMonth() Sub one month to the instance (using date interval).
234 * @method CarbonInterface addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
235 * @method CarbonInterface addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed.
236 * @method CarbonInterface subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
237 * @method CarbonInterface subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed.
238 * @method CarbonInterface addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
239 * @method CarbonInterface addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
240 * @method CarbonInterface subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
241 * @method CarbonInterface subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
242 * @method CarbonInterface addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
243 * @method CarbonInterface addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
244 * @method CarbonInterface subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
245 * @method CarbonInterface subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
246 * @method CarbonInterface addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
247 * @method CarbonInterface addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
248 * @method CarbonInterface subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
249 * @method CarbonInterface subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
250 * @method CarbonInterface addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval).
251 * @method CarbonInterface addDay() Add one day to the instance (using date interval).
252 * @method CarbonInterface subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval).
253 * @method CarbonInterface subDay() Sub one day to the instance (using date interval).
254 * @method CarbonInterface addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval).
255 * @method CarbonInterface addHour() Add one hour to the instance (using date interval).
256 * @method CarbonInterface subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval).
257 * @method CarbonInterface subHour() Sub one hour to the instance (using date interval).
258 * @method CarbonInterface addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval).
259 * @method CarbonInterface addMinute() Add one minute to the instance (using date interval).
260 * @method CarbonInterface subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval).
261 * @method CarbonInterface subMinute() Sub one minute to the instance (using date interval).
262 * @method CarbonInterface addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval).
263 * @method CarbonInterface addSecond() Add one second to the instance (using date interval).
264 * @method CarbonInterface subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval).
265 * @method CarbonInterface subSecond() Sub one second to the instance (using date interval).
266 * @method CarbonInterface addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval).
267 * @method CarbonInterface addMilli() Add one millisecond to the instance (using date interval).
268 * @method CarbonInterface subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval).
269 * @method CarbonInterface subMilli() Sub one millisecond to the instance (using date interval).
270 * @method CarbonInterface addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval).
271 * @method CarbonInterface addMillisecond() Add one millisecond to the instance (using date interval).
272 * @method CarbonInterface subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval).
273 * @method CarbonInterface subMillisecond() Sub one millisecond to the instance (using date interval).
274 * @method CarbonInterface addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval).
275 * @method CarbonInterface addMicro() Add one microsecond to the instance (using date interval).
276 * @method CarbonInterface subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval).
277 * @method CarbonInterface subMicro() Sub one microsecond to the instance (using date interval).
278 * @method CarbonInterface addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval).
279 * @method CarbonInterface addMicrosecond() Add one microsecond to the instance (using date interval).
280 * @method CarbonInterface subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval).
281 * @method CarbonInterface subMicrosecond() Sub one microsecond to the instance (using date interval).
282 * @method CarbonInterface addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval).
283 * @method CarbonInterface addMillennium() Add one millennium to the instance (using date interval).
284 * @method CarbonInterface subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval).
285 * @method CarbonInterface subMillennium() Sub one millennium to the instance (using date interval).
286 * @method CarbonInterface addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
287 * @method CarbonInterface addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed.
288 * @method CarbonInterface subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
289 * @method CarbonInterface subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed.
290 * @method CarbonInterface addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
291 * @method CarbonInterface addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
292 * @method CarbonInterface subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
293 * @method CarbonInterface subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
294 * @method CarbonInterface addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
295 * @method CarbonInterface addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
296 * @method CarbonInterface subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
297 * @method CarbonInterface subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
298 * @method CarbonInterface addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
299 * @method CarbonInterface addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
300 * @method CarbonInterface subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
301 * @method CarbonInterface subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
302 * @method CarbonInterface addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval).
303 * @method CarbonInterface addCentury() Add one century to the instance (using date interval).
304 * @method CarbonInterface subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval).
305 * @method CarbonInterface subCentury() Sub one century to the instance (using date interval).
306 * @method CarbonInterface addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
307 * @method CarbonInterface addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed.
308 * @method CarbonInterface subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
309 * @method CarbonInterface subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed.
310 * @method CarbonInterface addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
311 * @method CarbonInterface addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
312 * @method CarbonInterface subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
313 * @method CarbonInterface subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
314 * @method CarbonInterface addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
315 * @method CarbonInterface addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
316 * @method CarbonInterface subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
317 * @method CarbonInterface subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
318 * @method CarbonInterface addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
319 * @method CarbonInterface addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
320 * @method CarbonInterface subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
321 * @method CarbonInterface subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
322 * @method CarbonInterface addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval).
323 * @method CarbonInterface addDecade() Add one decade to the instance (using date interval).
324 * @method CarbonInterface subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval).
325 * @method CarbonInterface subDecade() Sub one decade to the instance (using date interval).
326 * @method CarbonInterface addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
327 * @method CarbonInterface addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed.
328 * @method CarbonInterface subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
329 * @method CarbonInterface subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed.
330 * @method CarbonInterface addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
331 * @method CarbonInterface addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
332 * @method CarbonInterface subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
333 * @method CarbonInterface subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
334 * @method CarbonInterface addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
335 * @method CarbonInterface addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
336 * @method CarbonInterface subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
337 * @method CarbonInterface subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
338 * @method CarbonInterface addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
339 * @method CarbonInterface addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
340 * @method CarbonInterface subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
341 * @method CarbonInterface subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
342 * @method CarbonInterface addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval).
343 * @method CarbonInterface addQuarter() Add one quarter to the instance (using date interval).
344 * @method CarbonInterface subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval).
345 * @method CarbonInterface subQuarter() Sub one quarter to the instance (using date interval).
346 * @method CarbonInterface addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
347 * @method CarbonInterface addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed.
348 * @method CarbonInterface subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
349 * @method CarbonInterface subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed.
350 * @method CarbonInterface addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
351 * @method CarbonInterface addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
352 * @method CarbonInterface subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
353 * @method CarbonInterface subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
354 * @method CarbonInterface addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
355 * @method CarbonInterface addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
356 * @method CarbonInterface subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
357 * @method CarbonInterface subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
358 * @method CarbonInterface addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
359 * @method CarbonInterface addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
360 * @method CarbonInterface subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
361 * @method CarbonInterface subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
362 * @method CarbonInterface addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval).
363 * @method CarbonInterface addWeek() Add one week to the instance (using date interval).
364 * @method CarbonInterface subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval).
365 * @method CarbonInterface subWeek() Sub one week to the instance (using date interval).
366 * @method CarbonInterface addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval).
367 * @method CarbonInterface addWeekday() Add one weekday to the instance (using date interval).
368 * @method CarbonInterface subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval).
369 * @method CarbonInterface subWeekday() Sub one weekday to the instance (using date interval).
370 * @method CarbonInterface addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp).
371 * @method CarbonInterface addRealMicro() Add one microsecond to the instance (using timestamp).
372 * @method CarbonInterface subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp).
373 * @method CarbonInterface subRealMicro() Sub one microsecond to the instance (using timestamp).
374 * @method CarbonPeriod microsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given.
375 * @method CarbonInterface addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp).
376 * @method CarbonInterface addRealMicrosecond() Add one microsecond to the instance (using timestamp).
377 * @method CarbonInterface subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp).
378 * @method CarbonInterface subRealMicrosecond() Sub one microsecond to the instance (using timestamp).
379 * @method CarbonPeriod microsecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given.
380 * @method CarbonInterface addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp).
381 * @method CarbonInterface addRealMilli() Add one millisecond to the instance (using timestamp).
382 * @method CarbonInterface subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp).
383 * @method CarbonInterface subRealMilli() Sub one millisecond to the instance (using timestamp).
384 * @method CarbonPeriod millisUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given.
385 * @method CarbonInterface addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp).
386 * @method CarbonInterface addRealMillisecond() Add one millisecond to the instance (using timestamp).
387 * @method CarbonInterface subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp).
388 * @method CarbonInterface subRealMillisecond() Sub one millisecond to the instance (using timestamp).
389 * @method CarbonPeriod millisecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given.
390 * @method CarbonInterface addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp).
391 * @method CarbonInterface addRealSecond() Add one second to the instance (using timestamp).
392 * @method CarbonInterface subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp).
393 * @method CarbonInterface subRealSecond() Sub one second to the instance (using timestamp).
394 * @method CarbonPeriod secondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given.
395 * @method CarbonInterface addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp).
396 * @method CarbonInterface addRealMinute() Add one minute to the instance (using timestamp).
397 * @method CarbonInterface subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp).
398 * @method CarbonInterface subRealMinute() Sub one minute to the instance (using timestamp).
399 * @method CarbonPeriod minutesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given.
400 * @method CarbonInterface addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp).
401 * @method CarbonInterface addRealHour() Add one hour to the instance (using timestamp).
402 * @method CarbonInterface subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp).
403 * @method CarbonInterface subRealHour() Sub one hour to the instance (using timestamp).
404 * @method CarbonPeriod hoursUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given.
405 * @method CarbonInterface addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp).
406 * @method CarbonInterface addRealDay() Add one day to the instance (using timestamp).
407 * @method CarbonInterface subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp).
408 * @method CarbonInterface subRealDay() Sub one day to the instance (using timestamp).
409 * @method CarbonPeriod daysUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given.
410 * @method CarbonInterface addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp).
411 * @method CarbonInterface addRealWeek() Add one week to the instance (using timestamp).
412 * @method CarbonInterface subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp).
413 * @method CarbonInterface subRealWeek() Sub one week to the instance (using timestamp).
414 * @method CarbonPeriod weeksUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given.
415 * @method CarbonInterface addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp).
416 * @method CarbonInterface addRealMonth() Add one month to the instance (using timestamp).
417 * @method CarbonInterface subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp).
418 * @method CarbonInterface subRealMonth() Sub one month to the instance (using timestamp).
419 * @method CarbonPeriod monthsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given.
420 * @method CarbonInterface addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp).
421 * @method CarbonInterface addRealQuarter() Add one quarter to the instance (using timestamp).
422 * @method CarbonInterface subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp).
423 * @method CarbonInterface subRealQuarter() Sub one quarter to the instance (using timestamp).
424 * @method CarbonPeriod quartersUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given.
425 * @method CarbonInterface addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp).
426 * @method CarbonInterface addRealYear() Add one year to the instance (using timestamp).
427 * @method CarbonInterface subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp).
428 * @method CarbonInterface subRealYear() Sub one year to the instance (using timestamp).
429 * @method CarbonPeriod yearsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given.
430 * @method CarbonInterface addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp).
431 * @method CarbonInterface addRealDecade() Add one decade to the instance (using timestamp).
432 * @method CarbonInterface subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp).
433 * @method CarbonInterface subRealDecade() Sub one decade to the instance (using timestamp).
434 * @method CarbonPeriod decadesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given.
435 * @method CarbonInterface addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp).
436 * @method CarbonInterface addRealCentury() Add one century to the instance (using timestamp).
437 * @method CarbonInterface subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp).
438 * @method CarbonInterface subRealCentury() Sub one century to the instance (using timestamp).
439 * @method CarbonPeriod centuriesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given.
440 * @method CarbonInterface addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp).
441 * @method CarbonInterface addRealMillennium() Add one millennium to the instance (using timestamp).
442 * @method CarbonInterface subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp).
443 * @method CarbonInterface subRealMillennium() Sub one millennium to the instance (using timestamp).
444 * @method CarbonPeriod millenniaUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given.
445 * @method CarbonInterface roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
446 * @method CarbonInterface roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
447 * @method CarbonInterface floorYear(float $precision = 1) Truncate the current instance year with given precision.
448 * @method CarbonInterface floorYears(float $precision = 1) Truncate the current instance year with given precision.
449 * @method CarbonInterface ceilYear(float $precision = 1) Ceil the current instance year with given precision.
450 * @method CarbonInterface ceilYears(float $precision = 1) Ceil the current instance year with given precision.
451 * @method CarbonInterface roundMonth(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
452 * @method CarbonInterface roundMonths(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
453 * @method CarbonInterface floorMonth(float $precision = 1) Truncate the current instance month with given precision.
454 * @method CarbonInterface floorMonths(float $precision = 1) Truncate the current instance month with given precision.
455 * @method CarbonInterface ceilMonth(float $precision = 1) Ceil the current instance month with given precision.
456 * @method CarbonInterface ceilMonths(float $precision = 1) Ceil the current instance month with given precision.
457 * @method CarbonInterface roundDay(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
458 * @method CarbonInterface roundDays(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
459 * @method CarbonInterface floorDay(float $precision = 1) Truncate the current instance day with given precision.
460 * @method CarbonInterface floorDays(float $precision = 1) Truncate the current instance day with given precision.
461 * @method CarbonInterface ceilDay(float $precision = 1) Ceil the current instance day with given precision.
462 * @method CarbonInterface ceilDays(float $precision = 1) Ceil the current instance day with given precision.
463 * @method CarbonInterface roundHour(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
464 * @method CarbonInterface roundHours(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
465 * @method CarbonInterface floorHour(float $precision = 1) Truncate the current instance hour with given precision.
466 * @method CarbonInterface floorHours(float $precision = 1) Truncate the current instance hour with given precision.
467 * @method CarbonInterface ceilHour(float $precision = 1) Ceil the current instance hour with given precision.
468 * @method CarbonInterface ceilHours(float $precision = 1) Ceil the current instance hour with given precision.
469 * @method CarbonInterface roundMinute(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
470 * @method CarbonInterface roundMinutes(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
471 * @method CarbonInterface floorMinute(float $precision = 1) Truncate the current instance minute with given precision.
472 * @method CarbonInterface floorMinutes(float $precision = 1) Truncate the current instance minute with given precision.
473 * @method CarbonInterface ceilMinute(float $precision = 1) Ceil the current instance minute with given precision.
474 * @method CarbonInterface ceilMinutes(float $precision = 1) Ceil the current instance minute with given precision.
475 * @method CarbonInterface roundSecond(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
476 * @method CarbonInterface roundSeconds(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
477 * @method CarbonInterface floorSecond(float $precision = 1) Truncate the current instance second with given precision.
478 * @method CarbonInterface floorSeconds(float $precision = 1) Truncate the current instance second with given precision.
479 * @method CarbonInterface ceilSecond(float $precision = 1) Ceil the current instance second with given precision.
480 * @method CarbonInterface ceilSeconds(float $precision = 1) Ceil the current instance second with given precision.
481 * @method CarbonInterface roundMillennium(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
482 * @method CarbonInterface roundMillennia(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
483 * @method CarbonInterface floorMillennium(float $precision = 1) Truncate the current instance millennium with given precision.
484 * @method CarbonInterface floorMillennia(float $precision = 1) Truncate the current instance millennium with given precision.
485 * @method CarbonInterface ceilMillennium(float $precision = 1) Ceil the current instance millennium with given precision.
486 * @method CarbonInterface ceilMillennia(float $precision = 1) Ceil the current instance millennium with given precision.
487 * @method CarbonInterface roundCentury(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
488 * @method CarbonInterface roundCenturies(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
489 * @method CarbonInterface floorCentury(float $precision = 1) Truncate the current instance century with given precision.
490 * @method CarbonInterface floorCenturies(float $precision = 1) Truncate the current instance century with given precision.
491 * @method CarbonInterface ceilCentury(float $precision = 1) Ceil the current instance century with given precision.
492 * @method CarbonInterface ceilCenturies(float $precision = 1) Ceil the current instance century with given precision.
493 * @method CarbonInterface roundDecade(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
494 * @method CarbonInterface roundDecades(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
495 * @method CarbonInterface floorDecade(float $precision = 1) Truncate the current instance decade with given precision.
496 * @method CarbonInterface floorDecades(float $precision = 1) Truncate the current instance decade with given precision.
497 * @method CarbonInterface ceilDecade(float $precision = 1) Ceil the current instance decade with given precision.
498 * @method CarbonInterface ceilDecades(float $precision = 1) Ceil the current instance decade with given precision.
499 * @method CarbonInterface roundQuarter(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
500 * @method CarbonInterface roundQuarters(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
501 * @method CarbonInterface floorQuarter(float $precision = 1) Truncate the current instance quarter with given precision.
502 * @method CarbonInterface floorQuarters(float $precision = 1) Truncate the current instance quarter with given precision.
503 * @method CarbonInterface ceilQuarter(float $precision = 1) Ceil the current instance quarter with given precision.
504 * @method CarbonInterface ceilQuarters(float $precision = 1) Ceil the current instance quarter with given precision.
505 * @method CarbonInterface roundMillisecond(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
506 * @method CarbonInterface roundMilliseconds(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
507 * @method CarbonInterface floorMillisecond(float $precision = 1) Truncate the current instance millisecond with given precision.
508 * @method CarbonInterface floorMilliseconds(float $precision = 1) Truncate the current instance millisecond with given precision.
509 * @method CarbonInterface ceilMillisecond(float $precision = 1) Ceil the current instance millisecond with given precision.
510 * @method CarbonInterface ceilMilliseconds(float $precision = 1) Ceil the current instance millisecond with given precision.
511 * @method CarbonInterface roundMicrosecond(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
512 * @method CarbonInterface roundMicroseconds(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
513 * @method CarbonInterface floorMicrosecond(float $precision = 1) Truncate the current instance microsecond with given precision.
514 * @method CarbonInterface floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision.
515 * @method CarbonInterface ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision.
516 * @method CarbonInterface ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision.
517 * @method string shortAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
518 * @method string longAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
519 * @method string shortRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
520 * @method string longRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
521 * @method string shortRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
522 * @method string longRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
523 * @method string shortRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
524 * @method string longRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
525 *
526 * </autodoc>
527 */
528trait Date
529{
530 use Boundaries;
531 use Comparison;
532 use Converter;
533 use Creator;
534 use Difference;
535 use Macro;
536 use Modifiers;
537 use Mutability;
538 use ObjectInitialisation;
539 use Options;
540 use Rounding;
541 use Serialization;
542 use Test;
543 use Timestamp;
544 use Units;
545 use Week;
546
547 /**
548 * Names of days of the week.
549 *
550 * @var array
551 */
552 protected static $days = [
553 // @call isDayOfWeek
554 CarbonInterface::SUNDAY => 'Sunday',
555 // @call isDayOfWeek
556 CarbonInterface::MONDAY => 'Monday',
557 // @call isDayOfWeek
558 CarbonInterface::TUESDAY => 'Tuesday',
559 // @call isDayOfWeek
560 CarbonInterface::WEDNESDAY => 'Wednesday',
561 // @call isDayOfWeek
562 CarbonInterface::THURSDAY => 'Thursday',
563 // @call isDayOfWeek
564 CarbonInterface::FRIDAY => 'Friday',
565 // @call isDayOfWeek
566 CarbonInterface::SATURDAY => 'Saturday',
567 ];
568
569 /**
570 * Will UTF8 encoding be used to print localized date/time ?
571 *
572 * @var bool
573 */
574 protected static $utf8 = false;
575
576 /**
577 * List of unit and magic methods associated as doc-comments.
578 *
579 * @var array
580 */
581 protected static $units = [
582 // @call setUnit
583 // @call addUnit
584 'year',
585 // @call setUnit
586 // @call addUnit
587 'month',
588 // @call setUnit
589 // @call addUnit
590 'day',
591 // @call setUnit
592 // @call addUnit
593 'hour',
594 // @call setUnit
595 // @call addUnit
596 'minute',
597 // @call setUnit
598 // @call addUnit
599 'second',
600 // @call setUnit
601 // @call addUnit
602 'milli',
603 // @call setUnit
604 // @call addUnit
605 'millisecond',
606 // @call setUnit
607 // @call addUnit
608 'micro',
609 // @call setUnit
610 // @call addUnit
611 'microsecond',
612 ];
613
614 /**
615 * Creates a DateTimeZone from a string, DateTimeZone or integer offset.
616 *
617 * @param DateTimeZone|string|int|null $object original value to get CarbonTimeZone from it.
618 * @param DateTimeZone|string|int|null $objectDump dump of the object for error messages.
619 *
620 * @throws InvalidTimeZoneException
621 *
622 * @return CarbonTimeZone|false
623 */
624 protected static function safeCreateDateTimeZone($object, $objectDump = null)
625 {
626 return CarbonTimeZone::instance($object, $objectDump);
627 }
628
629 /**
630 * Get the TimeZone associated with the Carbon instance (as CarbonTimeZone).
631 *
632 * @return CarbonTimeZone
633 *
634 * @link https://php.net/manual/en/datetime.gettimezone.php
635 */
636 #[ReturnTypeWillChange]
637 public function getTimezone()
638 {
639 return CarbonTimeZone::instance(parent::getTimezone());
640 }
641
642 /**
643 * List of minimum and maximums for each unit.
644 *
645 * @return array
646 */
647 protected static function getRangesByUnit()
648 {
649 return [
650 // @call roundUnit
651 'year' => [1, 9999],
652 // @call roundUnit
653 'month' => [1, static::MONTHS_PER_YEAR],
654 // @call roundUnit
655 'day' => [1, 31],
656 // @call roundUnit
657 'hour' => [0, static::HOURS_PER_DAY - 1],
658 // @call roundUnit
659 'minute' => [0, static::MINUTES_PER_HOUR - 1],
660 // @call roundUnit
661 'second' => [0, static::SECONDS_PER_MINUTE - 1],
662 ];
663 }
664
665 /**
666 * Get a copy of the instance.
667 *
668 * @return static
669 */
670 public function copy()
671 {
672 return clone $this;
673 }
674
675 /**
676 * @alias copy
677 *
678 * Get a copy of the instance.
679 *
680 * @return static
681 */
682 public function clone()
683 {
684 return clone $this;
685 }
686
687 /**
688 * Clone the current instance if it's mutable.
689 *
690 * This method is convenient to ensure you don't mutate the initial object
691 * but avoid to make a useless copy of it if it's already immutable.
692 *
693 * @return static
694 */
695 public function avoidMutation(): self
696 {
697 if ($this instanceof DateTimeImmutable) {
698 return $this;
699 }
700
701 return clone $this;
702 }
703
704 /**
705 * Returns a present instance in the same timezone.
706 *
707 * @return static
708 */
709 public function nowWithSameTz()
710 {
711 return static::now($this->getTimezone());
712 }
713
714 /**
715 * Throws an exception if the given object is not a DateTime and does not implement DateTimeInterface.
716 *
717 * @param mixed $date
718 * @param string|array $other
719 *
720 * @throws InvalidTypeException
721 */
722 protected static function expectDateTime($date, $other = [])
723 {
724 $message = 'Expected ';
725 foreach ((array) $other as $expect) {
726 $message .= "$expect, ";
727 }
728
729 if (!$date instanceof DateTime && !$date instanceof DateTimeInterface) {
730 throw new InvalidTypeException(
731 $message.'DateTime or DateTimeInterface, '.
732 (\is_object($date) ? \get_class($date) : \gettype($date)).' given'
733 );
734 }
735 }
736
737 /**
738 * Return the Carbon instance passed through, a now instance in the same timezone
739 * if null given or parse the input if string given.
740 *
741 * @param Carbon|DateTimeInterface|string|null $date
742 *
743 * @return static
744 */
745 protected function resolveCarbon($date = null)
746 {
747 if (!$date) {
748 return $this->nowWithSameTz();
749 }
750
751 if (\is_string($date)) {
752 return static::parse($date, $this->getTimezone());
753 }
754
755 static::expectDateTime($date, ['null', 'string']);
756
757 return $date instanceof self ? $date : static::instance($date);
758 }
759
760 /**
761 * Return the Carbon instance passed through, a now instance in UTC
762 * if null given or parse the input if string given (using current timezone
763 * then switching to UTC).
764 *
765 * @param Carbon|DateTimeInterface|string|null $date
766 *
767 * @return static
768 */
769 protected function resolveUTC($date = null): self
770 {
771 if (!$date) {
772 return static::now('UTC');
773 }
774
775 if (\is_string($date)) {
776 return static::parse($date, $this->getTimezone())->utc();
777 }
778
779 static::expectDateTime($date, ['null', 'string']);
780
781 return $date instanceof self ? $date : static::instance($date)->utc();
782 }
783
784 /**
785 * Return the Carbon instance passed through, a now instance in the same timezone
786 * if null given or parse the input if string given.
787 *
788 * @param Carbon|\Carbon\CarbonPeriod|\Carbon\CarbonInterval|\DateInterval|\DatePeriod|DateTimeInterface|string|null $date
789 *
790 * @return static
791 */
792 public function carbonize($date = null)
793 {
794 if ($date instanceof DateInterval) {
795 return $this->avoidMutation()->add($date);
796 }
797
798 if ($date instanceof DatePeriod || $date instanceof CarbonPeriod) {
799 $date = $date->getStartDate();
800 }
801
802 return $this->resolveCarbon($date);
803 }
804
805 ///////////////////////////////////////////////////////////////////
806 ///////////////////////// GETTERS AND SETTERS /////////////////////
807 ///////////////////////////////////////////////////////////////////
808
809 /**
810 * Get a part of the Carbon object
811 *
812 * @param string $name
813 *
814 * @throws UnknownGetterException
815 *
816 * @return string|int|bool|DateTimeZone|null
817 */
818 public function __get($name)
819 {
820 return $this->get($name);
821 }
822
823 /**
824 * Get a part of the Carbon object
825 *
826 * @param string $name
827 *
828 * @throws UnknownGetterException
829 *
830 * @return string|int|bool|DateTimeZone|null
831 */
832 public function get($name)
833 {
834 static $formats = [
835 // @property int
836 'year' => 'Y',
837 // @property int
838 'yearIso' => 'o',
839 // @property int
840 // @call isSameUnit
841 'month' => 'n',
842 // @property int
843 'day' => 'j',
844 // @property int
845 'hour' => 'G',
846 // @property int
847 'minute' => 'i',
848 // @property int
849 'second' => 's',
850 // @property int
851 'micro' => 'u',
852 // @property int
853 'microsecond' => 'u',
854 // @property-read int 0 (for Sunday) through 6 (for Saturday)
855 'dayOfWeek' => 'w',
856 // @property-read int 1 (for Monday) through 7 (for Sunday)
857 'dayOfWeekIso' => 'N',
858 // @property-read int ISO-8601 week number of year, weeks starting on Monday
859 'weekOfYear' => 'W',
860 // @property-read int number of days in the given month
861 'daysInMonth' => 't',
862 // @property int|float|string seconds since the Unix Epoch
863 'timestamp' => 'U',
864 // @property-read string "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark)
865 'latinMeridiem' => 'a',
866 // @property-read string "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark)
867 'latinUpperMeridiem' => 'A',
868 // @property string the day of week in English
869 'englishDayOfWeek' => 'l',
870 // @property string the abbreviated day of week in English
871 'shortEnglishDayOfWeek' => 'D',
872 // @property string the month in English
873 'englishMonth' => 'F',
874 // @property string the abbreviated month in English
875 'shortEnglishMonth' => 'M',
876 // @property string the day of week in current locale LC_TIME
877 'localeDayOfWeek' => '%A',
878 // @property string the abbreviated day of week in current locale LC_TIME
879 'shortLocaleDayOfWeek' => '%a',
880 // @property string the month in current locale LC_TIME
881 'localeMonth' => '%B',
882 // @property string the abbreviated month in current locale LC_TIME
883 'shortLocaleMonth' => '%b',
884 // @property-read string $timezoneAbbreviatedName the current timezone abbreviated name
885 'timezoneAbbreviatedName' => 'T',
886 // @property-read string $tzAbbrName alias of $timezoneAbbreviatedName
887 'tzAbbrName' => 'T',
888 ];
889
890 switch (true) {
891 case isset($formats[$name]):
892 $format = $formats[$name];
893 $method = str_starts_with($format, '%') ? 'formatLocalized' : 'rawFormat';
894 $value = $this->$method($format);
895
896 return is_numeric($value) ? (int) $value : $value;
897
898 // @property-read string long name of weekday translated according to Carbon locale, in english if no translation available for current language
899 case $name === 'dayName':
900 return $this->getTranslatedDayName();
901 // @property-read string short name of weekday translated according to Carbon locale, in english if no translation available for current language
902 case $name === 'shortDayName':
903 return $this->getTranslatedShortDayName();
904 // @property-read string very short name of weekday translated according to Carbon locale, in english if no translation available for current language
905 case $name === 'minDayName':
906 return $this->getTranslatedMinDayName();
907 // @property-read string long name of month translated according to Carbon locale, in english if no translation available for current language
908 case $name === 'monthName':
909 return $this->getTranslatedMonthName();
910 // @property-read string short name of month translated according to Carbon locale, in english if no translation available for current language
911 case $name === 'shortMonthName':
912 return $this->getTranslatedShortMonthName();
913 // @property-read string lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
914 case $name === 'meridiem':
915 return $this->meridiem(true);
916 // @property-read string uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
917 case $name === 'upperMeridiem':
918 return $this->meridiem();
919 // @property-read int current hour from 1 to 24
920 case $name === 'noZeroHour':
921 return $this->hour ?: 24;
922 // @property int
923 case $name === 'milliseconds':
924 // @property int
925 case $name === 'millisecond':
926 // @property int
927 case $name === 'milli':
928 return (int) floor($this->rawFormat('u') / 1000);
929
930 // @property int 1 through 53
931 case $name === 'week':
932 return (int) $this->week();
933
934 // @property int 1 through 53
935 case $name === 'isoWeek':
936 return (int) $this->isoWeek();
937
938 // @property int year according to week format
939 case $name === 'weekYear':
940 return (int) $this->weekYear();
941
942 // @property int year according to ISO week format
943 case $name === 'isoWeekYear':
944 return (int) $this->isoWeekYear();
945
946 // @property-read int 51 through 53
947 case $name === 'weeksInYear':
948 return $this->weeksInYear();
949
950 // @property-read int 51 through 53
951 case $name === 'isoWeeksInYear':
952 return $this->isoWeeksInYear();
953
954 // @property-read int 1 through 5
955 case $name === 'weekOfMonth':
956 return (int) ceil($this->day / static::DAYS_PER_WEEK);
957
958 // @property-read int 1 through 5
959 case $name === 'weekNumberInMonth':
960 return (int) ceil(($this->day + $this->avoidMutation()->startOfMonth()->dayOfWeekIso - 1) / static::DAYS_PER_WEEK);
961
962 // @property-read int 0 through 6
963 case $name === 'firstWeekDay':
964 return $this->localTranslator ? ($this->getTranslationMessage('first_day_of_week') ?? 0) : static::getWeekStartsAt();
965
966 // @property-read int 0 through 6
967 case $name === 'lastWeekDay':
968 return $this->localTranslator ? (($this->getTranslationMessage('first_day_of_week') ?? 0) + static::DAYS_PER_WEEK - 1) % static::DAYS_PER_WEEK : static::getWeekEndsAt();
969
970 // @property int 1 through 366
971 case $name === 'dayOfYear':
972 return 1 + (int) ($this->rawFormat('z'));
973
974 // @property-read int 365 or 366
975 case $name === 'daysInYear':
976 return $this->isLeapYear() ? 366 : 365;
977
978 // @property int does a diffInYears() with default parameters
979 case $name === 'age':
980 return $this->diffInYears();
981
982 // @property-read int the quarter of this instance, 1 - 4
983 // @call isSameUnit
984 case $name === 'quarter':
985 return (int) ceil($this->month / static::MONTHS_PER_QUARTER);
986
987 // @property-read int the decade of this instance
988 // @call isSameUnit
989 case $name === 'decade':
990 return (int) ceil($this->year / static::YEARS_PER_DECADE);
991
992 // @property-read int the century of this instance
993 // @call isSameUnit
994 case $name === 'century':
995 $factor = 1;
996 $year = $this->year;
997 if ($year < 0) {
998 $year = -$year;
999 $factor = -1;
1000 }
1001
1002 return (int) ($factor * ceil($year / static::YEARS_PER_CENTURY));
1003
1004 // @property-read int the millennium of this instance
1005 // @call isSameUnit
1006 case $name === 'millennium':
1007 $factor = 1;
1008 $year = $this->year;
1009 if ($year < 0) {
1010 $year = -$year;
1011 $factor = -1;
1012 }
1013
1014 return (int) ($factor * ceil($year / static::YEARS_PER_MILLENNIUM));
1015
1016 // @property int the timezone offset in seconds from UTC
1017 case $name === 'offset':
1018 return $this->getOffset();
1019
1020 // @property int the timezone offset in minutes from UTC
1021 case $name === 'offsetMinutes':
1022 return $this->getOffset() / static::SECONDS_PER_MINUTE;
1023
1024 // @property int the timezone offset in hours from UTC
1025 case $name === 'offsetHours':
1026 return $this->getOffset() / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR;
1027
1028 // @property-read bool daylight savings time indicator, true if DST, false otherwise
1029 case $name === 'dst':
1030 return $this->rawFormat('I') === '1';
1031
1032 // @property-read bool checks if the timezone is local, true if local, false otherwise
1033 case $name === 'local':
1034 return $this->getOffset() === $this->avoidMutation()->setTimezone(date_default_timezone_get())->getOffset();
1035
1036 // @property-read bool checks if the timezone is UTC, true if UTC, false otherwise
1037 case $name === 'utc':
1038 return $this->getOffset() === 0;
1039
1040 // @property CarbonTimeZone $timezone the current timezone
1041 // @property CarbonTimeZone $tz alias of $timezone
1042 case $name === 'timezone' || $name === 'tz':
1043 return CarbonTimeZone::instance($this->getTimezone());
1044
1045 // @property-read string $timezoneName the current timezone name
1046 // @property-read string $tzName alias of $timezoneName
1047 case $name === 'timezoneName' || $name === 'tzName':
1048 return $this->getTimezone()->getName();
1049
1050 // @property-read string locale of the current instance
1051 case $name === 'locale':
1052 return $this->getTranslatorLocale();
1053
1054 default:
1055 $macro = $this->getLocalMacro('get'.ucfirst($name));
1056
1057 if ($macro) {
1058 return $this->executeCallableWithContext($macro);
1059 }
1060
1061 throw new UnknownGetterException($name);
1062 }
1063 }
1064
1065 /**
1066 * Check if an attribute exists on the object
1067 *
1068 * @param string $name
1069 *
1070 * @return bool
1071 */
1072 public function __isset($name)
1073 {
1074 try {
1075 $this->__get($name);
1076 } catch (UnknownGetterException | ReflectionException $e) {
1077 return false;
1078 }
1079
1080 return true;
1081 }
1082
1083 /**
1084 * Set a part of the Carbon object
1085 *
1086 * @param string $name
1087 * @param string|int|DateTimeZone $value
1088 *
1089 * @throws UnknownSetterException|ReflectionException
1090 *
1091 * @return void
1092 */
1093 public function __set($name, $value)
1094 {
1095 if ($this->constructedObjectId === spl_object_hash($this)) {
1096 $this->set($name, $value);
1097
1098 return;
1099 }
1100
1101 $this->$name = $value;
1102 }
1103
1104 /**
1105 * Set a part of the Carbon object
1106 *
1107 * @param string|array $name
1108 * @param string|int|DateTimeZone $value
1109 *
1110 * @throws ImmutableException|UnknownSetterException
1111 *
1112 * @return $this
1113 */
1114 public function set($name, $value = null)
1115 {
1116 if ($this->isImmutable()) {
1117 throw new ImmutableException(sprintf('%s class', static::class));
1118 }
1119
1120 if (\is_array($name)) {
1121 foreach ($name as $key => $value) {
1122 $this->set($key, $value);
1123 }
1124
1125 return $this;
1126 }
1127
1128 switch ($name) {
1129 case 'milliseconds':
1130 case 'millisecond':
1131 case 'milli':
1132 case 'microseconds':
1133 case 'microsecond':
1134 case 'micro':
1135 if (str_starts_with($name, 'milli')) {
1136 $value *= 1000;
1137 }
1138
1139 while ($value < 0) {
1140 $this->subSecond();
1141 $value += static::MICROSECONDS_PER_SECOND;
1142 }
1143
1144 while ($value >= static::MICROSECONDS_PER_SECOND) {
1145 $this->addSecond();
1146 $value -= static::MICROSECONDS_PER_SECOND;
1147 }
1148
1149 $this->modify($this->rawFormat('H:i:s.').str_pad((string) round($value), 6, '0', STR_PAD_LEFT));
1150
1151 break;
1152
1153 case 'year':
1154 case 'month':
1155 case 'day':
1156 case 'hour':
1157 case 'minute':
1158 case 'second':
1159 [$year, $month, $day, $hour, $minute, $second] = array_map('intval', explode('-', $this->rawFormat('Y-n-j-G-i-s')));
1160 $$name = $value;
1161 $this->setDateTime($year, $month, $day, $hour, $minute, $second);
1162
1163 break;
1164
1165 case 'week':
1166 $this->week($value);
1167
1168 break;
1169
1170 case 'isoWeek':
1171 $this->isoWeek($value);
1172
1173 break;
1174
1175 case 'weekYear':
1176 $this->weekYear($value);
1177
1178 break;
1179
1180 case 'isoWeekYear':
1181 $this->isoWeekYear($value);
1182
1183 break;
1184
1185 case 'dayOfYear':
1186 $this->addDays($value - $this->dayOfYear);
1187
1188 break;
1189
1190 case 'timestamp':
1191 $this->setTimestamp($value);
1192
1193 break;
1194
1195 case 'offset':
1196 $this->setTimezone(static::safeCreateDateTimeZone($value / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR));
1197
1198 break;
1199
1200 case 'offsetMinutes':
1201 $this->setTimezone(static::safeCreateDateTimeZone($value / static::MINUTES_PER_HOUR));
1202
1203 break;
1204
1205 case 'offsetHours':
1206 $this->setTimezone(static::safeCreateDateTimeZone($value));
1207
1208 break;
1209
1210 case 'timezone':
1211 case 'tz':
1212 $this->setTimezone($value);
1213
1214 break;
1215
1216 default:
1217 $macro = $this->getLocalMacro('set'.ucfirst($name));
1218
1219 if ($macro) {
1220 $this->executeCallableWithContext($macro, $value);
1221
1222 break;
1223 }
1224
1225 if ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) {
1226 throw new UnknownSetterException($name);
1227 }
1228
1229 $this->$name = $value;
1230 }
1231
1232 return $this;
1233 }
1234
1235 protected function getTranslatedFormByRegExp($baseKey, $keySuffix, $context, $subKey, $defaultValue)
1236 {
1237 $key = $baseKey.$keySuffix;
1238 $standaloneKey = "${key}_standalone";
1239 $baseTranslation = $this->getTranslationMessage($key);
1240
1241 if ($baseTranslation instanceof Closure) {
1242 return $baseTranslation($this, $context, $subKey) ?: $defaultValue;
1243 }
1244
1245 if (
1246 $this->getTranslationMessage("$standaloneKey.$subKey") &&
1247 (!$context || ($regExp = $this->getTranslationMessage("${baseKey}_regexp")) && !preg_match($regExp, $context))
1248 ) {
1249 $key = $standaloneKey;
1250 }
1251
1252 return $this->getTranslationMessage("$key.$subKey", null, $defaultValue);
1253 }
1254
1255 /**
1256 * Get the translation of the current week day name (with context for languages with multiple forms).
1257 *
1258 * @param string|null $context whole format string
1259 * @param string $keySuffix "", "_short" or "_min"
1260 * @param string|null $defaultValue default value if translation missing
1261 *
1262 * @return string
1263 */
1264 public function getTranslatedDayName($context = null, $keySuffix = '', $defaultValue = null)
1265 {
1266 return $this->getTranslatedFormByRegExp('weekdays', $keySuffix, $context, $this->dayOfWeek, $defaultValue ?: $this->englishDayOfWeek);
1267 }
1268
1269 /**
1270 * Get the translation of the current short week day name (with context for languages with multiple forms).
1271 *
1272 * @param string|null $context whole format string
1273 *
1274 * @return string
1275 */
1276 public function getTranslatedShortDayName($context = null)
1277 {
1278 return $this->getTranslatedDayName($context, '_short', $this->shortEnglishDayOfWeek);
1279 }
1280
1281 /**
1282 * Get the translation of the current abbreviated week day name (with context for languages with multiple forms).
1283 *
1284 * @param string|null $context whole format string
1285 *
1286 * @return string
1287 */
1288 public function getTranslatedMinDayName($context = null)
1289 {
1290 return $this->getTranslatedDayName($context, '_min', $this->shortEnglishDayOfWeek);
1291 }
1292
1293 /**
1294 * Get the translation of the current month day name (with context for languages with multiple forms).
1295 *
1296 * @param string|null $context whole format string
1297 * @param string $keySuffix "" or "_short"
1298 * @param string|null $defaultValue default value if translation missing
1299 *
1300 * @return string
1301 */
1302 public function getTranslatedMonthName($context = null, $keySuffix = '', $defaultValue = null)
1303 {
1304 return $this->getTranslatedFormByRegExp('months', $keySuffix, $context, $this->month - 1, $defaultValue ?: $this->englishMonth);
1305 }
1306
1307 /**
1308 * Get the translation of the current short month day name (with context for languages with multiple forms).
1309 *
1310 * @param string|null $context whole format string
1311 *
1312 * @return string
1313 */
1314 public function getTranslatedShortMonthName($context = null)
1315 {
1316 return $this->getTranslatedMonthName($context, '_short', $this->shortEnglishMonth);
1317 }
1318
1319 /**
1320 * Get/set the day of year.
1321 *
1322 * @param int|null $value new value for day of year if using as setter.
1323 *
1324 * @return static|int
1325 */
1326 public function dayOfYear($value = null)
1327 {
1328 $dayOfYear = $this->dayOfYear;
1329
1330 return $value === null ? $dayOfYear : $this->addDays($value - $dayOfYear);
1331 }
1332
1333 /**
1334 * Get/set the weekday from 0 (Sunday) to 6 (Saturday).
1335 *
1336 * @param int|null $value new value for weekday if using as setter.
1337 *
1338 * @return static|int
1339 */
1340 public function weekday($value = null)
1341 {
1342 $dayOfWeek = ($this->dayOfWeek + 7 - (int) ($this->getTranslationMessage('first_day_of_week') ?? 0)) % 7;
1343
1344 return $value === null ? $dayOfWeek : $this->addDays($value - $dayOfWeek);
1345 }
1346
1347 /**
1348 * Get/set the ISO weekday from 1 (Monday) to 7 (Sunday).
1349 *
1350 * @param int|null $value new value for weekday if using as setter.
1351 *
1352 * @return static|int
1353 */
1354 public function isoWeekday($value = null)
1355 {
1356 $dayOfWeekIso = $this->dayOfWeekIso;
1357
1358 return $value === null ? $dayOfWeekIso : $this->addDays($value - $dayOfWeekIso);
1359 }
1360
1361 /**
1362 * Set any unit to a new value without overflowing current other unit given.
1363 *
1364 * @param string $valueUnit unit name to modify
1365 * @param int $value new value for the input unit
1366 * @param string $overflowUnit unit name to not overflow
1367 *
1368 * @return static
1369 */
1370 public function setUnitNoOverflow($valueUnit, $value, $overflowUnit)
1371 {
1372 try {
1373 $original = $this->avoidMutation();
1374 /** @var static $date */
1375 $date = $this->$valueUnit($value);
1376 $end = $original->avoidMutation()->endOf($overflowUnit);
1377 $start = $original->avoidMutation()->startOf($overflowUnit);
1378 if ($date < $start) {
1379 $date = $date->setDateTimeFrom($start);
1380 } elseif ($date > $end) {
1381 $date = $date->setDateTimeFrom($end);
1382 }
1383
1384 return $date;
1385 } catch (BadMethodCallException | ReflectionException $exception) {
1386 throw new UnknownUnitException($valueUnit, 0, $exception);
1387 }
1388 }
1389
1390 /**
1391 * Add any unit to a new value without overflowing current other unit given.
1392 *
1393 * @param string $valueUnit unit name to modify
1394 * @param int $value amount to add to the input unit
1395 * @param string $overflowUnit unit name to not overflow
1396 *
1397 * @return static
1398 */
1399 public function addUnitNoOverflow($valueUnit, $value, $overflowUnit)
1400 {
1401 return $this->setUnitNoOverflow($valueUnit, $this->$valueUnit + $value, $overflowUnit);
1402 }
1403
1404 /**
1405 * Subtract any unit to a new value without overflowing current other unit given.
1406 *
1407 * @param string $valueUnit unit name to modify
1408 * @param int $value amount to subtract to the input unit
1409 * @param string $overflowUnit unit name to not overflow
1410 *
1411 * @return static
1412 */
1413 public function subUnitNoOverflow($valueUnit, $value, $overflowUnit)
1414 {
1415 return $this->setUnitNoOverflow($valueUnit, $this->$valueUnit - $value, $overflowUnit);
1416 }
1417
1418 /**
1419 * Returns the minutes offset to UTC if no arguments passed, else set the timezone with given minutes shift passed.
1420 *
1421 * @param int|null $minuteOffset
1422 *
1423 * @return int|static
1424 */
1425 public function utcOffset(int $minuteOffset = null)
1426 {
1427 if (\func_num_args() < 1) {
1428 return $this->offsetMinutes;
1429 }
1430
1431 return $this->setTimezone(CarbonTimeZone::createFromMinuteOffset($minuteOffset));
1432 }
1433
1434 /**
1435 * Set the date with gregorian year, month and day numbers.
1436 *
1437 * @see https://php.net/manual/en/datetime.setdate.php
1438 *
1439 * @param int $year
1440 * @param int $month
1441 * @param int $day
1442 *
1443 * @return static
1444 */
1445 #[ReturnTypeWillChange]
1446 public function setDate($year, $month, $day)
1447 {
1448 return parent::setDate((int) $year, (int) $month, (int) $day);
1449 }
1450
1451 /**
1452 * Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
1453 *
1454 * @see https://php.net/manual/en/datetime.setisodate.php
1455 *
1456 * @param int $year
1457 * @param int $week
1458 * @param int $day
1459 *
1460 * @return static
1461 */
1462 #[ReturnTypeWillChange]
1463 public function setISODate($year, $week, $day = 1)
1464 {
1465 return parent::setISODate((int) $year, (int) $week, (int) $day);
1466 }
1467
1468 /**
1469 * Set the date and time all together.
1470 *
1471 * @param int $year
1472 * @param int $month
1473 * @param int $day
1474 * @param int $hour
1475 * @param int $minute
1476 * @param int $second
1477 * @param int $microseconds
1478 *
1479 * @return static
1480 */
1481 public function setDateTime($year, $month, $day, $hour, $minute, $second = 0, $microseconds = 0)
1482 {
1483 return $this->setDate($year, $month, $day)->setTime((int) $hour, (int) $minute, (int) $second, (int) $microseconds);
1484 }
1485
1486 /**
1487 * Resets the current time of the DateTime object to a different time.
1488 *
1489 * @see https://php.net/manual/en/datetime.settime.php
1490 *
1491 * @param int $hour
1492 * @param int $minute
1493 * @param int $second
1494 * @param int $microseconds
1495 *
1496 * @return static
1497 */
1498 #[ReturnTypeWillChange]
1499 public function setTime($hour, $minute, $second = 0, $microseconds = 0)
1500 {
1501 return parent::setTime((int) $hour, (int) $minute, (int) $second, (int) $microseconds);
1502 }
1503
1504 /**
1505 * Set the instance's timestamp.
1506 *
1507 * Timestamp input can be given as int, float or a string containing one or more numbers.
1508 *
1509 * @param float|int|string $unixTimestamp
1510 *
1511 * @return static
1512 */
1513 #[ReturnTypeWillChange]
1514 public function setTimestamp($unixTimestamp)
1515 {
1516 [$timestamp, $microseconds] = self::getIntegerAndDecimalParts($unixTimestamp);
1517
1518 return parent::setTimestamp((int) $timestamp)->setMicroseconds((int) $microseconds);
1519 }
1520
1521 /**
1522 * Set the time by time string.
1523 *
1524 * @param string $time
1525 *
1526 * @return static
1527 */
1528 public function setTimeFromTimeString($time)
1529 {
1530 if (!str_contains($time, ':')) {
1531 $time .= ':0';
1532 }
1533
1534 return $this->modify($time);
1535 }
1536
1537 /**
1538 * @alias setTimezone
1539 *
1540 * @param DateTimeZone|string $value
1541 *
1542 * @return static
1543 */
1544 public function timezone($value)
1545 {
1546 return $this->setTimezone($value);
1547 }
1548
1549 /**
1550 * Set the timezone or returns the timezone name if no arguments passed.
1551 *
1552 * @param DateTimeZone|string $value
1553 *
1554 * @return static|string
1555 */
1556 public function tz($value = null)
1557 {
1558 if (\func_num_args() < 1) {
1559 return $this->tzName;
1560 }
1561
1562 return $this->setTimezone($value);
1563 }
1564
1565 /**
1566 * Set the instance's timezone from a string or object.
1567 *
1568 * @param DateTimeZone|string $value
1569 *
1570 * @return static
1571 */
1572 #[ReturnTypeWillChange]
1573 public function setTimezone($value)
1574 {
1575 return parent::setTimezone(static::safeCreateDateTimeZone($value));
1576 }
1577
1578 /**
1579 * Set the instance's timezone from a string or object and add/subtract the offset difference.
1580 *
1581 * @param DateTimeZone|string $value
1582 *
1583 * @return static
1584 */
1585 public function shiftTimezone($value)
1586 {
1587 $offset = $this->offset;
1588 $date = $this->setTimezone($value);
1589
1590 return $date->addRealMicroseconds(($offset - $date->offset) * static::MICROSECONDS_PER_SECOND);
1591 }
1592
1593 /**
1594 * Set the instance's timezone to UTC.
1595 *
1596 * @return static
1597 */
1598 public function utc()
1599 {
1600 return $this->setTimezone('UTC');
1601 }
1602
1603 /**
1604 * Set the year, month, and date for this instance to that of the passed instance.
1605 *
1606 * @param Carbon|DateTimeInterface $date now if null
1607 *
1608 * @return static
1609 */
1610 public function setDateFrom($date = null)
1611 {
1612 $date = $this->resolveCarbon($date);
1613
1614 return $this->setDate($date->year, $date->month, $date->day);
1615 }
1616
1617 /**
1618 * Set the hour, minute, second and microseconds for this instance to that of the passed instance.
1619 *
1620 * @param Carbon|DateTimeInterface $date now if null
1621 *
1622 * @return static
1623 */
1624 public function setTimeFrom($date = null)
1625 {
1626 $date = $this->resolveCarbon($date);
1627
1628 return $this->setTime($date->hour, $date->minute, $date->second, $date->microsecond);
1629 }
1630
1631 /**
1632 * Set the date and time for this instance to that of the passed instance.
1633 *
1634 * @param Carbon|DateTimeInterface $date
1635 *
1636 * @return static
1637 */
1638 public function setDateTimeFrom($date = null)
1639 {
1640 $date = $this->resolveCarbon($date);
1641
1642 return $this->modify($date->rawFormat('Y-m-d H:i:s.u'));
1643 }
1644
1645 /**
1646 * Get the days of the week
1647 *
1648 * @return array
1649 */
1650 public static function getDays()
1651 {
1652 return static::$days;
1653 }
1654
1655 ///////////////////////////////////////////////////////////////////
1656 /////////////////////// WEEK SPECIAL DAYS /////////////////////////
1657 ///////////////////////////////////////////////////////////////////
1658
1659 private static function getFirstDayOfWeek(): int
1660 {
1661 return (int) static::getTranslationMessageWith(
1662 static::getTranslator(),
1663 'first_day_of_week'
1664 );
1665 }
1666
1667 /**
1668 * Get the first day of week
1669 *
1670 * @return int
1671 */
1672 public static function getWeekStartsAt()
1673 {
1674 if (static::$weekStartsAt === static::WEEK_DAY_AUTO) {
1675 return static::getFirstDayOfWeek();
1676 }
1677
1678 return static::$weekStartsAt;
1679 }
1680
1681 /**
1682 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
1683 * Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the
1684 * 'first_day_of_week' locale setting to change the start of week according to current locale
1685 * selected and implicitly the end of week.
1686 *
1687 * Set the first day of week
1688 *
1689 * @param int|string $day week start day (or 'auto' to get the first day of week from Carbon::getLocale() culture).
1690 *
1691 * @return void
1692 */
1693 public static function setWeekStartsAt($day)
1694 {
1695 static::$weekStartsAt = $day === static::WEEK_DAY_AUTO ? $day : max(0, (7 + $day) % 7);
1696 }
1697
1698 /**
1699 * Get the last day of week
1700 *
1701 * @return int
1702 */
1703 public static function getWeekEndsAt()
1704 {
1705 if (static::$weekStartsAt === static::WEEK_DAY_AUTO) {
1706 return (int) (static::DAYS_PER_WEEK - 1 + static::getFirstDayOfWeek()) % static::DAYS_PER_WEEK;
1707 }
1708
1709 return static::$weekEndsAt;
1710 }
1711
1712 /**
1713 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
1714 * Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek
1715 * or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the
1716 * start of week according to current locale selected and implicitly the end of week.
1717 *
1718 * Set the last day of week
1719 *
1720 * @param int|string $day week end day (or 'auto' to get the day before the first day of week
1721 * from Carbon::getLocale() culture).
1722 *
1723 * @return void
1724 */
1725 public static function setWeekEndsAt($day)
1726 {
1727 static::$weekEndsAt = $day === static::WEEK_DAY_AUTO ? $day : max(0, (7 + $day) % 7);
1728 }
1729
1730 /**
1731 * Get weekend days
1732 *
1733 * @return array
1734 */
1735 public static function getWeekendDays()
1736 {
1737 return static::$weekendDays;
1738 }
1739
1740 /**
1741 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
1742 * You should rather consider week-end is always saturday and sunday, and if you have some custom
1743 * week-end days to handle, give to those days an other name and create a macro for them:
1744 *
1745 * ```
1746 * Carbon::macro('isDayOff', function ($date) {
1747 * return $date->isSunday() || $date->isMonday();
1748 * });
1749 * Carbon::macro('isNotDayOff', function ($date) {
1750 * return !$date->isDayOff();
1751 * });
1752 * if ($someDate->isDayOff()) ...
1753 * if ($someDate->isNotDayOff()) ...
1754 * // Add 5 not-off days
1755 * $count = 5;
1756 * while ($someDate->isDayOff() || ($count-- > 0)) {
1757 * $someDate->addDay();
1758 * }
1759 * ```
1760 *
1761 * Set weekend days
1762 *
1763 * @param array $days
1764 *
1765 * @return void
1766 */
1767 public static function setWeekendDays($days)
1768 {
1769 static::$weekendDays = $days;
1770 }
1771
1772 /**
1773 * Determine if a time string will produce a relative date.
1774 *
1775 * @param string $time
1776 *
1777 * @return bool true if time match a relative date, false if absolute or invalid time string
1778 */
1779 public static function hasRelativeKeywords($time)
1780 {
1781 if (!$time || strtotime($time) === false) {
1782 return false;
1783 }
1784
1785 $date1 = new DateTime('2000-01-01T00:00:00Z');
1786 $date1->modify($time);
1787 $date2 = new DateTime('2001-12-25T00:00:00Z');
1788 $date2->modify($time);
1789
1790 return $date1 != $date2;
1791 }
1792
1793 ///////////////////////////////////////////////////////////////////
1794 /////////////////////// STRING FORMATTING /////////////////////////
1795 ///////////////////////////////////////////////////////////////////
1796
1797 /**
1798 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
1799 * You should rather use UTF-8 language packages on every machine.
1800 *
1801 * Set if UTF8 will be used for localized date/time.
1802 *
1803 * @param bool $utf8
1804 */
1805 public static function setUtf8($utf8)
1806 {
1807 static::$utf8 = $utf8;
1808 }
1809
1810 /**
1811 * Format the instance with the current locale. You can set the current
1812 * locale using setlocale() https://php.net/setlocale.
1813 *
1814 * @param string $format
1815 *
1816 * @return string
1817 */
1818 public function formatLocalized($format)
1819 {
1820 // Check for Windows to find and replace the %e modifier correctly.
1821 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
1822 $format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format); // @codeCoverageIgnore
1823 }
1824
1825 $formatted = strftime($format, strtotime($this->toDateTimeString()));
1826
1827 return static::$utf8 ? utf8_encode($formatted) : $formatted;
1828 }
1829
1830 /**
1831 * Returns list of locale formats for ISO formatting.
1832 *
1833 * @param string|null $locale current locale used if null
1834 *
1835 * @return array
1836 */
1837 public function getIsoFormats($locale = null)
1838 {
1839 return [
1840 'LT' => $this->getTranslationMessage('formats.LT', $locale, 'h:mm A'),
1841 'LTS' => $this->getTranslationMessage('formats.LTS', $locale, 'h:mm:ss A'),
1842 'L' => $this->getTranslationMessage('formats.L', $locale, 'MM/DD/YYYY'),
1843 'LL' => $this->getTranslationMessage('formats.LL', $locale, 'MMMM D, YYYY'),
1844 'LLL' => $this->getTranslationMessage('formats.LLL', $locale, 'MMMM D, YYYY h:mm A'),
1845 'LLLL' => $this->getTranslationMessage('formats.LLLL', $locale, 'dddd, MMMM D, YYYY h:mm A'),
1846 ];
1847 }
1848
1849 /**
1850 * Returns list of calendar formats for ISO formatting.
1851 *
1852 * @param string|null $locale current locale used if null
1853 *
1854 * @return array
1855 */
1856 public function getCalendarFormats($locale = null)
1857 {
1858 return [
1859 'sameDay' => $this->getTranslationMessage('calendar.sameDay', $locale, '[Today at] LT'),
1860 'nextDay' => $this->getTranslationMessage('calendar.nextDay', $locale, '[Tomorrow at] LT'),
1861 'nextWeek' => $this->getTranslationMessage('calendar.nextWeek', $locale, 'dddd [at] LT'),
1862 'lastDay' => $this->getTranslationMessage('calendar.lastDay', $locale, '[Yesterday at] LT'),
1863 'lastWeek' => $this->getTranslationMessage('calendar.lastWeek', $locale, '[Last] dddd [at] LT'),
1864 'sameElse' => $this->getTranslationMessage('calendar.sameElse', $locale, 'L'),
1865 ];
1866 }
1867
1868 /**
1869 * Returns list of locale units for ISO formatting.
1870 *
1871 * @return array
1872 */
1873 public static function getIsoUnits()
1874 {
1875 static $units = null;
1876
1877 if ($units === null) {
1878 $units = [
1879 'OD' => ['getAltNumber', ['day']],
1880 'OM' => ['getAltNumber', ['month']],
1881 'OY' => ['getAltNumber', ['year']],
1882 'OH' => ['getAltNumber', ['hour']],
1883 'Oh' => ['getAltNumber', ['h']],
1884 'Om' => ['getAltNumber', ['minute']],
1885 'Os' => ['getAltNumber', ['second']],
1886 'D' => 'day',
1887 'DD' => ['rawFormat', ['d']],
1888 'Do' => ['ordinal', ['day', 'D']],
1889 'd' => 'dayOfWeek',
1890 'dd' => function (CarbonInterface $date, $originalFormat = null) {
1891 return $date->getTranslatedMinDayName($originalFormat);
1892 },
1893 'ddd' => function (CarbonInterface $date, $originalFormat = null) {
1894 return $date->getTranslatedShortDayName($originalFormat);
1895 },
1896 'dddd' => function (CarbonInterface $date, $originalFormat = null) {
1897 return $date->getTranslatedDayName($originalFormat);
1898 },
1899 'DDD' => 'dayOfYear',
1900 'DDDD' => ['getPaddedUnit', ['dayOfYear', 3]],
1901 'DDDo' => ['ordinal', ['dayOfYear', 'DDD']],
1902 'e' => ['weekday', []],
1903 'E' => 'dayOfWeekIso',
1904 'H' => ['rawFormat', ['G']],
1905 'HH' => ['rawFormat', ['H']],
1906 'h' => ['rawFormat', ['g']],
1907 'hh' => ['rawFormat', ['h']],
1908 'k' => 'noZeroHour',
1909 'kk' => ['getPaddedUnit', ['noZeroHour']],
1910 'hmm' => ['rawFormat', ['gi']],
1911 'hmmss' => ['rawFormat', ['gis']],
1912 'Hmm' => ['rawFormat', ['Gi']],
1913 'Hmmss' => ['rawFormat', ['Gis']],
1914 'm' => 'minute',
1915 'mm' => ['rawFormat', ['i']],
1916 'a' => 'meridiem',
1917 'A' => 'upperMeridiem',
1918 's' => 'second',
1919 'ss' => ['getPaddedUnit', ['second']],
1920 'S' => function (CarbonInterface $date) {
1921 return (string) floor($date->micro / 100000);
1922 },
1923 'SS' => function (CarbonInterface $date) {
1924 return str_pad((string) floor($date->micro / 10000), 2, '0', STR_PAD_LEFT);
1925 },
1926 'SSS' => function (CarbonInterface $date) {
1927 return str_pad((string) floor($date->micro / 1000), 3, '0', STR_PAD_LEFT);
1928 },
1929 'SSSS' => function (CarbonInterface $date) {
1930 return str_pad((string) floor($date->micro / 100), 4, '0', STR_PAD_LEFT);
1931 },
1932 'SSSSS' => function (CarbonInterface $date) {
1933 return str_pad((string) floor($date->micro / 10), 5, '0', STR_PAD_LEFT);
1934 },
1935 'SSSSSS' => ['getPaddedUnit', ['micro', 6]],
1936 'SSSSSSS' => function (CarbonInterface $date) {
1937 return str_pad((string) floor($date->micro * 10), 7, '0', STR_PAD_LEFT);
1938 },
1939 'SSSSSSSS' => function (CarbonInterface $date) {
1940 return str_pad((string) floor($date->micro * 100), 8, '0', STR_PAD_LEFT);
1941 },
1942 'SSSSSSSSS' => function (CarbonInterface $date) {
1943 return str_pad((string) floor($date->micro * 1000), 9, '0', STR_PAD_LEFT);
1944 },
1945 'M' => 'month',
1946 'MM' => ['rawFormat', ['m']],
1947 'MMM' => function (CarbonInterface $date, $originalFormat = null) {
1948 $month = $date->getTranslatedShortMonthName($originalFormat);
1949 $suffix = $date->getTranslationMessage('mmm_suffix');
1950 if ($suffix && $month !== $date->monthName) {
1951 $month .= $suffix;
1952 }
1953
1954 return $month;
1955 },
1956 'MMMM' => function (CarbonInterface $date, $originalFormat = null) {
1957 return $date->getTranslatedMonthName($originalFormat);
1958 },
1959 'Mo' => ['ordinal', ['month', 'M']],
1960 'Q' => 'quarter',
1961 'Qo' => ['ordinal', ['quarter', 'M']],
1962 'G' => 'isoWeekYear',
1963 'GG' => ['getPaddedUnit', ['isoWeekYear']],
1964 'GGG' => ['getPaddedUnit', ['isoWeekYear', 3]],
1965 'GGGG' => ['getPaddedUnit', ['isoWeekYear', 4]],
1966 'GGGGG' => ['getPaddedUnit', ['isoWeekYear', 5]],
1967 'g' => 'weekYear',
1968 'gg' => ['getPaddedUnit', ['weekYear']],
1969 'ggg' => ['getPaddedUnit', ['weekYear', 3]],
1970 'gggg' => ['getPaddedUnit', ['weekYear', 4]],
1971 'ggggg' => ['getPaddedUnit', ['weekYear', 5]],
1972 'W' => 'isoWeek',
1973 'WW' => ['getPaddedUnit', ['isoWeek']],
1974 'Wo' => ['ordinal', ['isoWeek', 'W']],
1975 'w' => 'week',
1976 'ww' => ['getPaddedUnit', ['week']],
1977 'wo' => ['ordinal', ['week', 'w']],
1978 'x' => ['valueOf', []],
1979 'X' => 'timestamp',
1980 'Y' => 'year',
1981 'YY' => ['rawFormat', ['y']],
1982 'YYYY' => ['getPaddedUnit', ['year', 4]],
1983 'YYYYY' => ['getPaddedUnit', ['year', 5]],
1984 'YYYYYY' => function (CarbonInterface $date) {
1985 return ($date->year < 0 ? '' : '+').$date->getPaddedUnit('year', 6);
1986 },
1987 'z' => ['rawFormat', ['T']],
1988 'zz' => 'tzName',
1989 'Z' => ['getOffsetString', []],
1990 'ZZ' => ['getOffsetString', ['']],
1991 ];
1992 }
1993
1994 return $units;
1995 }
1996
1997 /**
1998 * Returns a unit of the instance padded with 0 by default or any other string if specified.
1999 *
2000 * @param string $unit Carbon unit name
2001 * @param int $length Length of the output (2 by default)
2002 * @param string $padString String to use for padding ("0" by default)
2003 * @param int $padType Side(s) to pad (STR_PAD_LEFT by default)
2004 *
2005 * @return string
2006 */
2007 public function getPaddedUnit($unit, $length = 2, $padString = '0', $padType = STR_PAD_LEFT)
2008 {
2009 return ($this->$unit < 0 ? '-' : '').str_pad((string) abs($this->$unit), $length, $padString, $padType);
2010 }
2011
2012 /**
2013 * Return a property with its ordinal.
2014 *
2015 * @param string $key
2016 * @param string|null $period
2017 *
2018 * @return string
2019 */
2020 public function ordinal(string $key, ?string $period = null): string
2021 {
2022 $number = $this->$key;
2023 $result = $this->translate('ordinal', [
2024 ':number' => $number,
2025 ':period' => (string) $period,
2026 ]);
2027
2028 return (string) ($result === 'ordinal' ? $number : $result);
2029 }
2030
2031 /**
2032 * Return the meridiem of the current time in the current locale.
2033 *
2034 * @param bool $isLower if true, returns lowercase variant if available in the current locale.
2035 *
2036 * @return string
2037 */
2038 public function meridiem(bool $isLower = false): string
2039 {
2040 $hour = $this->hour;
2041 $index = $hour < 12 ? 0 : 1;
2042
2043 if ($isLower) {
2044 $key = 'meridiem.'.($index + 2);
2045 $result = $this->translate($key);
2046
2047 if ($result !== $key) {
2048 return $result;
2049 }
2050 }
2051
2052 $key = "meridiem.$index";
2053 $result = $this->translate($key);
2054 if ($result === $key) {
2055 $result = $this->translate('meridiem', [
2056 ':hour' => $this->hour,
2057 ':minute' => $this->minute,
2058 ':isLower' => $isLower,
2059 ]);
2060
2061 if ($result === 'meridiem') {
2062 return $isLower ? $this->latinMeridiem : $this->latinUpperMeridiem;
2063 }
2064 } elseif ($isLower) {
2065 $result = mb_strtolower($result);
2066 }
2067
2068 return $result;
2069 }
2070
2071 /**
2072 * Returns the alternative number for a given date property if available in the current locale.
2073 *
2074 * @param string $key date property
2075 *
2076 * @return string
2077 */
2078 public function getAltNumber(string $key): string
2079 {
2080 return $this->translateNumber(\strlen($key) > 1 ? $this->$key : $this->rawFormat('h'));
2081 }
2082
2083 /**
2084 * Format in the current language using ISO replacement patterns.
2085 *
2086 * @param string $format
2087 * @param string|null $originalFormat provide context if a chunk has been passed alone
2088 *
2089 * @return string
2090 */
2091 public function isoFormat(string $format, ?string $originalFormat = null): string
2092 {
2093 $result = '';
2094 $length = mb_strlen($format);
2095 $originalFormat = $originalFormat ?: $format;
2096 $inEscaped = false;
2097 $formats = null;
2098 $units = null;
2099
2100 for ($i = 0; $i < $length; $i++) {
2101 $char = mb_substr($format, $i, 1);
2102
2103 if ($char === '\\') {
2104 $result .= mb_substr($format, ++$i, 1);
2105
2106 continue;
2107 }
2108
2109 if ($char === '[' && !$inEscaped) {
2110 $inEscaped = true;
2111
2112 continue;
2113 }
2114
2115 if ($char === ']' && $inEscaped) {
2116 $inEscaped = false;
2117
2118 continue;
2119 }
2120
2121 if ($inEscaped) {
2122 $result .= $char;
2123
2124 continue;
2125 }
2126
2127 $input = mb_substr($format, $i);
2128
2129 if (preg_match('/^(LTS|LT|[Ll]{1,4})/', $input, $match)) {
2130 if ($formats === null) {
2131 $formats = $this->getIsoFormats();
2132 }
2133
2134 $code = $match[0];
2135 $sequence = $formats[$code] ?? preg_replace_callback(
2136 '/MMMM|MM|DD|dddd/',
2137 function ($code) {
2138 return mb_substr($code[0], 1);
2139 },
2140 $formats[strtoupper($code)] ?? ''
2141 );
2142 $rest = mb_substr($format, $i + mb_strlen($code));
2143 $format = mb_substr($format, 0, $i).$sequence.$rest;
2144 $length = mb_strlen($format);
2145 $input = $sequence.$rest;
2146 }
2147
2148 if (preg_match('/^'.CarbonInterface::ISO_FORMAT_REGEXP.'/', $input, $match)) {
2149 $code = $match[0];
2150
2151 if ($units === null) {
2152 $units = static::getIsoUnits();
2153 }
2154
2155 $sequence = $units[$code] ?? '';
2156
2157 if ($sequence instanceof Closure) {
2158 $sequence = $sequence($this, $originalFormat);
2159 } elseif (\is_array($sequence)) {
2160 try {
2161 $sequence = $this->{$sequence[0]}(...$sequence[1]);
2162 } catch (ReflectionException | InvalidArgumentException | BadMethodCallException $e) {
2163 $sequence = '';
2164 }
2165 } elseif (\is_string($sequence)) {
2166 $sequence = $this->$sequence ?? $code;
2167 }
2168
2169 $format = mb_substr($format, 0, $i).$sequence.mb_substr($format, $i + mb_strlen($code));
2170 $i += mb_strlen((string) $sequence) - 1;
2171 $length = mb_strlen($format);
2172 $char = $sequence;
2173 }
2174
2175 $result .= $char;
2176 }
2177
2178 return $result;
2179 }
2180
2181 /**
2182 * List of replacements from date() format to isoFormat().
2183 *
2184 * @return array
2185 */
2186 public static function getFormatsToIsoReplacements()
2187 {
2188 static $replacements = null;
2189
2190 if ($replacements === null) {
2191 $replacements = [
2192 'd' => true,
2193 'D' => 'ddd',
2194 'j' => true,
2195 'l' => 'dddd',
2196 'N' => true,
2197 'S' => function ($date) {
2198 $day = $date->rawFormat('j');
2199
2200 return str_replace((string) $day, '', $date->isoFormat('Do'));
2201 },
2202 'w' => true,
2203 'z' => true,
2204 'W' => true,
2205 'F' => 'MMMM',
2206 'm' => true,
2207 'M' => 'MMM',
2208 'n' => true,
2209 't' => true,
2210 'L' => true,
2211 'o' => true,
2212 'Y' => true,
2213 'y' => true,
2214 'a' => 'a',
2215 'A' => 'A',
2216 'B' => true,
2217 'g' => true,
2218 'G' => true,
2219 'h' => true,
2220 'H' => true,
2221 'i' => true,
2222 's' => true,
2223 'u' => true,
2224 'v' => true,
2225 'E' => true,
2226 'I' => true,
2227 'O' => true,
2228 'P' => true,
2229 'Z' => true,
2230 'c' => true,
2231 'r' => true,
2232 'U' => true,
2233 ];
2234 }
2235
2236 return $replacements;
2237 }
2238
2239 /**
2240 * Format as ->format() do (using date replacements patterns from https://php.net/manual/en/function.date.php)
2241 * but translate words whenever possible (months, day names, etc.) using the current locale.
2242 *
2243 * @param string $format
2244 *
2245 * @return string
2246 */
2247 public function translatedFormat(string $format): string
2248 {
2249 $replacements = static::getFormatsToIsoReplacements();
2250 $context = '';
2251 $isoFormat = '';
2252 $length = mb_strlen($format);
2253
2254 for ($i = 0; $i < $length; $i++) {
2255 $char = mb_substr($format, $i, 1);
2256
2257 if ($char === '\\') {
2258 $replacement = mb_substr($format, $i, 2);
2259 $isoFormat .= $replacement;
2260 $i++;
2261
2262 continue;
2263 }
2264
2265 if (!isset($replacements[$char])) {
2266 $replacement = preg_match('/^[A-Za-z]$/', $char) ? "\\$char" : $char;
2267 $isoFormat .= $replacement;
2268 $context .= $replacement;
2269
2270 continue;
2271 }
2272
2273 $replacement = $replacements[$char];
2274
2275 if ($replacement === true) {
2276 static $contextReplacements = null;
2277
2278 if ($contextReplacements === null) {
2279 $contextReplacements = [
2280 'm' => 'MM',
2281 'd' => 'DD',
2282 't' => 'D',
2283 'j' => 'D',
2284 'N' => 'e',
2285 'w' => 'e',
2286 'n' => 'M',
2287 'o' => 'YYYY',
2288 'Y' => 'YYYY',
2289 'y' => 'YY',
2290 'g' => 'h',
2291 'G' => 'H',
2292 'h' => 'hh',
2293 'H' => 'HH',
2294 'i' => 'mm',
2295 's' => 'ss',
2296 ];
2297 }
2298
2299 $isoFormat .= '['.$this->rawFormat($char).']';
2300 $context .= $contextReplacements[$char] ?? ' ';
2301
2302 continue;
2303 }
2304
2305 if ($replacement instanceof Closure) {
2306 $replacement = '['.$replacement($this).']';
2307 $isoFormat .= $replacement;
2308 $context .= $replacement;
2309
2310 continue;
2311 }
2312
2313 $isoFormat .= $replacement;
2314 $context .= $replacement;
2315 }
2316
2317 return $this->isoFormat($isoFormat, $context);
2318 }
2319
2320 /**
2321 * Returns the offset hour and minute formatted with +/- and a given separator (":" by default).
2322 * For example, if the time zone is 9 hours 30 minutes, you'll get "+09:30", with "@@" as first
2323 * argument, "+09@@30", with "" as first argument, "+0930". Negative offset will return something
2324 * like "-12:00".
2325 *
2326 * @param string $separator string to place between hours and minutes (":" by default)
2327 *
2328 * @return string
2329 */
2330 public function getOffsetString($separator = ':')
2331 {
2332 $second = $this->getOffset();
2333 $symbol = $second < 0 ? '-' : '+';
2334 $minute = abs($second) / static::SECONDS_PER_MINUTE;
2335 $hour = str_pad((string) floor($minute / static::MINUTES_PER_HOUR), 2, '0', STR_PAD_LEFT);
2336 $minute = str_pad((string) ($minute % static::MINUTES_PER_HOUR), 2, '0', STR_PAD_LEFT);
2337
2338 return "$symbol$hour$separator$minute";
2339 }
2340
2341 protected static function executeStaticCallable($macro, ...$parameters)
2342 {
2343 return static::bindMacroContext(null, function () use (&$macro, &$parameters) {
2344 if ($macro instanceof Closure) {
2345 $boundMacro = @Closure::bind($macro, null, static::class);
2346
2347 return ($boundMacro ?: $macro)(...$parameters);
2348 }
2349
2350 return $macro(...$parameters);
2351 });
2352 }
2353
2354 /**
2355 * Dynamically handle calls to the class.
2356 *
2357 * @param string $method magic method name called
2358 * @param array $parameters parameters list
2359 *
2360 * @throws BadMethodCallException
2361 *
2362 * @return mixed
2363 */
2364 public static function __callStatic($method, $parameters)
2365 {
2366 if (!static::hasMacro($method)) {
2367 foreach (static::getGenericMacros() as $callback) {
2368 try {
2369 return static::executeStaticCallable($callback, $method, ...$parameters);
2370 } catch (BadMethodCallException $exception) {
2371 continue;
2372 }
2373 }
2374 if (static::isStrictModeEnabled()) {
2375 throw new UnknownMethodException(sprintf('%s::%s', static::class, $method));
2376 }
2377
2378 return null;
2379 }
2380
2381 return static::executeStaticCallable(static::$globalMacros[$method], ...$parameters);
2382 }
2383
2384 /**
2385 * Set specified unit to new given value.
2386 *
2387 * @param string $unit year, month, day, hour, minute, second or microsecond
2388 * @param int $value new value for given unit
2389 *
2390 * @return static
2391 */
2392 public function setUnit($unit, $value = null)
2393 {
2394 $unit = static::singularUnit($unit);
2395 $dateUnits = ['year', 'month', 'day'];
2396 if (\in_array($unit, $dateUnits)) {
2397 return $this->setDate(...array_map(function ($name) use ($unit, $value) {
2398 return (int) ($name === $unit ? $value : $this->$name);
2399 }, $dateUnits));
2400 }
2401
2402 $units = ['hour', 'minute', 'second', 'micro'];
2403 if ($unit === 'millisecond' || $unit === 'milli') {
2404 $value *= 1000;
2405 $unit = 'micro';
2406 } elseif ($unit === 'microsecond') {
2407 $unit = 'micro';
2408 }
2409
2410 return $this->setTime(...array_map(function ($name) use ($unit, $value) {
2411 return (int) ($name === $unit ? $value : $this->$name);
2412 }, $units));
2413 }
2414
2415 /**
2416 * Returns standardized singular of a given singular/plural unit name (in English).
2417 *
2418 * @param string $unit
2419 *
2420 * @return string
2421 */
2422 public static function singularUnit(string $unit): string
2423 {
2424 $unit = rtrim(mb_strtolower($unit), 's');
2425
2426 if ($unit === 'centurie') {
2427 return 'century';
2428 }
2429
2430 if ($unit === 'millennia') {
2431 return 'millennium';
2432 }
2433
2434 return $unit;
2435 }
2436
2437 /**
2438 * Returns standardized plural of a given singular/plural unit name (in English).
2439 *
2440 * @param string $unit
2441 *
2442 * @return string
2443 */
2444 public static function pluralUnit(string $unit): string
2445 {
2446 $unit = rtrim(strtolower($unit), 's');
2447
2448 if ($unit === 'century') {
2449 return 'centuries';
2450 }
2451
2452 if ($unit === 'millennium' || $unit === 'millennia') {
2453 return 'millennia';
2454 }
2455
2456 return "${unit}s";
2457 }
2458
2459 protected function executeCallable($macro, ...$parameters)
2460 {
2461 if ($macro instanceof Closure) {
2462 $boundMacro = @$macro->bindTo($this, static::class) ?: @$macro->bindTo(null, static::class);
2463
2464 return ($boundMacro ?: $macro)(...$parameters);
2465 }
2466
2467 return $macro(...$parameters);
2468 }
2469
2470 protected function executeCallableWithContext($macro, ...$parameters)
2471 {
2472 return static::bindMacroContext($this, function () use (&$macro, &$parameters) {
2473 return $this->executeCallable($macro, ...$parameters);
2474 });
2475 }
2476
2477 protected static function getGenericMacros()
2478 {
2479 foreach (static::$globalGenericMacros as $list) {
2480 foreach ($list as $macro) {
2481 yield $macro;
2482 }
2483 }
2484 }
2485
2486 /**
2487 * Dynamically handle calls to the class.
2488 *
2489 * @param string $method magic method name called
2490 * @param array $parameters parameters list
2491 *
2492 * @throws UnknownMethodException|BadMethodCallException|ReflectionException|Throwable
2493 *
2494 * @return mixed
2495 */
2496 public function __call($method, $parameters)
2497 {
2498 $diffSizes = [
2499 // @mode diffForHumans
2500 'short' => true,
2501 // @mode diffForHumans
2502 'long' => false,
2503 ];
2504 $diffSyntaxModes = [
2505 // @call diffForHumans
2506 'Absolute' => CarbonInterface::DIFF_ABSOLUTE,
2507 // @call diffForHumans
2508 'Relative' => CarbonInterface::DIFF_RELATIVE_AUTO,
2509 // @call diffForHumans
2510 'RelativeToNow' => CarbonInterface::DIFF_RELATIVE_TO_NOW,
2511 // @call diffForHumans
2512 'RelativeToOther' => CarbonInterface::DIFF_RELATIVE_TO_OTHER,
2513 ];
2514 $sizePattern = implode('|', array_keys($diffSizes));
2515 $syntaxPattern = implode('|', array_keys($diffSyntaxModes));
2516
2517 if (preg_match("/^(?<size>$sizePattern)(?<syntax>$syntaxPattern)DiffForHumans$/", $method, $match)) {
2518 $dates = array_filter($parameters, function ($parameter) {
2519 return $parameter instanceof DateTimeInterface;
2520 });
2521 $other = null;
2522
2523 if (\count($dates)) {
2524 $key = key($dates);
2525 $other = current($dates);
2526 array_splice($parameters, $key, 1);
2527 }
2528
2529 return $this->diffForHumans($other, $diffSyntaxModes[$match['syntax']], $diffSizes[$match['size']], ...$parameters);
2530 }
2531
2532 $roundedValue = $this->callRoundMethod($method, $parameters);
2533
2534 if ($roundedValue !== null) {
2535 return $roundedValue;
2536 }
2537
2538 $unit = rtrim($method, 's');
2539
2540 if (str_starts_with($unit, 'is')) {
2541 $word = substr($unit, 2);
2542
2543 if (\in_array($word, static::$days)) {
2544 return $this->isDayOfWeek($word);
2545 }
2546
2547 switch ($word) {
2548 // @call is Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.)
2549 case 'Utc':
2550 case 'UTC':
2551 return $this->utc;
2552 // @call is Check if the current instance has non-UTC timezone.
2553 case 'Local':
2554 return $this->local;
2555 // @call is Check if the current instance is a valid date.
2556 case 'Valid':
2557 return $this->year !== 0;
2558 // @call is Check if the current instance is in a daylight saving time.
2559 case 'DST':
2560 return $this->dst;
2561 }
2562 }
2563
2564 $action = substr($unit, 0, 3);
2565 $overflow = null;
2566
2567 if ($action === 'set') {
2568 $unit = strtolower(substr($unit, 3));
2569 }
2570
2571 if (\in_array($unit, static::$units)) {
2572 return $this->setUnit($unit, ...$parameters);
2573 }
2574
2575 if ($action === 'add' || $action === 'sub') {
2576 $unit = substr($unit, 3);
2577
2578 if (str_starts_with($unit, 'Real')) {
2579 $unit = static::singularUnit(substr($unit, 4));
2580
2581 return $this->{"${action}RealUnit"}($unit, ...$parameters);
2582 }
2583
2584 if (preg_match('/^(Month|Quarter|Year|Decade|Century|Centurie|Millennium|Millennia)s?(No|With|Without|WithNo)Overflow$/', $unit, $match)) {
2585 $unit = $match[1];
2586 $overflow = $match[2] === 'With';
2587 }
2588
2589 $unit = static::singularUnit($unit);
2590 }
2591
2592 if (static::isModifiableUnit($unit)) {
2593 return $this->{"${action}Unit"}($unit, $parameters[0] ?? 1, $overflow);
2594 }
2595
2596 $sixFirstLetters = substr($unit, 0, 6);
2597 $factor = -1;
2598
2599 if ($sixFirstLetters === 'isLast') {
2600 $sixFirstLetters = 'isNext';
2601 $factor = 1;
2602 }
2603
2604 if ($sixFirstLetters === 'isNext') {
2605 $lowerUnit = strtolower(substr($unit, 6));
2606
2607 if (static::isModifiableUnit($lowerUnit)) {
2608 return $this->copy()->addUnit($lowerUnit, $factor, false)->isSameUnit($lowerUnit, ...$parameters);
2609 }
2610 }
2611
2612 if ($sixFirstLetters === 'isSame') {
2613 try {
2614 return $this->isSameUnit(strtolower(substr($unit, 6)), ...$parameters);
2615 } catch (BadComparisonUnitException $exception) {
2616 // Try next
2617 }
2618 }
2619
2620 if (str_starts_with($unit, 'isCurrent')) {
2621 try {
2622 return $this->isCurrentUnit(strtolower(substr($unit, 9)));
2623 } catch (BadComparisonUnitException | BadMethodCallException $exception) {
2624 // Try next
2625 }
2626 }
2627
2628 if (str_ends_with($method, 'Until')) {
2629 try {
2630 $unit = static::singularUnit(substr($method, 0, -5));
2631
2632 return $this->range($parameters[0] ?? $this, $parameters[1] ?? 1, $unit);
2633 } catch (InvalidArgumentException $exception) {
2634 // Try macros
2635 }
2636 }
2637
2638 return static::bindMacroContext($this, function () use (&$method, &$parameters) {
2639 $macro = $this->getLocalMacro($method);
2640
2641 if (!$macro) {
2642 foreach ([$this->localGenericMacros ?: [], static::getGenericMacros()] as $list) {
2643 foreach ($list as $callback) {
2644 try {
2645 return $this->executeCallable($callback, $method, ...$parameters);
2646 } catch (BadMethodCallException $exception) {
2647 continue;
2648 }
2649 }
2650 }
2651
2652 if ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) {
2653 throw new UnknownMethodException($method);
2654 }
2655
2656 return null;
2657 }
2658
2659 return $this->executeCallable($macro, ...$parameters);
2660 });
2661 }
2662}