vendor/nesbot/carbon/src/Carbon/Traits/Date.php line 1853

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