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

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 MagicParameter;
  532.     use Modifiers;
  533.     use Mutability;
  534.     use ObjectInitialisation;
  535.     use Options;
  536.     use Rounding;
  537.     use Serialization;
  538.     use Test;
  539.     use Timestamp;
  540.     use Units;
  541.     use Week;
  542.     /**
  543.      * Names of days of the week.
  544.      *
  545.      * @var array
  546.      */
  547.     protected static $days = [
  548.         // @call isDayOfWeek
  549.         CarbonInterface::SUNDAY => 'Sunday',
  550.         // @call isDayOfWeek
  551.         CarbonInterface::MONDAY => 'Monday',
  552.         // @call isDayOfWeek
  553.         CarbonInterface::TUESDAY => 'Tuesday',
  554.         // @call isDayOfWeek
  555.         CarbonInterface::WEDNESDAY => 'Wednesday',
  556.         // @call isDayOfWeek
  557.         CarbonInterface::THURSDAY => 'Thursday',
  558.         // @call isDayOfWeek
  559.         CarbonInterface::FRIDAY => 'Friday',
  560.         // @call isDayOfWeek
  561.         CarbonInterface::SATURDAY => 'Saturday',
  562.     ];
  563.     /**
  564.      * Will UTF8 encoding be used to print localized date/time ?
  565.      *
  566.      * @var bool
  567.      */
  568.     protected static $utf8 false;
  569.     /**
  570.      * List of unit and magic methods associated as doc-comments.
  571.      *
  572.      * @var array
  573.      */
  574.     protected static $units = [
  575.         // @call setUnit
  576.         // @call addUnit
  577.         'year',
  578.         // @call setUnit
  579.         // @call addUnit
  580.         'month',
  581.         // @call setUnit
  582.         // @call addUnit
  583.         'day',
  584.         // @call setUnit
  585.         // @call addUnit
  586.         'hour',
  587.         // @call setUnit
  588.         // @call addUnit
  589.         'minute',
  590.         // @call setUnit
  591.         // @call addUnit
  592.         'second',
  593.         // @call setUnit
  594.         // @call addUnit
  595.         'milli',
  596.         // @call setUnit
  597.         // @call addUnit
  598.         'millisecond',
  599.         // @call setUnit
  600.         // @call addUnit
  601.         'micro',
  602.         // @call setUnit
  603.         // @call addUnit
  604.         'microsecond',
  605.     ];
  606.     /**
  607.      * Creates a DateTimeZone from a string, DateTimeZone or integer offset.
  608.      *
  609.      * @param DateTimeZone|string|int|null $object     original value to get CarbonTimeZone from it.
  610.      * @param DateTimeZone|string|int|null $objectDump dump of the object for error messages.
  611.      *
  612.      * @throws InvalidTimeZoneException
  613.      *
  614.      * @return CarbonTimeZone|false
  615.      */
  616.     protected static function safeCreateDateTimeZone($object$objectDump null)
  617.     {
  618.         return CarbonTimeZone::instance($object$objectDump);
  619.     }
  620.     /**
  621.      * Get the TimeZone associated with the Carbon instance (as CarbonTimeZone).
  622.      *
  623.      * @return CarbonTimeZone
  624.      *
  625.      * @link https://php.net/manual/en/datetime.gettimezone.php
  626.      */
  627.     #[ReturnTypeWillChange]
  628.     public function getTimezone()
  629.     {
  630.         return CarbonTimeZone::instance(parent::getTimezone());
  631.     }
  632.     /**
  633.      * List of minimum and maximums for each unit.
  634.      *
  635.      * @param int $daysInMonth
  636.      *
  637.      * @return array
  638.      */
  639.     protected static function getRangesByUnit(int $daysInMonth 31): array
  640.     {
  641.         return [
  642.             // @call roundUnit
  643.             'year' => [19999],
  644.             // @call roundUnit
  645.             'month' => [1, static::MONTHS_PER_YEAR],
  646.             // @call roundUnit
  647.             'day' => [1$daysInMonth],
  648.             // @call roundUnit
  649.             'hour' => [0, static::HOURS_PER_DAY 1],
  650.             // @call roundUnit
  651.             'minute' => [0, static::MINUTES_PER_HOUR 1],
  652.             // @call roundUnit
  653.             'second' => [0, static::SECONDS_PER_MINUTE 1],
  654.         ];
  655.     }
  656.     /**
  657.      * Get a copy of the instance.
  658.      *
  659.      * @return static
  660.      */
  661.     public function copy()
  662.     {
  663.         return clone $this;
  664.     }
  665.     /**
  666.      * @alias copy
  667.      *
  668.      * Get a copy of the instance.
  669.      *
  670.      * @return static
  671.      */
  672.     public function clone()
  673.     {
  674.         return clone $this;
  675.     }
  676.     /**
  677.      * Clone the current instance if it's mutable.
  678.      *
  679.      * This method is convenient to ensure you don't mutate the initial object
  680.      * but avoid to make a useless copy of it if it's already immutable.
  681.      *
  682.      * @return static
  683.      */
  684.     public function avoidMutation(): self
  685.     {
  686.         if ($this instanceof DateTimeImmutable) {
  687.             return $this;
  688.         }
  689.         return clone $this;
  690.     }
  691.     /**
  692.      * Returns a present instance in the same timezone.
  693.      *
  694.      * @return static
  695.      */
  696.     public function nowWithSameTz()
  697.     {
  698.         return static::now($this->getTimezone());
  699.     }
  700.     /**
  701.      * Throws an exception if the given object is not a DateTime and does not implement DateTimeInterface.
  702.      *
  703.      * @param mixed        $date
  704.      * @param string|array $other
  705.      *
  706.      * @throws InvalidTypeException
  707.      */
  708.     protected static function expectDateTime($date$other = [])
  709.     {
  710.         $message 'Expected ';
  711.         foreach ((array) $other as $expect) {
  712.             $message .= "$expect, ";
  713.         }
  714.         if (!$date instanceof DateTime && !$date instanceof DateTimeInterface) {
  715.             throw new InvalidTypeException(
  716.                 $message.'DateTime or DateTimeInterface, '.
  717.                 (\is_object($date) ? \get_class($date) : \gettype($date)).' given'
  718.             );
  719.         }
  720.     }
  721.     /**
  722.      * Return the Carbon instance passed through, a now instance in the same timezone
  723.      * if null given or parse the input if string given.
  724.      *
  725.      * @param Carbon|DateTimeInterface|string|null $date
  726.      *
  727.      * @return static
  728.      */
  729.     protected function resolveCarbon($date null)
  730.     {
  731.         if (!$date) {
  732.             return $this->nowWithSameTz();
  733.         }
  734.         if (\is_string($date)) {
  735.             return static::parse($date$this->getTimezone());
  736.         }
  737.         static::expectDateTime($date, ['null''string']);
  738.         return $date instanceof self $date : static::instance($date);
  739.     }
  740.     /**
  741.      * Return the Carbon instance passed through, a now instance in UTC
  742.      * if null given or parse the input if string given (using current timezone
  743.      * then switching to UTC).
  744.      *
  745.      * @param Carbon|DateTimeInterface|string|null $date
  746.      *
  747.      * @return static
  748.      */
  749.     protected function resolveUTC($date null): self
  750.     {
  751.         if (!$date) {
  752.             return static::now('UTC');
  753.         }
  754.         if (\is_string($date)) {
  755.             return static::parse($date$this->getTimezone())->utc();
  756.         }
  757.         static::expectDateTime($date, ['null''string']);
  758.         return $date instanceof self $date : static::instance($date)->utc();
  759.     }
  760.     /**
  761.      * Return the Carbon instance passed through, a now instance in the same timezone
  762.      * if null given or parse the input if string given.
  763.      *
  764.      * @param Carbon|\Carbon\CarbonPeriod|\Carbon\CarbonInterval|\DateInterval|\DatePeriod|DateTimeInterface|string|null $date
  765.      *
  766.      * @return static
  767.      */
  768.     public function carbonize($date null)
  769.     {
  770.         if ($date instanceof DateInterval) {
  771.             return $this->avoidMutation()->add($date);
  772.         }
  773.         if ($date instanceof DatePeriod || $date instanceof CarbonPeriod) {
  774.             $date $date->getStartDate();
  775.         }
  776.         return $this->resolveCarbon($date);
  777.     }
  778.     ///////////////////////////////////////////////////////////////////
  779.     ///////////////////////// GETTERS AND SETTERS /////////////////////
  780.     ///////////////////////////////////////////////////////////////////
  781.     /**
  782.      * Get a part of the Carbon object
  783.      *
  784.      * @param string $name
  785.      *
  786.      * @throws UnknownGetterException
  787.      *
  788.      * @return string|int|bool|DateTimeZone|null
  789.      */
  790.     public function __get($name)
  791.     {
  792.         return $this->get($name);
  793.     }
  794.     /**
  795.      * Get a part of the Carbon object
  796.      *
  797.      * @param string $name
  798.      *
  799.      * @throws UnknownGetterException
  800.      *
  801.      * @return string|int|bool|DateTimeZone|null
  802.      */
  803.     public function get($name)
  804.     {
  805.         static $formats = [
  806.             // @property int
  807.             'year' => 'Y',
  808.             // @property int
  809.             'yearIso' => 'o',
  810.             // @property int
  811.             // @call isSameUnit
  812.             'month' => 'n',
  813.             // @property int
  814.             'day' => 'j',
  815.             // @property int
  816.             'hour' => 'G',
  817.             // @property int
  818.             'minute' => 'i',
  819.             // @property int
  820.             'second' => 's',
  821.             // @property int
  822.             'micro' => 'u',
  823.             // @property int
  824.             'microsecond' => 'u',
  825.             // @property-read int 0 (for Sunday) through 6 (for Saturday)
  826.             'dayOfWeek' => 'w',
  827.             // @property-read int 1 (for Monday) through 7 (for Sunday)
  828.             'dayOfWeekIso' => 'N',
  829.             // @property-read int ISO-8601 week number of year, weeks starting on Monday
  830.             'weekOfYear' => 'W',
  831.             // @property-read int number of days in the given month
  832.             'daysInMonth' => 't',
  833.             // @property int|float|string seconds since the Unix Epoch
  834.             'timestamp' => 'U',
  835.             // @property-read string "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark)
  836.             'latinMeridiem' => 'a',
  837.             // @property-read string "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark)
  838.             'latinUpperMeridiem' => 'A',
  839.             // @property string the day of week in English
  840.             'englishDayOfWeek' => 'l',
  841.             // @property string the abbreviated day of week in English
  842.             'shortEnglishDayOfWeek' => 'D',
  843.             // @property string the month in English
  844.             'englishMonth' => 'F',
  845.             // @property string the abbreviated month in English
  846.             'shortEnglishMonth' => 'M',
  847.             // @property string the day of week in current locale LC_TIME
  848.             // @deprecated
  849.             //   reason: It uses OS language package and strftime() which is deprecated since PHP 8.1.
  850.             //   replacement: Use ->isoFormat('MMM') instead.
  851.             //   since: 2.55.0
  852.             'localeDayOfWeek' => '%A',
  853.             // @property string the abbreviated day of week in current locale LC_TIME
  854.             // @deprecated
  855.             //   reason: It uses OS language package and strftime() which is deprecated since PHP 8.1.
  856.             //   replacement: Use ->isoFormat('dddd') instead.
  857.             //   since: 2.55.0
  858.             'shortLocaleDayOfWeek' => '%a',
  859.             // @property string the month in current locale LC_TIME
  860.             // @deprecated
  861.             //   reason: It uses OS language package and strftime() which is deprecated since PHP 8.1.
  862.             //   replacement: Use ->isoFormat('ddd') instead.
  863.             //   since: 2.55.0
  864.             'localeMonth' => '%B',
  865.             // @property string the abbreviated month in current locale LC_TIME
  866.             // @deprecated
  867.             //   reason: It uses OS language package and strftime() which is deprecated since PHP 8.1.
  868.             //   replacement: Use ->isoFormat('MMMM') instead.
  869.             //   since: 2.55.0
  870.             'shortLocaleMonth' => '%b',
  871.             // @property-read string $timezoneAbbreviatedName the current timezone abbreviated name
  872.             'timezoneAbbreviatedName' => 'T',
  873.             // @property-read string $tzAbbrName alias of $timezoneAbbreviatedName
  874.             'tzAbbrName' => 'T',
  875.         ];
  876.         switch (true) {
  877.             case isset($formats[$name]):
  878.                 $format $formats[$name];
  879.                 $method str_starts_with($format'%') ? 'formatLocalized' 'rawFormat';
  880.                 $value $this->$method($format);
  881.                 return is_numeric($value) ? (int) $value $value;
  882.             // @property-read string long name of weekday translated according to Carbon locale, in english if no translation available for current language
  883.             case $name === 'dayName':
  884.                 return $this->getTranslatedDayName();
  885.             // @property-read string short name of weekday translated according to Carbon locale, in english if no translation available for current language
  886.             case $name === 'shortDayName':
  887.                 return $this->getTranslatedShortDayName();
  888.             // @property-read string very short name of weekday translated according to Carbon locale, in english if no translation available for current language
  889.             case $name === 'minDayName':
  890.                 return $this->getTranslatedMinDayName();
  891.             // @property-read string long name of month translated according to Carbon locale, in english if no translation available for current language
  892.             case $name === 'monthName':
  893.                 return $this->getTranslatedMonthName();
  894.             // @property-read string short name of month translated according to Carbon locale, in english if no translation available for current language
  895.             case $name === 'shortMonthName':
  896.                 return $this->getTranslatedShortMonthName();
  897.             // @property-read string lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
  898.             case $name === 'meridiem':
  899.                 return $this->meridiem(true);
  900.             // @property-read string uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
  901.             case $name === 'upperMeridiem':
  902.                 return $this->meridiem();
  903.             // @property-read int current hour from 1 to 24
  904.             case $name === 'noZeroHour':
  905.                 return $this->hour ?: 24;
  906.             // @property int
  907.             case $name === 'milliseconds':
  908.                 // @property int
  909.             case $name === 'millisecond':
  910.             // @property int
  911.             case $name === 'milli':
  912.                 return (int) floor(((int) $this->rawFormat('u')) / 1000);
  913.             // @property int 1 through 53
  914.             case $name === 'week':
  915.                 return (int) $this->week();
  916.             // @property int 1 through 53
  917.             case $name === 'isoWeek':
  918.                 return (int) $this->isoWeek();
  919.             // @property int year according to week format
  920.             case $name === 'weekYear':
  921.                 return (int) $this->weekYear();
  922.             // @property int year according to ISO week format
  923.             case $name === 'isoWeekYear':
  924.                 return (int) $this->isoWeekYear();
  925.             // @property-read int 51 through 53
  926.             case $name === 'weeksInYear':
  927.                 return $this->weeksInYear();
  928.             // @property-read int 51 through 53
  929.             case $name === 'isoWeeksInYear':
  930.                 return $this->isoWeeksInYear();
  931.             // @property-read int 1 through 5
  932.             case $name === 'weekOfMonth':
  933.                 return (int) ceil($this->day / static::DAYS_PER_WEEK);
  934.             // @property-read int 1 through 5
  935.             case $name === 'weekNumberInMonth':
  936.                 return (int) ceil(($this->day $this->avoidMutation()->startOfMonth()->dayOfWeekIso 1) / static::DAYS_PER_WEEK);
  937.             // @property-read int 0 through 6
  938.             case $name === 'firstWeekDay':
  939.                 return $this->localTranslator ? ($this->getTranslationMessage('first_day_of_week') ?? 0) : static::getWeekStartsAt();
  940.             // @property-read int 0 through 6
  941.             case $name === 'lastWeekDay':
  942.                 return $this->localTranslator ? (($this->getTranslationMessage('first_day_of_week') ?? 0) + static::DAYS_PER_WEEK 1) % static::DAYS_PER_WEEK : static::getWeekEndsAt();
  943.             // @property int 1 through 366
  944.             case $name === 'dayOfYear':
  945.                 return + (int) ($this->rawFormat('z'));
  946.             // @property-read int 365 or 366
  947.             case $name === 'daysInYear':
  948.                 return $this->isLeapYear() ? 366 365;
  949.             // @property int does a diffInYears() with default parameters
  950.             case $name === 'age':
  951.                 return $this->diffInYears();
  952.             // @property-read int the quarter of this instance, 1 - 4
  953.             // @call isSameUnit
  954.             case $name === 'quarter':
  955.                 return (int) ceil($this->month / static::MONTHS_PER_QUARTER);
  956.             // @property-read int the decade of this instance
  957.             // @call isSameUnit
  958.             case $name === 'decade':
  959.                 return (int) ceil($this->year / static::YEARS_PER_DECADE);
  960.             // @property-read int the century of this instance
  961.             // @call isSameUnit
  962.             case $name === 'century':
  963.                 $factor 1;
  964.                 $year $this->year;
  965.                 if ($year 0) {
  966.                     $year = -$year;
  967.                     $factor = -1;
  968.                 }
  969.                 return (int) ($factor ceil($year / static::YEARS_PER_CENTURY));
  970.             // @property-read int the millennium of this instance
  971.             // @call isSameUnit
  972.             case $name === 'millennium':
  973.                 $factor 1;
  974.                 $year $this->year;
  975.                 if ($year 0) {
  976.                     $year = -$year;
  977.                     $factor = -1;
  978.                 }
  979.                 return (int) ($factor ceil($year / static::YEARS_PER_MILLENNIUM));
  980.             // @property int the timezone offset in seconds from UTC
  981.             case $name === 'offset':
  982.                 return $this->getOffset();
  983.             // @property int the timezone offset in minutes from UTC
  984.             case $name === 'offsetMinutes':
  985.                 return $this->getOffset() / static::SECONDS_PER_MINUTE;
  986.             // @property int the timezone offset in hours from UTC
  987.             case $name === 'offsetHours':
  988.                 return $this->getOffset() / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR;
  989.             // @property-read bool daylight savings time indicator, true if DST, false otherwise
  990.             case $name === 'dst':
  991.                 return $this->rawFormat('I') === '1';
  992.             // @property-read bool checks if the timezone is local, true if local, false otherwise
  993.             case $name === 'local':
  994.                 return $this->getOffset() === $this->avoidMutation()->setTimezone(date_default_timezone_get())->getOffset();
  995.             // @property-read bool checks if the timezone is UTC, true if UTC, false otherwise
  996.             case $name === 'utc':
  997.                 return $this->getOffset() === 0;
  998.             // @property CarbonTimeZone $timezone the current timezone
  999.             // @property CarbonTimeZone $tz alias of $timezone
  1000.             case $name === 'timezone' || $name === 'tz':
  1001.                 return CarbonTimeZone::instance($this->getTimezone());
  1002.             // @property-read string $timezoneName the current timezone name
  1003.             // @property-read string $tzName alias of $timezoneName
  1004.             case $name === 'timezoneName' || $name === 'tzName':
  1005.                 return $this->getTimezone()->getName();
  1006.             // @property-read string locale of the current instance
  1007.             case $name === 'locale':
  1008.                 return $this->getTranslatorLocale();
  1009.             default:
  1010.                 $macro $this->getLocalMacro('get'.ucfirst($name));
  1011.                 if ($macro) {
  1012.                     return $this->executeCallableWithContext($macro);
  1013.                 }
  1014.                 throw new UnknownGetterException($name);
  1015.         }
  1016.     }
  1017.     /**
  1018.      * Check if an attribute exists on the object
  1019.      *
  1020.      * @param string $name
  1021.      *
  1022.      * @return bool
  1023.      */
  1024.     public function __isset($name)
  1025.     {
  1026.         try {
  1027.             $this->__get($name);
  1028.         } catch (UnknownGetterException ReflectionException $e) {
  1029.             return false;
  1030.         }
  1031.         return true;
  1032.     }
  1033.     /**
  1034.      * Set a part of the Carbon object
  1035.      *
  1036.      * @param string                  $name
  1037.      * @param string|int|DateTimeZone $value
  1038.      *
  1039.      * @throws UnknownSetterException|ReflectionException
  1040.      *
  1041.      * @return void
  1042.      */
  1043.     public function __set($name$value)
  1044.     {
  1045.         if ($this->constructedObjectId === spl_object_hash($this)) {
  1046.             $this->set($name$value);
  1047.             return;
  1048.         }
  1049.         $this->$name $value;
  1050.     }
  1051.     /**
  1052.      * Set a part of the Carbon object
  1053.      *
  1054.      * @param string|array            $name
  1055.      * @param string|int|DateTimeZone $value
  1056.      *
  1057.      * @throws ImmutableException|UnknownSetterException
  1058.      *
  1059.      * @return $this
  1060.      */
  1061.     public function set($name$value null)
  1062.     {
  1063.         if ($this->isImmutable()) {
  1064.             throw new ImmutableException(sprintf('%s class', static::class));
  1065.         }
  1066.         if (\is_array($name)) {
  1067.             foreach ($name as $key => $value) {
  1068.                 $this->set($key$value);
  1069.             }
  1070.             return $this;
  1071.         }
  1072.         switch ($name) {
  1073.             case 'milliseconds':
  1074.             case 'millisecond':
  1075.             case 'milli':
  1076.             case 'microseconds':
  1077.             case 'microsecond':
  1078.             case 'micro':
  1079.                 if (str_starts_with($name'milli')) {
  1080.                     $value *= 1000;
  1081.                 }
  1082.                 while ($value 0) {
  1083.                     $this->subSecond();
  1084.                     $value += static::MICROSECONDS_PER_SECOND;
  1085.                 }
  1086.                 while ($value >= static::MICROSECONDS_PER_SECOND) {
  1087.                     $this->addSecond();
  1088.                     $value -= static::MICROSECONDS_PER_SECOND;
  1089.                 }
  1090.                 $this->modify($this->rawFormat('H:i:s.').str_pad((string) round($value), 6'0'STR_PAD_LEFT));
  1091.                 break;
  1092.             case 'year':
  1093.             case 'month':
  1094.             case 'day':
  1095.             case 'hour':
  1096.             case 'minute':
  1097.             case 'second':
  1098.                 [$year$month$day$hour$minute$second] = array_map('intval'explode('-'$this->rawFormat('Y-n-j-G-i-s')));
  1099.                 $$name $value;
  1100.                 $this->setDateTime($year$month$day$hour$minute$second);
  1101.                 break;
  1102.             case 'week':
  1103.                 $this->week($value);
  1104.                 break;
  1105.             case 'isoWeek':
  1106.                 $this->isoWeek($value);
  1107.                 break;
  1108.             case 'weekYear':
  1109.                 $this->weekYear($value);
  1110.                 break;
  1111.             case 'isoWeekYear':
  1112.                 $this->isoWeekYear($value);
  1113.                 break;
  1114.             case 'dayOfYear':
  1115.                 $this->addDays($value $this->dayOfYear);
  1116.                 break;
  1117.             case 'timestamp':
  1118.                 $this->setTimestamp($value);
  1119.                 break;
  1120.             case 'offset':
  1121.                 $this->setTimezone(static::safeCreateDateTimeZone($value / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR));
  1122.                 break;
  1123.             case 'offsetMinutes':
  1124.                 $this->setTimezone(static::safeCreateDateTimeZone($value / static::MINUTES_PER_HOUR));
  1125.                 break;
  1126.             case 'offsetHours':
  1127.                 $this->setTimezone(static::safeCreateDateTimeZone($value));
  1128.                 break;
  1129.             case 'timezone':
  1130.             case 'tz':
  1131.                 $this->setTimezone($value);
  1132.                 break;
  1133.             default:
  1134.                 $macro $this->getLocalMacro('set'.ucfirst($name));
  1135.                 if ($macro) {
  1136.                     $this->executeCallableWithContext($macro$value);
  1137.                     break;
  1138.                 }
  1139.                 if ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) {
  1140.                     throw new UnknownSetterException($name);
  1141.                 }
  1142.                 $this->$name $value;
  1143.         }
  1144.         return $this;
  1145.     }
  1146.     protected function getTranslatedFormByRegExp($baseKey$keySuffix$context$subKey$defaultValue)
  1147.     {
  1148.         $key $baseKey.$keySuffix;
  1149.         $standaloneKey "{$key}_standalone";
  1150.         $baseTranslation $this->getTranslationMessage($key);
  1151.         if ($baseTranslation instanceof Closure) {
  1152.             return $baseTranslation($this$context$subKey) ?: $defaultValue;
  1153.         }
  1154.         if (
  1155.             $this->getTranslationMessage("$standaloneKey.$subKey") &&
  1156.             (!$context || (($regExp $this->getTranslationMessage("{$baseKey}_regexp")) && !preg_match($regExp$context)))
  1157.         ) {
  1158.             $key $standaloneKey;
  1159.         }
  1160.         return $this->getTranslationMessage("$key.$subKey"null$defaultValue);
  1161.     }
  1162.     /**
  1163.      * Get the translation of the current week day name (with context for languages with multiple forms).
  1164.      *
  1165.      * @param string|null $context      whole format string
  1166.      * @param string      $keySuffix    "", "_short" or "_min"
  1167.      * @param string|null $defaultValue default value if translation missing
  1168.      *
  1169.      * @return string
  1170.      */
  1171.     public function getTranslatedDayName($context null$keySuffix ''$defaultValue null)
  1172.     {
  1173.         return $this->getTranslatedFormByRegExp('weekdays'$keySuffix$context$this->dayOfWeek$defaultValue ?: $this->englishDayOfWeek);
  1174.     }
  1175.     /**
  1176.      * Get the translation of the current short week day name (with context for languages with multiple forms).
  1177.      *
  1178.      * @param string|null $context whole format string
  1179.      *
  1180.      * @return string
  1181.      */
  1182.     public function getTranslatedShortDayName($context null)
  1183.     {
  1184.         return $this->getTranslatedDayName($context'_short'$this->shortEnglishDayOfWeek);
  1185.     }
  1186.     /**
  1187.      * Get the translation of the current abbreviated week day name (with context for languages with multiple forms).
  1188.      *
  1189.      * @param string|null $context whole format string
  1190.      *
  1191.      * @return string
  1192.      */
  1193.     public function getTranslatedMinDayName($context null)
  1194.     {
  1195.         return $this->getTranslatedDayName($context'_min'$this->shortEnglishDayOfWeek);
  1196.     }
  1197.     /**
  1198.      * Get the translation of the current month day name (with context for languages with multiple forms).
  1199.      *
  1200.      * @param string|null $context      whole format string
  1201.      * @param string      $keySuffix    "" or "_short"
  1202.      * @param string|null $defaultValue default value if translation missing
  1203.      *
  1204.      * @return string
  1205.      */
  1206.     public function getTranslatedMonthName($context null$keySuffix ''$defaultValue null)
  1207.     {
  1208.         return $this->getTranslatedFormByRegExp('months'$keySuffix$context$this->month 1$defaultValue ?: $this->englishMonth);
  1209.     }
  1210.     /**
  1211.      * Get the translation of the current short month day name (with context for languages with multiple forms).
  1212.      *
  1213.      * @param string|null $context whole format string
  1214.      *
  1215.      * @return string
  1216.      */
  1217.     public function getTranslatedShortMonthName($context null)
  1218.     {
  1219.         return $this->getTranslatedMonthName($context'_short'$this->shortEnglishMonth);
  1220.     }
  1221.     /**
  1222.      * Get/set the day of year.
  1223.      *
  1224.      * @param int|null $value new value for day of year if using as setter.
  1225.      *
  1226.      * @return static|int
  1227.      */
  1228.     public function dayOfYear($value null)
  1229.     {
  1230.         $dayOfYear $this->dayOfYear;
  1231.         return $value === null $dayOfYear $this->addDays($value $dayOfYear);
  1232.     }
  1233.     /**
  1234.      * Get/set the weekday from 0 (Sunday) to 6 (Saturday).
  1235.      *
  1236.      * @param int|null $value new value for weekday if using as setter.
  1237.      *
  1238.      * @return static|int
  1239.      */
  1240.     public function weekday($value null)
  1241.     {
  1242.         if ($value === null) {
  1243.             return $this->dayOfWeek;
  1244.         }
  1245.         $firstDay = (int) ($this->getTranslationMessage('first_day_of_week') ?? 0);
  1246.         $dayOfWeek = ($this->dayOfWeek $firstDay) % 7;
  1247.         return $this->addDays((($value $firstDay) % 7) - $dayOfWeek);
  1248.     }
  1249.     /**
  1250.      * Get/set the ISO weekday from 1 (Monday) to 7 (Sunday).
  1251.      *
  1252.      * @param int|null $value new value for weekday if using as setter.
  1253.      *
  1254.      * @return static|int
  1255.      */
  1256.     public function isoWeekday($value null)
  1257.     {
  1258.         $dayOfWeekIso $this->dayOfWeekIso;
  1259.         return $value === null $dayOfWeekIso $this->addDays($value $dayOfWeekIso);
  1260.     }
  1261.     /**
  1262.      * Return the number of days since the start of the week (using the current locale or the first parameter
  1263.      * if explicitly given).
  1264.      *
  1265.      * @param int|null $weekStartsAt optional start allow you to specify the day of week to use to start the week,
  1266.      *                               if not provided, start of week is inferred from the locale
  1267.      *                               (Sunday for en_US, Monday for de_DE, etc.)
  1268.      *
  1269.      * @return int
  1270.      */
  1271.     public function getDaysFromStartOfWeek(int $weekStartsAt null): int
  1272.     {
  1273.         $firstDay = (int) ($weekStartsAt ?? $this->getTranslationMessage('first_day_of_week') ?? 0);
  1274.         return ($this->dayOfWeek $firstDay) % 7;
  1275.     }
  1276.     /**
  1277.      * Set the day (keeping the current time) to the start of the week + the number of days passed as the first
  1278.      * parameter. First day of week is driven by the locale unless explicitly set with the second parameter.
  1279.      *
  1280.      * @param int      $numberOfDays number of days to add after the start of the current week
  1281.      * @param int|null $weekStartsAt optional start allow you to specify the day of week to use to start the week,
  1282.      *                               if not provided, start of week is inferred from the locale
  1283.      *                               (Sunday for en_US, Monday for de_DE, etc.)
  1284.      *
  1285.      * @return static
  1286.      */
  1287.     public function setDaysFromStartOfWeek(int $numberOfDaysint $weekStartsAt null)
  1288.     {
  1289.         return $this->addDays($numberOfDays $this->getDaysFromStartOfWeek($weekStartsAt));
  1290.     }
  1291.     /**
  1292.      * Set any unit to a new value without overflowing current other unit given.
  1293.      *
  1294.      * @param string $valueUnit    unit name to modify
  1295.      * @param int    $value        new value for the input unit
  1296.      * @param string $overflowUnit unit name to not overflow
  1297.      *
  1298.      * @return static
  1299.      */
  1300.     public function setUnitNoOverflow($valueUnit$value$overflowUnit)
  1301.     {
  1302.         try {
  1303.             $original $this->avoidMutation();
  1304.             /** @var static $date */
  1305.             $date $this->$valueUnit($value);
  1306.             $end $original->avoidMutation()->endOf($overflowUnit);
  1307.             $start $original->avoidMutation()->startOf($overflowUnit);
  1308.             if ($date $start) {
  1309.                 $date $date->setDateTimeFrom($start);
  1310.             } elseif ($date $end) {
  1311.                 $date $date->setDateTimeFrom($end);
  1312.             }
  1313.             return $date;
  1314.         } catch (BadMethodCallException ReflectionException $exception) {
  1315.             throw new UnknownUnitException($valueUnit0$exception);
  1316.         }
  1317.     }
  1318.     /**
  1319.      * Add any unit to a new value without overflowing current other unit given.
  1320.      *
  1321.      * @param string $valueUnit    unit name to modify
  1322.      * @param int    $value        amount to add to the input unit
  1323.      * @param string $overflowUnit unit name to not overflow
  1324.      *
  1325.      * @return static
  1326.      */
  1327.     public function addUnitNoOverflow($valueUnit$value$overflowUnit)
  1328.     {
  1329.         return $this->setUnitNoOverflow($valueUnit$this->$valueUnit $value$overflowUnit);
  1330.     }
  1331.     /**
  1332.      * Subtract any unit to a new value without overflowing current other unit given.
  1333.      *
  1334.      * @param string $valueUnit    unit name to modify
  1335.      * @param int    $value        amount to subtract to the input unit
  1336.      * @param string $overflowUnit unit name to not overflow
  1337.      *
  1338.      * @return static
  1339.      */
  1340.     public function subUnitNoOverflow($valueUnit$value$overflowUnit)
  1341.     {
  1342.         return $this->setUnitNoOverflow($valueUnit$this->$valueUnit $value$overflowUnit);
  1343.     }
  1344.     /**
  1345.      * Returns the minutes offset to UTC if no arguments passed, else set the timezone with given minutes shift passed.
  1346.      *
  1347.      * @param int|null $minuteOffset
  1348.      *
  1349.      * @return int|static
  1350.      */
  1351.     public function utcOffset(int $minuteOffset null)
  1352.     {
  1353.         if (\func_num_args() < 1) {
  1354.             return $this->offsetMinutes;
  1355.         }
  1356.         return $this->setTimezone(CarbonTimeZone::createFromMinuteOffset($minuteOffset));
  1357.     }
  1358.     /**
  1359.      * Set the date with gregorian year, month and day numbers.
  1360.      *
  1361.      * @see https://php.net/manual/en/datetime.setdate.php
  1362.      *
  1363.      * @param int $year
  1364.      * @param int $month
  1365.      * @param int $day
  1366.      *
  1367.      * @return static
  1368.      */
  1369.     #[ReturnTypeWillChange]
  1370.     public function setDate($year$month$day)
  1371.     {
  1372.         return parent::setDate((int) $year, (int) $month, (int) $day);
  1373.     }
  1374.     /**
  1375.      * Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
  1376.      *
  1377.      * @see https://php.net/manual/en/datetime.setisodate.php
  1378.      *
  1379.      * @param int $year
  1380.      * @param int $week
  1381.      * @param int $day
  1382.      *
  1383.      * @return static
  1384.      */
  1385.     #[ReturnTypeWillChange]
  1386.     public function setISODate($year$week$day 1)
  1387.     {
  1388.         return parent::setISODate((int) $year, (int) $week, (int) $day);
  1389.     }
  1390.     /**
  1391.      * Set the date and time all together.
  1392.      *
  1393.      * @param int $year
  1394.      * @param int $month
  1395.      * @param int $day
  1396.      * @param int $hour
  1397.      * @param int $minute
  1398.      * @param int $second
  1399.      * @param int $microseconds
  1400.      *
  1401.      * @return static
  1402.      */
  1403.     public function setDateTime($year$month$day$hour$minute$second 0$microseconds 0)
  1404.     {
  1405.         return $this->setDate($year$month$day)->setTime((int) $hour, (int) $minute, (int) $second, (int) $microseconds);
  1406.     }
  1407.     /**
  1408.      * Resets the current time of the DateTime object to a different time.
  1409.      *
  1410.      * @see https://php.net/manual/en/datetime.settime.php
  1411.      *
  1412.      * @param int $hour
  1413.      * @param int $minute
  1414.      * @param int $second
  1415.      * @param int $microseconds
  1416.      *
  1417.      * @return static
  1418.      */
  1419.     #[ReturnTypeWillChange]
  1420.     public function setTime($hour$minute$second 0$microseconds 0)
  1421.     {
  1422.         return parent::setTime((int) $hour, (int) $minute, (int) $second, (int) $microseconds);
  1423.     }
  1424.     /**
  1425.      * Set the instance's timestamp.
  1426.      *
  1427.      * Timestamp input can be given as int, float or a string containing one or more numbers.
  1428.      *
  1429.      * @param float|int|string $unixTimestamp
  1430.      *
  1431.      * @return static
  1432.      */
  1433.     #[ReturnTypeWillChange]
  1434.     public function setTimestamp($unixTimestamp)
  1435.     {
  1436.         [$timestamp$microseconds] = self::getIntegerAndDecimalParts($unixTimestamp);
  1437.         return parent::setTimestamp((int) $timestamp)->setMicroseconds((int) $microseconds);
  1438.     }
  1439.     /**
  1440.      * Set the time by time string.
  1441.      *
  1442.      * @param string $time
  1443.      *
  1444.      * @return static
  1445.      */
  1446.     public function setTimeFromTimeString($time)
  1447.     {
  1448.         if (!str_contains($time':')) {
  1449.             $time .= ':0';
  1450.         }
  1451.         return $this->modify($time);
  1452.     }
  1453.     /**
  1454.      * @alias setTimezone
  1455.      *
  1456.      * @param DateTimeZone|string $value
  1457.      *
  1458.      * @return static
  1459.      */
  1460.     public function timezone($value)
  1461.     {
  1462.         return $this->setTimezone($value);
  1463.     }
  1464.     /**
  1465.      * Set the timezone or returns the timezone name if no arguments passed.
  1466.      *
  1467.      * @param DateTimeZone|string $value
  1468.      *
  1469.      * @return static|string
  1470.      */
  1471.     public function tz($value null)
  1472.     {
  1473.         if (\func_num_args() < 1) {
  1474.             return $this->tzName;
  1475.         }
  1476.         return $this->setTimezone($value);
  1477.     }
  1478.     /**
  1479.      * Set the instance's timezone from a string or object.
  1480.      *
  1481.      * @param DateTimeZone|string $value
  1482.      *
  1483.      * @return static
  1484.      */
  1485.     #[ReturnTypeWillChange]
  1486.     public function setTimezone($value)
  1487.     {
  1488.         $tz = static::safeCreateDateTimeZone($value);
  1489.         if ($tz === false && !self::isStrictModeEnabled()) {
  1490.             $tz = new CarbonTimeZone();
  1491.         }
  1492.         return parent::setTimezone($tz);
  1493.     }
  1494.     /**
  1495.      * Set the instance's timezone from a string or object and add/subtract the offset difference.
  1496.      *
  1497.      * @param DateTimeZone|string $value
  1498.      *
  1499.      * @return static
  1500.      */
  1501.     public function shiftTimezone($value)
  1502.     {
  1503.         $dateTimeString $this->format('Y-m-d H:i:s.u');
  1504.         return $this
  1505.             ->setTimezone($value)
  1506.             ->modify($dateTimeString);
  1507.     }
  1508.     /**
  1509.      * Set the instance's timezone to UTC.
  1510.      *
  1511.      * @return static
  1512.      */
  1513.     public function utc()
  1514.     {
  1515.         return $this->setTimezone('UTC');
  1516.     }
  1517.     /**
  1518.      * Set the year, month, and date for this instance to that of the passed instance.
  1519.      *
  1520.      * @param Carbon|DateTimeInterface $date now if null
  1521.      *
  1522.      * @return static
  1523.      */
  1524.     public function setDateFrom($date null)
  1525.     {
  1526.         $date $this->resolveCarbon($date);
  1527.         return $this->setDate($date->year$date->month$date->day);
  1528.     }
  1529.     /**
  1530.      * Set the hour, minute, second and microseconds for this instance to that of the passed instance.
  1531.      *
  1532.      * @param Carbon|DateTimeInterface $date now if null
  1533.      *
  1534.      * @return static
  1535.      */
  1536.     public function setTimeFrom($date null)
  1537.     {
  1538.         $date $this->resolveCarbon($date);
  1539.         return $this->setTime($date->hour$date->minute$date->second$date->microsecond);
  1540.     }
  1541.     /**
  1542.      * Set the date and time for this instance to that of the passed instance.
  1543.      *
  1544.      * @param Carbon|DateTimeInterface $date
  1545.      *
  1546.      * @return static
  1547.      */
  1548.     public function setDateTimeFrom($date null)
  1549.     {
  1550.         $date $this->resolveCarbon($date);
  1551.         return $this->modify($date->rawFormat('Y-m-d H:i:s.u'));
  1552.     }
  1553.     /**
  1554.      * Get the days of the week
  1555.      *
  1556.      * @return array
  1557.      */
  1558.     public static function getDays()
  1559.     {
  1560.         return static::$days;
  1561.     }
  1562.     ///////////////////////////////////////////////////////////////////
  1563.     /////////////////////// WEEK SPECIAL DAYS /////////////////////////
  1564.     ///////////////////////////////////////////////////////////////////
  1565.     private static function getFirstDayOfWeek(): int
  1566.     {
  1567.         return (int) static::getTranslationMessageWith(
  1568.             static::getTranslator(),
  1569.             'first_day_of_week'
  1570.         );
  1571.     }
  1572.     /**
  1573.      * Get the first day of week
  1574.      *
  1575.      * @return int
  1576.      */
  1577.     public static function getWeekStartsAt()
  1578.     {
  1579.         if (static::$weekStartsAt === static::WEEK_DAY_AUTO) {
  1580.             return self::getFirstDayOfWeek();
  1581.         }
  1582.         return static::$weekStartsAt;
  1583.     }
  1584.     /**
  1585.      * @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
  1586.      *             Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the
  1587.      *             'first_day_of_week' locale setting to change the start of week according to current locale
  1588.      *             selected and implicitly the end of week.
  1589.      *
  1590.      * Set the first day of week
  1591.      *
  1592.      * @param int|string $day week start day (or 'auto' to get the first day of week from Carbon::getLocale() culture).
  1593.      *
  1594.      * @return void
  1595.      */
  1596.     public static function setWeekStartsAt($day)
  1597.     {
  1598.         static::$weekStartsAt $day === static::WEEK_DAY_AUTO $day max(0, ($day) % 7);
  1599.     }
  1600.     /**
  1601.      * Get the last day of week
  1602.      *
  1603.      * @return int
  1604.      */
  1605.     public static function getWeekEndsAt()
  1606.     {
  1607.         if (static::$weekStartsAt === static::WEEK_DAY_AUTO) {
  1608.             return (int) (static::DAYS_PER_WEEK self::getFirstDayOfWeek()) % static::DAYS_PER_WEEK;
  1609.         }
  1610.         return static::$weekEndsAt;
  1611.     }
  1612.     /**
  1613.      * @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
  1614.      *             Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek
  1615.      *             or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the
  1616.      *             start of week according to current locale selected and implicitly the end of week.
  1617.      *
  1618.      * Set the last day of week
  1619.      *
  1620.      * @param int|string $day week end day (or 'auto' to get the day before the first day of week
  1621.      *                        from Carbon::getLocale() culture).
  1622.      *
  1623.      * @return void
  1624.      */
  1625.     public static function setWeekEndsAt($day)
  1626.     {
  1627.         static::$weekEndsAt $day === static::WEEK_DAY_AUTO $day max(0, ($day) % 7);
  1628.     }
  1629.     /**
  1630.      * Get weekend days
  1631.      *
  1632.      * @return array
  1633.      */
  1634.     public static function getWeekendDays()
  1635.     {
  1636.         return static::$weekendDays;
  1637.     }
  1638.     /**
  1639.      * @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
  1640.      *             You should rather consider week-end is always saturday and sunday, and if you have some custom
  1641.      *             week-end days to handle, give to those days an other name and create a macro for them:
  1642.      *
  1643.      *             ```
  1644.      *             Carbon::macro('isDayOff', function ($date) {
  1645.      *                 return $date->isSunday() || $date->isMonday();
  1646.      *             });
  1647.      *             Carbon::macro('isNotDayOff', function ($date) {
  1648.      *                 return !$date->isDayOff();
  1649.      *             });
  1650.      *             if ($someDate->isDayOff()) ...
  1651.      *             if ($someDate->isNotDayOff()) ...
  1652.      *             // Add 5 not-off days
  1653.      *             $count = 5;
  1654.      *             while ($someDate->isDayOff() || ($count-- > 0)) {
  1655.      *                 $someDate->addDay();
  1656.      *             }
  1657.      *             ```
  1658.      *
  1659.      * Set weekend days
  1660.      *
  1661.      * @param array $days
  1662.      *
  1663.      * @return void
  1664.      */
  1665.     public static function setWeekendDays($days)
  1666.     {
  1667.         static::$weekendDays $days;
  1668.     }
  1669.     /**
  1670.      * Determine if a time string will produce a relative date.
  1671.      *
  1672.      * @param string $time
  1673.      *
  1674.      * @return bool true if time match a relative date, false if absolute or invalid time string
  1675.      */
  1676.     public static function hasRelativeKeywords($time)
  1677.     {
  1678.         if (!$time || strtotime($time) === false) {
  1679.             return false;
  1680.         }
  1681.         $date1 = new DateTime('2000-01-01T00:00:00Z');
  1682.         $date1->modify($time);
  1683.         $date2 = new DateTime('2001-12-25T00:00:00Z');
  1684.         $date2->modify($time);
  1685.         return $date1 != $date2;
  1686.     }
  1687.     ///////////////////////////////////////////////////////////////////
  1688.     /////////////////////// STRING FORMATTING /////////////////////////
  1689.     ///////////////////////////////////////////////////////////////////
  1690.     /**
  1691.      * @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
  1692.      *             You should rather use UTF-8 language packages on every machine.
  1693.      *
  1694.      * Set if UTF8 will be used for localized date/time.
  1695.      *
  1696.      * @param bool $utf8
  1697.      */
  1698.     public static function setUtf8($utf8)
  1699.     {
  1700.         static::$utf8 $utf8;
  1701.     }
  1702.     /**
  1703.      * Format the instance with the current locale.  You can set the current
  1704.      * locale using setlocale() https://php.net/setlocale.
  1705.      *
  1706.      * @deprecated It uses OS language package and strftime() which is deprecated since PHP 8.1.
  1707.      *             Use ->isoFormat() instead.
  1708.      *             Deprecated since 2.55.0
  1709.      *
  1710.      * @param string $format
  1711.      *
  1712.      * @return string
  1713.      */
  1714.     public function formatLocalized($format)
  1715.     {
  1716.         // Check for Windows to find and replace the %e modifier correctly.
  1717.         if (strtoupper(substr(PHP_OS03)) === 'WIN') {
  1718.             $format preg_replace('#(?<!%)((?:%%)*)%e#''\1%#d'$format); // @codeCoverageIgnore
  1719.         }
  1720.         $time strtotime($this->toDateTimeString());
  1721.         $formatted = ($this->localStrictModeEnabled ?? static::isStrictModeEnabled())
  1722.             ? strftime($format$time)
  1723.             : @strftime($format$time);
  1724.         return static::$utf8
  1725.             ? (
  1726.                 \function_exists('mb_convert_encoding')
  1727.                 ? mb_convert_encoding($formatted'UTF-8'mb_list_encodings())
  1728.                 : utf8_encode($formatted)
  1729.             )
  1730.             : $formatted;
  1731.     }
  1732.     /**
  1733.      * Returns list of locale formats for ISO formatting.
  1734.      *
  1735.      * @param string|null $locale current locale used if null
  1736.      *
  1737.      * @return array
  1738.      */
  1739.     public function getIsoFormats($locale null)
  1740.     {
  1741.         return [
  1742.             'LT' => $this->getTranslationMessage('formats.LT'$locale'h:mm A'),
  1743.             'LTS' => $this->getTranslationMessage('formats.LTS'$locale'h:mm:ss A'),
  1744.             'L' => $this->getTranslationMessage('formats.L'$locale'MM/DD/YYYY'),
  1745.             'LL' => $this->getTranslationMessage('formats.LL'$locale'MMMM D, YYYY'),
  1746.             'LLL' => $this->getTranslationMessage('formats.LLL'$locale'MMMM D, YYYY h:mm A'),
  1747.             'LLLL' => $this->getTranslationMessage('formats.LLLL'$locale'dddd, MMMM D, YYYY h:mm A'),
  1748.             'l' => $this->getTranslationMessage('formats.l'$locale),
  1749.             'll' => $this->getTranslationMessage('formats.ll'$locale),
  1750.             'lll' => $this->getTranslationMessage('formats.lll'$locale),
  1751.             'llll' => $this->getTranslationMessage('formats.llll'$locale),
  1752.         ];
  1753.     }
  1754.     /**
  1755.      * Returns list of calendar formats for ISO formatting.
  1756.      *
  1757.      * @param string|null $locale current locale used if null
  1758.      *
  1759.      * @return array
  1760.      */
  1761.     public function getCalendarFormats($locale null)
  1762.     {
  1763.         return [
  1764.             'sameDay' => $this->getTranslationMessage('calendar.sameDay'$locale'[Today at] LT'),
  1765.             'nextDay' => $this->getTranslationMessage('calendar.nextDay'$locale'[Tomorrow at] LT'),
  1766.             'nextWeek' => $this->getTranslationMessage('calendar.nextWeek'$locale'dddd [at] LT'),
  1767.             'lastDay' => $this->getTranslationMessage('calendar.lastDay'$locale'[Yesterday at] LT'),
  1768.             'lastWeek' => $this->getTranslationMessage('calendar.lastWeek'$locale'[Last] dddd [at] LT'),
  1769.             'sameElse' => $this->getTranslationMessage('calendar.sameElse'$locale'L'),
  1770.         ];
  1771.     }
  1772.     /**
  1773.      * Returns list of locale units for ISO formatting.
  1774.      *
  1775.      * @return array
  1776.      */
  1777.     public static function getIsoUnits()
  1778.     {
  1779.         static $units null;
  1780.         if ($units === null) {
  1781.             $units = [
  1782.                 'OD' => ['getAltNumber', ['day']],
  1783.                 'OM' => ['getAltNumber', ['month']],
  1784.                 'OY' => ['getAltNumber', ['year']],
  1785.                 'OH' => ['getAltNumber', ['hour']],
  1786.                 'Oh' => ['getAltNumber', ['h']],
  1787.                 'Om' => ['getAltNumber', ['minute']],
  1788.                 'Os' => ['getAltNumber', ['second']],
  1789.                 'D' => 'day',
  1790.                 'DD' => ['rawFormat', ['d']],
  1791.                 'Do' => ['ordinal', ['day''D']],
  1792.                 'd' => 'dayOfWeek',
  1793.                 'dd' => function (CarbonInterface $date$originalFormat null) {
  1794.                     return $date->getTranslatedMinDayName($originalFormat);
  1795.                 },
  1796.                 'ddd' => function (CarbonInterface $date$originalFormat null) {
  1797.                     return $date->getTranslatedShortDayName($originalFormat);
  1798.                 },
  1799.                 'dddd' => function (CarbonInterface $date$originalFormat null) {
  1800.                     return $date->getTranslatedDayName($originalFormat);
  1801.                 },
  1802.                 'DDD' => 'dayOfYear',
  1803.                 'DDDD' => ['getPaddedUnit', ['dayOfYear'3]],
  1804.                 'DDDo' => ['ordinal', ['dayOfYear''DDD']],
  1805.                 'e' => ['weekday', []],
  1806.                 'E' => 'dayOfWeekIso',
  1807.                 'H' => ['rawFormat', ['G']],
  1808.                 'HH' => ['rawFormat', ['H']],
  1809.                 'h' => ['rawFormat', ['g']],
  1810.                 'hh' => ['rawFormat', ['h']],
  1811.                 'k' => 'noZeroHour',
  1812.                 'kk' => ['getPaddedUnit', ['noZeroHour']],
  1813.                 'hmm' => ['rawFormat', ['gi']],
  1814.                 'hmmss' => ['rawFormat', ['gis']],
  1815.                 'Hmm' => ['rawFormat', ['Gi']],
  1816.                 'Hmmss' => ['rawFormat', ['Gis']],
  1817.                 'm' => 'minute',
  1818.                 'mm' => ['rawFormat', ['i']],
  1819.                 'a' => 'meridiem',
  1820.                 'A' => 'upperMeridiem',
  1821.                 's' => 'second',
  1822.                 'ss' => ['getPaddedUnit', ['second']],
  1823.                 'S' => function (CarbonInterface $date) {
  1824.                     return (string) floor($date->micro 100000);
  1825.                 },
  1826.                 'SS' => function (CarbonInterface $date) {
  1827.                     return str_pad((string) floor($date->micro 10000), 2'0'STR_PAD_LEFT);
  1828.                 },
  1829.                 'SSS' => function (CarbonInterface $date) {
  1830.                     return str_pad((string) floor($date->micro 1000), 3'0'STR_PAD_LEFT);
  1831.                 },
  1832.                 'SSSS' => function (CarbonInterface $date) {
  1833.                     return str_pad((string) floor($date->micro 100), 4'0'STR_PAD_LEFT);
  1834.                 },
  1835.                 'SSSSS' => function (CarbonInterface $date) {
  1836.                     return str_pad((string) floor($date->micro 10), 5'0'STR_PAD_LEFT);
  1837.                 },
  1838.                 'SSSSSS' => ['getPaddedUnit', ['micro'6]],
  1839.                 'SSSSSSS' => function (CarbonInterface $date) {
  1840.                     return str_pad((string) floor($date->micro 10), 7'0'STR_PAD_LEFT);
  1841.                 },
  1842.                 'SSSSSSSS' => function (CarbonInterface $date) {
  1843.                     return str_pad((string) floor($date->micro 100), 8'0'STR_PAD_LEFT);
  1844.                 },
  1845.                 'SSSSSSSSS' => function (CarbonInterface $date) {
  1846.                     return str_pad((string) floor($date->micro 1000), 9'0'STR_PAD_LEFT);
  1847.                 },
  1848.                 'M' => 'month',
  1849.                 'MM' => ['rawFormat', ['m']],
  1850.                 'MMM' => function (CarbonInterface $date$originalFormat null) {
  1851.                     $month $date->getTranslatedShortMonthName($originalFormat);
  1852.                     $suffix $date->getTranslationMessage('mmm_suffix');
  1853.                     if ($suffix && $month !== $date->monthName) {
  1854.                         $month .= $suffix;
  1855.                     }
  1856.                     return $month;
  1857.                 },
  1858.                 'MMMM' => function (CarbonInterface $date$originalFormat null) {
  1859.                     return $date->getTranslatedMonthName($originalFormat);
  1860.                 },
  1861.                 'Mo' => ['ordinal', ['month''M']],
  1862.                 'Q' => 'quarter',
  1863.                 'Qo' => ['ordinal', ['quarter''M']],
  1864.                 'G' => 'isoWeekYear',
  1865.                 'GG' => ['getPaddedUnit', ['isoWeekYear']],
  1866.                 'GGG' => ['getPaddedUnit', ['isoWeekYear'3]],
  1867.                 'GGGG' => ['getPaddedUnit', ['isoWeekYear'4]],
  1868.                 'GGGGG' => ['getPaddedUnit', ['isoWeekYear'5]],
  1869.                 'g' => 'weekYear',
  1870.                 'gg' => ['getPaddedUnit', ['weekYear']],
  1871.                 'ggg' => ['getPaddedUnit', ['weekYear'3]],
  1872.                 'gggg' => ['getPaddedUnit', ['weekYear'4]],
  1873.                 'ggggg' => ['getPaddedUnit', ['weekYear'5]],
  1874.                 'W' => 'isoWeek',
  1875.                 'WW' => ['getPaddedUnit', ['isoWeek']],
  1876.                 'Wo' => ['ordinal', ['isoWeek''W']],
  1877.                 'w' => 'week',
  1878.                 'ww' => ['getPaddedUnit', ['week']],
  1879.                 'wo' => ['ordinal', ['week''w']],
  1880.                 'x' => ['valueOf', []],
  1881.                 'X' => 'timestamp',
  1882.                 'Y' => 'year',
  1883.                 'YY' => ['rawFormat', ['y']],
  1884.                 'YYYY' => ['getPaddedUnit', ['year'4]],
  1885.                 'YYYYY' => ['getPaddedUnit', ['year'5]],
  1886.                 'YYYYYY' => function (CarbonInterface $date) {
  1887.                     return ($date->year '' '+').$date->getPaddedUnit('year'6);
  1888.                 },
  1889.                 'z' => ['rawFormat', ['T']],
  1890.                 'zz' => 'tzName',
  1891.                 'Z' => ['getOffsetString', []],
  1892.                 'ZZ' => ['getOffsetString', ['']],
  1893.             ];
  1894.         }
  1895.         return $units;
  1896.     }
  1897.     /**
  1898.      * Returns a unit of the instance padded with 0 by default or any other string if specified.
  1899.      *
  1900.      * @param string $unit      Carbon unit name
  1901.      * @param int    $length    Length of the output (2 by default)
  1902.      * @param string $padString String to use for padding ("0" by default)
  1903.      * @param int    $padType   Side(s) to pad (STR_PAD_LEFT by default)
  1904.      *
  1905.      * @return string
  1906.      */
  1907.     public function getPaddedUnit($unit$length 2$padString '0'$padType STR_PAD_LEFT)
  1908.     {
  1909.         return ($this->$unit '-' '').str_pad((string) abs($this->$unit), $length$padString$padType);
  1910.     }
  1911.     /**
  1912.      * Return a property with its ordinal.
  1913.      *
  1914.      * @param string      $key
  1915.      * @param string|null $period
  1916.      *
  1917.      * @return string
  1918.      */
  1919.     public function ordinal(string $key, ?string $period null): string
  1920.     {
  1921.         $number $this->$key;
  1922.         $result $this->translate('ordinal', [
  1923.             ':number' => $number,
  1924.             ':period' => (string) $period,
  1925.         ]);
  1926.         return (string) ($result === 'ordinal' $number $result);
  1927.     }
  1928.     /**
  1929.      * Return the meridiem of the current time in the current locale.
  1930.      *
  1931.      * @param bool $isLower if true, returns lowercase variant if available in the current locale.
  1932.      *
  1933.      * @return string
  1934.      */
  1935.     public function meridiem(bool $isLower false): string
  1936.     {
  1937.         $hour $this->hour;
  1938.         $index $hour 12 1;
  1939.         if ($isLower) {
  1940.             $key 'meridiem.'.($index 2);
  1941.             $result $this->translate($key);
  1942.             if ($result !== $key) {
  1943.                 return $result;
  1944.             }
  1945.         }
  1946.         $key "meridiem.$index";
  1947.         $result $this->translate($key);
  1948.         if ($result === $key) {
  1949.             $result $this->translate('meridiem', [
  1950.                 ':hour' => $this->hour,
  1951.                 ':minute' => $this->minute,
  1952.                 ':isLower' => $isLower,
  1953.             ]);
  1954.             if ($result === 'meridiem') {
  1955.                 return $isLower $this->latinMeridiem $this->latinUpperMeridiem;
  1956.             }
  1957.         } elseif ($isLower) {
  1958.             $result mb_strtolower($result);
  1959.         }
  1960.         return $result;
  1961.     }
  1962.     /**
  1963.      * Returns the alternative number for a given date property if available in the current locale.
  1964.      *
  1965.      * @param string $key date property
  1966.      *
  1967.      * @return string
  1968.      */
  1969.     public function getAltNumber(string $key): string
  1970.     {
  1971.         return $this->translateNumber(\strlen($key) > $this->$key $this->rawFormat('h'));
  1972.     }
  1973.     /**
  1974.      * Format in the current language using ISO replacement patterns.
  1975.      *
  1976.      * @param string      $format
  1977.      * @param string|null $originalFormat provide context if a chunk has been passed alone
  1978.      *
  1979.      * @return string
  1980.      */
  1981.     public function isoFormat(string $format, ?string $originalFormat null): string
  1982.     {
  1983.         $result '';
  1984.         $length mb_strlen($format);
  1985.         $originalFormat $originalFormat ?: $format;
  1986.         $inEscaped false;
  1987.         $formats null;
  1988.         $units null;
  1989.         for ($i 0$i $length$i++) {
  1990.             $char mb_substr($format$i1);
  1991.             if ($char === '\\') {
  1992.                 $result .= mb_substr($format, ++$i1);
  1993.                 continue;
  1994.             }
  1995.             if ($char === '[' && !$inEscaped) {
  1996.                 $inEscaped true;
  1997.                 continue;
  1998.             }
  1999.             if ($char === ']' && $inEscaped) {
  2000.                 $inEscaped false;
  2001.                 continue;
  2002.             }
  2003.             if ($inEscaped) {
  2004.                 $result .= $char;
  2005.                 continue;
  2006.             }
  2007.             $input mb_substr($format$i);
  2008.             if (preg_match('/^(LTS|LT|l{1,4}|L{1,4})/'$input$match)) {
  2009.                 if ($formats === null) {
  2010.                     $formats $this->getIsoFormats();
  2011.                 }
  2012.                 $code $match[0];
  2013.                 $sequence $formats[$code] ?? preg_replace_callback(
  2014.                     '/MMMM|MM|DD|dddd/',
  2015.                     function ($code) {
  2016.                         return mb_substr($code[0], 1);
  2017.                     },
  2018.                     $formats[strtoupper($code)] ?? ''
  2019.                 );
  2020.                 $rest mb_substr($format$i mb_strlen($code));
  2021.                 $format mb_substr($format0$i).$sequence.$rest;
  2022.                 $length mb_strlen($format);
  2023.                 $input $sequence.$rest;
  2024.             }
  2025.             if (preg_match('/^'.CarbonInterface::ISO_FORMAT_REGEXP.'/'$input$match)) {
  2026.                 $code $match[0];
  2027.                 if ($units === null) {
  2028.                     $units = static::getIsoUnits();
  2029.                 }
  2030.                 $sequence $units[$code] ?? '';
  2031.                 if ($sequence instanceof Closure) {
  2032.                     $sequence $sequence($this$originalFormat);
  2033.                 } elseif (\is_array($sequence)) {
  2034.                     try {
  2035.                         $sequence $this->{$sequence[0]}(...$sequence[1]);
  2036.                     } catch (ReflectionException InvalidArgumentException BadMethodCallException $e) {
  2037.                         $sequence '';
  2038.                     }
  2039.                 } elseif (\is_string($sequence)) {
  2040.                     $sequence $this->$sequence ?? $code;
  2041.                 }
  2042.                 $format mb_substr($format0$i).$sequence.mb_substr($format$i mb_strlen($code));
  2043.                 $i += mb_strlen((string) $sequence) - 1;
  2044.                 $length mb_strlen($format);
  2045.                 $char $sequence;
  2046.             }
  2047.             $result .= $char;
  2048.         }
  2049.         return $result;
  2050.     }
  2051.     /**
  2052.      * List of replacements from date() format to isoFormat().
  2053.      *
  2054.      * @return array
  2055.      */
  2056.     public static function getFormatsToIsoReplacements()
  2057.     {
  2058.         static $replacements null;
  2059.         if ($replacements === null) {
  2060.             $replacements = [
  2061.                 'd' => true,
  2062.                 'D' => 'ddd',
  2063.                 'j' => true,
  2064.                 'l' => 'dddd',
  2065.                 'N' => true,
  2066.                 'S' => function ($date) {
  2067.                     $day $date->rawFormat('j');
  2068.                     return str_replace((string) $day''$date->isoFormat('Do'));
  2069.                 },
  2070.                 'w' => true,
  2071.                 'z' => true,
  2072.                 'W' => true,
  2073.                 'F' => 'MMMM',
  2074.                 'm' => true,
  2075.                 'M' => 'MMM',
  2076.                 'n' => true,
  2077.                 't' => true,
  2078.                 'L' => true,
  2079.                 'o' => true,
  2080.                 'Y' => true,
  2081.                 'y' => true,
  2082.                 'a' => 'a',
  2083.                 'A' => 'A',
  2084.                 'B' => true,
  2085.                 'g' => true,
  2086.                 'G' => true,
  2087.                 'h' => true,
  2088.                 'H' => true,
  2089.                 'i' => true,
  2090.                 's' => true,
  2091.                 'u' => true,
  2092.                 'v' => true,
  2093.                 'E' => true,
  2094.                 'I' => true,
  2095.                 'O' => true,
  2096.                 'P' => true,
  2097.                 'Z' => true,
  2098.                 'c' => true,
  2099.                 'r' => true,
  2100.                 'U' => true,
  2101.             ];
  2102.         }
  2103.         return $replacements;
  2104.     }
  2105.     /**
  2106.      * Format as ->format() do (using date replacements patterns from https://php.net/manual/en/function.date.php)
  2107.      * but translate words whenever possible (months, day names, etc.) using the current locale.
  2108.      *
  2109.      * @param string $format
  2110.      *
  2111.      * @return string
  2112.      */
  2113.     public function translatedFormat(string $format): string
  2114.     {
  2115.         $replacements = static::getFormatsToIsoReplacements();
  2116.         $context '';
  2117.         $isoFormat '';
  2118.         $length mb_strlen($format);
  2119.         for ($i 0$i $length$i++) {
  2120.             $char mb_substr($format$i1);
  2121.             if ($char === '\\') {
  2122.                 $replacement mb_substr($format$i2);
  2123.                 $isoFormat .= $replacement;
  2124.                 $i++;
  2125.                 continue;
  2126.             }
  2127.             if (!isset($replacements[$char])) {
  2128.                 $replacement preg_match('/^[A-Za-z]$/'$char) ? "\\$char$char;
  2129.                 $isoFormat .= $replacement;
  2130.                 $context .= $replacement;
  2131.                 continue;
  2132.             }
  2133.             $replacement $replacements[$char];
  2134.             if ($replacement === true) {
  2135.                 static $contextReplacements null;
  2136.                 if ($contextReplacements === null) {
  2137.                     $contextReplacements = [
  2138.                         'm' => 'MM',
  2139.                         'd' => 'DD',
  2140.                         't' => 'D',
  2141.                         'j' => 'D',
  2142.                         'N' => 'e',
  2143.                         'w' => 'e',
  2144.                         'n' => 'M',
  2145.                         'o' => 'YYYY',
  2146.                         'Y' => 'YYYY',
  2147.                         'y' => 'YY',
  2148.                         'g' => 'h',
  2149.                         'G' => 'H',
  2150.                         'h' => 'hh',
  2151.                         'H' => 'HH',
  2152.                         'i' => 'mm',
  2153.                         's' => 'ss',
  2154.                     ];
  2155.                 }
  2156.                 $isoFormat .= '['.$this->rawFormat($char).']';
  2157.                 $context .= $contextReplacements[$char] ?? ' ';
  2158.                 continue;
  2159.             }
  2160.             if ($replacement instanceof Closure) {
  2161.                 $replacement '['.$replacement($this).']';
  2162.                 $isoFormat .= $replacement;
  2163.                 $context .= $replacement;
  2164.                 continue;
  2165.             }
  2166.             $isoFormat .= $replacement;
  2167.             $context .= $replacement;
  2168.         }
  2169.         return $this->isoFormat($isoFormat$context);
  2170.     }
  2171.     /**
  2172.      * Returns the offset hour and minute formatted with +/- and a given separator (":" by default).
  2173.      * For example, if the time zone is 9 hours 30 minutes, you'll get "+09:30", with "@@" as first
  2174.      * argument, "+09@@30", with "" as first argument, "+0930". Negative offset will return something
  2175.      * like "-12:00".
  2176.      *
  2177.      * @param string $separator string to place between hours and minutes (":" by default)
  2178.      *
  2179.      * @return string
  2180.      */
  2181.     public function getOffsetString($separator ':')
  2182.     {
  2183.         $second $this->getOffset();
  2184.         $symbol $second '-' '+';
  2185.         $minute abs($second) / static::SECONDS_PER_MINUTE;
  2186.         $hour str_pad((string) floor($minute / static::MINUTES_PER_HOUR), 2'0'STR_PAD_LEFT);
  2187.         $minute str_pad((string) (((int) $minute) % static::MINUTES_PER_HOUR), 2'0'STR_PAD_LEFT);
  2188.         return "$symbol$hour$separator$minute";
  2189.     }
  2190.     protected static function executeStaticCallable($macro, ...$parameters)
  2191.     {
  2192.         return static::bindMacroContext(null, function () use (&$macro, &$parameters) {
  2193.             if ($macro instanceof Closure) {
  2194.                 $boundMacro = @Closure::bind($macronull, static::class);
  2195.                 return ($boundMacro ?: $macro)(...$parameters);
  2196.             }
  2197.             return $macro(...$parameters);
  2198.         });
  2199.     }
  2200.     /**
  2201.      * Dynamically handle calls to the class.
  2202.      *
  2203.      * @param string $method     magic method name called
  2204.      * @param array  $parameters parameters list
  2205.      *
  2206.      * @throws BadMethodCallException
  2207.      *
  2208.      * @return mixed
  2209.      */
  2210.     public static function __callStatic($method$parameters)
  2211.     {
  2212.         if (!static::hasMacro($method)) {
  2213.             foreach (static::getGenericMacros() as $callback) {
  2214.                 try {
  2215.                     return static::executeStaticCallable($callback$method, ...$parameters);
  2216.                 } catch (BadMethodCallException $exception) {
  2217.                     continue;
  2218.                 }
  2219.             }
  2220.             if (static::isStrictModeEnabled()) {
  2221.                 throw new UnknownMethodException(sprintf('%s::%s', static::class, $method));
  2222.             }
  2223.             return null;
  2224.         }
  2225.         return static::executeStaticCallable(static::$globalMacros[$method], ...$parameters);
  2226.     }
  2227.     /**
  2228.      * Set specified unit to new given value.
  2229.      *
  2230.      * @param string $unit  year, month, day, hour, minute, second or microsecond
  2231.      * @param int    $value new value for given unit
  2232.      *
  2233.      * @return static
  2234.      */
  2235.     public function setUnit($unit$value null)
  2236.     {
  2237.         $unit = static::singularUnit($unit);
  2238.         $dateUnits = ['year''month''day'];
  2239.         if (\in_array($unit$dateUnits)) {
  2240.             return $this->setDate(...array_map(function ($name) use ($unit$value) {
  2241.                 return (int) ($name === $unit $value $this->$name);
  2242.             }, $dateUnits));
  2243.         }
  2244.         $units = ['hour''minute''second''micro'];
  2245.         if ($unit === 'millisecond' || $unit === 'milli') {
  2246.             $value *= 1000;
  2247.             $unit 'micro';
  2248.         } elseif ($unit === 'microsecond') {
  2249.             $unit 'micro';
  2250.         }
  2251.         return $this->setTime(...array_map(function ($name) use ($unit$value) {
  2252.             return (int) ($name === $unit $value $this->$name);
  2253.         }, $units));
  2254.     }
  2255.     /**
  2256.      * Returns standardized singular of a given singular/plural unit name (in English).
  2257.      *
  2258.      * @param string $unit
  2259.      *
  2260.      * @return string
  2261.      */
  2262.     public static function singularUnit(string $unit): string
  2263.     {
  2264.         $unit rtrim(mb_strtolower($unit), 's');
  2265.         if ($unit === 'centurie') {
  2266.             return 'century';
  2267.         }
  2268.         if ($unit === 'millennia') {
  2269.             return 'millennium';
  2270.         }
  2271.         return $unit;
  2272.     }
  2273.     /**
  2274.      * Returns standardized plural of a given singular/plural unit name (in English).
  2275.      *
  2276.      * @param string $unit
  2277.      *
  2278.      * @return string
  2279.      */
  2280.     public static function pluralUnit(string $unit): string
  2281.     {
  2282.         $unit rtrim(strtolower($unit), 's');
  2283.         if ($unit === 'century') {
  2284.             return 'centuries';
  2285.         }
  2286.         if ($unit === 'millennium' || $unit === 'millennia') {
  2287.             return 'millennia';
  2288.         }
  2289.         return "{$unit}s";
  2290.     }
  2291.     protected function executeCallable($macro, ...$parameters)
  2292.     {
  2293.         if ($macro instanceof Closure) {
  2294.             $boundMacro = @$macro->bindTo($this, static::class) ?: @$macro->bindTo(null, static::class);
  2295.             return ($boundMacro ?: $macro)(...$parameters);
  2296.         }
  2297.         return $macro(...$parameters);
  2298.     }
  2299.     protected function executeCallableWithContext($macro, ...$parameters)
  2300.     {
  2301.         return static::bindMacroContext($this, function () use (&$macro, &$parameters) {
  2302.             return $this->executeCallable($macro, ...$parameters);
  2303.         });
  2304.     }
  2305.     protected static function getGenericMacros()
  2306.     {
  2307.         foreach (static::$globalGenericMacros as $list) {
  2308.             foreach ($list as $macro) {
  2309.                 yield $macro;
  2310.             }
  2311.         }
  2312.     }
  2313.     /**
  2314.      * Dynamically handle calls to the class.
  2315.      *
  2316.      * @param string $method     magic method name called
  2317.      * @param array  $parameters parameters list
  2318.      *
  2319.      * @throws UnknownMethodException|BadMethodCallException|ReflectionException|Throwable
  2320.      *
  2321.      * @return mixed
  2322.      */
  2323.     public function __call($method$parameters)
  2324.     {
  2325.         $diffSizes = [
  2326.             // @mode diffForHumans
  2327.             'short' => true,
  2328.             // @mode diffForHumans
  2329.             'long' => false,
  2330.         ];
  2331.         $diffSyntaxModes = [
  2332.             // @call diffForHumans
  2333.             'Absolute' => CarbonInterface::DIFF_ABSOLUTE,
  2334.             // @call diffForHumans
  2335.             'Relative' => CarbonInterface::DIFF_RELATIVE_AUTO,
  2336.             // @call diffForHumans
  2337.             'RelativeToNow' => CarbonInterface::DIFF_RELATIVE_TO_NOW,
  2338.             // @call diffForHumans
  2339.             'RelativeToOther' => CarbonInterface::DIFF_RELATIVE_TO_OTHER,
  2340.         ];
  2341.         $sizePattern implode('|'array_keys($diffSizes));
  2342.         $syntaxPattern implode('|'array_keys($diffSyntaxModes));
  2343.         if (preg_match("/^(?<size>$sizePattern)(?<syntax>$syntaxPattern)DiffForHumans$/"$method$match)) {
  2344.             $dates array_filter($parameters, function ($parameter) {
  2345.                 return $parameter instanceof DateTimeInterface;
  2346.             });
  2347.             $other null;
  2348.             if (\count($dates)) {
  2349.                 $key key($dates);
  2350.                 $other current($dates);
  2351.                 array_splice($parameters$key1);
  2352.             }
  2353.             return $this->diffForHumans($other$diffSyntaxModes[$match['syntax']], $diffSizes[$match['size']], ...$parameters);
  2354.         }
  2355.         $roundedValue $this->callRoundMethod($method$parameters);
  2356.         if ($roundedValue !== null) {
  2357.             return $roundedValue;
  2358.         }
  2359.         $unit rtrim($method's');
  2360.         if (str_starts_with($unit'is')) {
  2361.             $word substr($unit2);
  2362.             if (\in_array($word, static::$daystrue)) {
  2363.                 return $this->isDayOfWeek($word);
  2364.             }
  2365.             switch ($word) {
  2366.                 // @call is Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.)
  2367.                 case 'Utc':
  2368.                 case 'UTC':
  2369.                     return $this->utc;
  2370.                 // @call is Check if the current instance has non-UTC timezone.
  2371.                 case 'Local':
  2372.                     return $this->local;
  2373.                 // @call is Check if the current instance is a valid date.
  2374.                 case 'Valid':
  2375.                     return $this->year !== 0;
  2376.                 // @call is Check if the current instance is in a daylight saving time.
  2377.                 case 'DST':
  2378.                     return $this->dst;
  2379.             }
  2380.         }
  2381.         $action substr($unit03);
  2382.         $overflow null;
  2383.         if ($action === 'set') {
  2384.             $unit strtolower(substr($unit3));
  2385.         }
  2386.         if (\in_array($unit, static::$unitstrue)) {
  2387.             return $this->setUnit($unit, ...$parameters);
  2388.         }
  2389.         if ($action === 'add' || $action === 'sub') {
  2390.             $unit substr($unit3);
  2391.             if (str_starts_with($unit'Real')) {
  2392.                 $unit = static::singularUnit(substr($unit4));
  2393.                 return $this->{"{$action}RealUnit"}($unit, ...$parameters);
  2394.             }
  2395.             if (preg_match('/^(Month|Quarter|Year|Decade|Century|Centurie|Millennium|Millennia)s?(No|With|Without|WithNo)Overflow$/'$unit$match)) {
  2396.                 $unit $match[1];
  2397.                 $overflow $match[2] === 'With';
  2398.             }
  2399.             $unit = static::singularUnit($unit);
  2400.         }
  2401.         if (static::isModifiableUnit($unit)) {
  2402.             return $this->{"{$action}Unit"}($unit$this->getMagicParameter($parameters0'value'1), $overflow);
  2403.         }
  2404.         $sixFirstLetters substr($unit06);
  2405.         $factor = -1;
  2406.         if ($sixFirstLetters === 'isLast') {
  2407.             $sixFirstLetters 'isNext';
  2408.             $factor 1;
  2409.         }
  2410.         if ($sixFirstLetters === 'isNext') {
  2411.             $lowerUnit strtolower(substr($unit6));
  2412.             if (static::isModifiableUnit($lowerUnit)) {
  2413.                 return $this->copy()->addUnit($lowerUnit$factorfalse)->isSameUnit($lowerUnit, ...$parameters);
  2414.             }
  2415.         }
  2416.         if ($sixFirstLetters === 'isSame') {
  2417.             try {
  2418.                 return $this->isSameUnit(strtolower(substr($unit6)), ...$parameters);
  2419.             } catch (BadComparisonUnitException $exception) {
  2420.                 // Try next
  2421.             }
  2422.         }
  2423.         if (str_starts_with($unit'isCurrent')) {
  2424.             try {
  2425.                 return $this->isCurrentUnit(strtolower(substr($unit9)));
  2426.             } catch (BadComparisonUnitException BadMethodCallException $exception) {
  2427.                 // Try next
  2428.             }
  2429.         }
  2430.         if (str_ends_with($method'Until')) {
  2431.             try {
  2432.                 $unit = static::singularUnit(substr($method0, -5));
  2433.                 return $this->range(
  2434.                     $this->getMagicParameter($parameters0'endDate'$this),
  2435.                     $this->getMagicParameter($parameters1'factor'1),
  2436.                     $unit
  2437.                 );
  2438.             } catch (InvalidArgumentException $exception) {
  2439.                 // Try macros
  2440.             }
  2441.         }
  2442.         return static::bindMacroContext($this, function () use (&$method, &$parameters) {
  2443.             $macro $this->getLocalMacro($method);
  2444.             if (!$macro) {
  2445.                 foreach ([$this->localGenericMacros ?: [], static::getGenericMacros()] as $list) {
  2446.                     foreach ($list as $callback) {
  2447.                         try {
  2448.                             return $this->executeCallable($callback$method, ...$parameters);
  2449.                         } catch (BadMethodCallException $exception) {
  2450.                             continue;
  2451.                         }
  2452.                     }
  2453.                 }
  2454.                 if ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) {
  2455.                     throw new UnknownMethodException($method);
  2456.                 }
  2457.                 return null;
  2458.             }
  2459.             return $this->executeCallable($macro, ...$parameters);
  2460.         });
  2461.     }
  2462. }