This commit is contained in:
emmymayo
2025-02-05 23:15:46 +01:00
commit 7269c99357
16995 changed files with 3389680 additions and 0 deletions
@@ -0,0 +1 @@
<?php
@@ -0,0 +1,67 @@
<?php
namespace MailPoetVendor;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\CarbonImmutable;
require_once __DIR__ . '/vendor/autoload.php';
function getMaxHistoryMonthsByAmount($amount) : int
{
if ($amount >= 50) {
return 6;
}
if ($amount >= 20) {
return 4;
}
return 2;
}
function getHtmlAttribute($rawValue) : string
{
return \str_replace(['', "\r"], '', \trim(\htmlspecialchars((string) $rawValue), "  \n\r\t\v\x00"));
}
function getOpenCollectiveSponsors() : string
{
$customSponsorImages = [];
$members = \json_decode(\file_get_contents('https://opencollective.com/carbon/members/all.json'), \true);
$list = \array_filter($members, static function ($member) : bool {
return ($member['lastTransactionAmount'] > 3 || $member['isActive']) && $member['role'] === 'BACKER' && $member['type'] !== 'USER' && ($member['totalAmountDonated'] > 100 || $member['lastTransactionAt'] > CarbonImmutable::now()->subMonthsNoOverflow(getMaxHistoryMonthsByAmount($member['lastTransactionAmount']))->format('Y-m-d h:i') || $member['isActive'] && $member['lastTransactionAmount'] >= 30);
});
$list = \array_map(static function (array $member) : array {
$createdAt = CarbonImmutable::parse($member['createdAt']);
$lastTransactionAt = CarbonImmutable::parse($member['lastTransactionAt']);
if ($createdAt->format('d H:i:s.u') > $lastTransactionAt->format('d H:i:s.u')) {
$createdAt = $createdAt->setDay($lastTransactionAt->day)->modify($lastTransactionAt->format('H:i:s.u'));
}
$monthlyContribution = (float) ($member['totalAmountDonated'] / \ceil($createdAt->floatDiffInMonths()));
if ($lastTransactionAt->isAfter('last month') && $member['lastTransactionAmount'] > $monthlyContribution) {
$monthlyContribution = (float) $member['lastTransactionAmount'];
}
$yearlyContribution = (float) ($member['totalAmountDonated'] / \max(1, $createdAt->floatDiffInYears()));
$status = null;
if ($monthlyContribution > 29) {
$status = 'sponsor';
} elseif ($monthlyContribution > 4.5 || $yearlyContribution > 29) {
$status = 'backer';
} elseif ($member['totalAmountDonated'] > 0) {
$status = 'helper';
}
return \array_merge($member, ['star' => $monthlyContribution > 98 || $yearlyContribution > 500, 'status' => $status, 'monthlyContribution' => $monthlyContribution, 'yearlyContribution' => $yearlyContribution]);
}, $list);
\usort($list, static function (array $a, array $b) : int {
return $b['monthlyContribution'] <=> $a['monthlyContribution'] ?: $b['totalAmountDonated'] <=> $a['totalAmountDonated'];
});
return \implode('', \array_map(static function (array $member) use($customSponsorImages) : string {
$href = \htmlspecialchars($member['website'] ?? $member['profile']);
$src = $customSponsorImages[$member['MemberId'] ?? ''] ?? $member['image'] ?? \strtr($member['profile'], ['https://opencollective.com/' => 'https://images.opencollective.com/']) . '/avatar/256.png';
[$x, $y] = @\getimagesize($src) ?: [0, 0];
$validImage = $x && $y;
$src = $validImage ? \htmlspecialchars($src) : 'https://opencollective.com/static/images/default-guest-logo.svg';
$height = $member['status'] === 'sponsor' ? 64 : 42;
$width = \min($height * 2, $validImage ? \round($x * $height / $y) : $height);
$href .= (\strpos($href, '?') === \false ? '?' : '&amp;') . 'utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon';
$title = getHtmlAttribute($member['description'] ?? null ?: $member['name']);
$alt = getHtmlAttribute($member['name']);
return "\n" . '<a title="' . $title . '" href="' . $href . '" target="_blank">' . '<img alt="' . $alt . '" src="' . $src . '" width="' . $width . '" height="' . $height . '">' . '</a>';
}, $list)) . "\n";
}
\file_put_contents('readme.md', \preg_replace_callback('/(<!-- <open-collective-sponsors> -->)[\\s\\S]+(<!-- <\\/open-collective-sponsors> -->)/', static function (array $match) : string {
return $match[1] . getOpenCollectiveSponsors() . $match[2];
}, \file_get_contents('readme.md')));
@@ -0,0 +1,191 @@
<?php
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\MessageFormatter\MessageFormatterMapper;
use Closure;
use ReflectionException;
use ReflectionFunction;
use MailPoetVendor\Symfony\Component\Translation;
use MailPoetVendor\Symfony\Component\Translation\Formatter\MessageFormatterInterface;
use MailPoetVendor\Symfony\Component\Translation\Loader\ArrayLoader;
abstract class AbstractTranslator extends Translation\Translator
{
protected static $singletons = [];
protected $messages = [];
protected $directories = [];
protected $initializing = \false;
protected $aliases = ['me' => 'sr_Latn_ME', 'scr' => 'sh'];
public static function get($locale = null)
{
$locale = $locale ?: 'en';
$key = static::class === Translator::class ? $locale : static::class . '|' . $locale;
if (!isset(static::$singletons[$key])) {
static::$singletons[$key] = new static($locale);
}
return static::$singletons[$key];
}
public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = \false)
{
parent::setLocale($locale);
$this->initializing = \true;
$this->directories = [__DIR__ . '/Lang'];
$this->addLoader('array', new ArrayLoader());
parent::__construct($locale, new MessageFormatterMapper($formatter), $cacheDir, $debug);
$this->initializing = \false;
}
public function getDirectories() : array
{
return $this->directories;
}
public function setDirectories(array $directories)
{
$this->directories = $directories;
return $this;
}
public function addDirectory(string $directory)
{
$this->directories[] = $directory;
return $this;
}
public function removeDirectory(string $directory)
{
$search = \rtrim(\strtr($directory, '\\', '/'), '/');
return $this->setDirectories(\array_filter($this->getDirectories(), function ($item) use($search) {
return \rtrim(\strtr($item, '\\', '/'), '/') !== $search;
}));
}
public function resetMessages($locale = null)
{
if ($locale === null) {
$this->messages = [];
return \true;
}
$this->assertValidLocale($locale);
foreach ($this->getDirectories() as $directory) {
$data = @(include \sprintf('%s/%s.php', \rtrim($directory, '\\/'), $locale));
if ($data !== \false) {
$this->messages[$locale] = $data;
$this->addResource('array', $this->messages[$locale], $locale);
return \true;
}
}
return \false;
}
public function getLocalesFiles($prefix = '')
{
$files = [];
foreach ($this->getDirectories() as $directory) {
$directory = \rtrim($directory, '\\/');
foreach (\glob("{$directory}/{$prefix}*.php") as $file) {
$files[] = $file;
}
}
return \array_unique($files);
}
public function getAvailableLocales($prefix = '')
{
$locales = [];
foreach ($this->getLocalesFiles($prefix) as $file) {
$locales[] = \substr($file, \strrpos($file, '/') + 1, -4);
}
return \array_unique(\array_merge($locales, \array_keys($this->messages)));
}
protected function translate(?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null) : string
{
if ($domain === null) {
$domain = 'messages';
}
$catalogue = $this->getCatalogue($locale);
$format = $this instanceof TranslatorStrongTypeInterface ? $this->getFromCatalogue($catalogue, (string) $id, $domain) : $this->getCatalogue($locale)->get((string) $id, $domain);
// @codeCoverageIgnore
if ($format instanceof Closure) {
// @codeCoverageIgnoreStart
try {
$count = (new ReflectionFunction($format))->getNumberOfRequiredParameters();
} catch (ReflectionException $exception) {
$count = 0;
}
// @codeCoverageIgnoreEnd
return $format(...\array_values($parameters), ...\array_fill(0, \max(0, $count - \count($parameters)), null));
}
return parent::trans($id, $parameters, $domain, $locale);
}
protected function loadMessagesFromFile($locale)
{
return isset($this->messages[$locale]) || $this->resetMessages($locale);
}
public function setMessages($locale, $messages)
{
$this->loadMessagesFromFile($locale);
$this->addResource('array', $messages, $locale);
$this->messages[$locale] = \array_merge($this->messages[$locale] ?? [], $messages);
return $this;
}
public function setTranslations($messages)
{
return $this->setMessages($this->getLocale(), $messages);
}
public function getMessages($locale = null)
{
return $locale === null ? $this->messages : $this->messages[$locale];
}
public function setLocale($locale)
{
$locale = \preg_replace_callback('/[-_]([a-z]{2,}|\\d{2,})/', function ($matches) {
// _2-letters or YUE is a region, _3+-letters is a variant
$upper = \strtoupper($matches[1]);
if ($upper === 'YUE' || $upper === 'ISO' || \strlen($upper) < 3) {
return "_{$upper}";
}
return '_' . \ucfirst($matches[1]);
}, \strtolower($locale));
$previousLocale = $this->getLocale();
if ($previousLocale === $locale && isset($this->messages[$locale])) {
return \true;
}
unset(static::$singletons[$previousLocale]);
if ($locale === 'auto') {
$completeLocale = \setlocale(\LC_TIME, '0');
$locale = \preg_replace('/^([^_.-]+).*$/', '$1', $completeLocale);
$locales = $this->getAvailableLocales($locale);
$completeLocaleChunks = \preg_split('/[_.-]+/', $completeLocale);
$getScore = function ($language) use($completeLocaleChunks) {
return self::compareChunkLists($completeLocaleChunks, \preg_split('/[_.-]+/', $language));
};
\usort($locales, function ($first, $second) use($getScore) {
return $getScore($second) <=> $getScore($first);
});
$locale = $locales[0];
}
if (isset($this->aliases[$locale])) {
$locale = $this->aliases[$locale];
}
// If subtag (ex: en_CA) first load the macro (ex: en) to have a fallback
if (\str_contains($locale, '_') && $this->loadMessagesFromFile($macroLocale = \preg_replace('/^([^_]+).*$/', '$1', $locale))) {
parent::setLocale($macroLocale);
}
if (!$this->loadMessagesFromFile($locale) && !$this->initializing) {
return \false;
}
parent::setLocale($locale);
return \true;
}
public function __debugInfo()
{
return ['locale' => $this->getLocale()];
}
private static function compareChunkLists($referenceChunks, $chunks)
{
$score = 0;
foreach ($referenceChunks as $index => $chunk) {
if (!isset($chunks[$index])) {
$score++;
continue;
}
if (\strtolower($chunks[$index]) === \strtolower($chunk)) {
$score += 10;
}
}
return $score;
}
}
@@ -0,0 +1,519 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Traits\Date;
use MailPoetVendor\Carbon\Traits\DeprecatedProperties;
use DateTime;
use DateTimeInterface;
use DateTimeZone;
/**
* A simple API extension for DateTime.
*
*
*
* <autodoc generated by `composer phpdoc`>
*
* @property int $year
* @property int $yearIso
* @property int $month
* @property int $day
* @property int $hour
* @property int $minute
* @property int $second
* @property int $micro
* @property int $microsecond
* @property int|float|string $timestamp seconds since the Unix Epoch
* @property string $englishDayOfWeek the day of week in English
* @property string $shortEnglishDayOfWeek the abbreviated day of week in English
* @property string $englishMonth the month in English
* @property string $shortEnglishMonth the abbreviated month in English
* @property int $milliseconds
* @property int $millisecond
* @property int $milli
* @property int $week 1 through 53
* @property int $isoWeek 1 through 53
* @property int $weekYear year according to week format
* @property int $isoWeekYear year according to ISO week format
* @property int $dayOfYear 1 through 366
* @property int $age does a diffInYears() with default parameters
* @property int $offset the timezone offset in seconds from UTC
* @property int $offsetMinutes the timezone offset in minutes from UTC
* @property int $offsetHours the timezone offset in hours from UTC
* @property CarbonTimeZone $timezone the current timezone
* @property CarbonTimeZone $tz alias of $timezone
* @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday)
* @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday)
* @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday
* @property-read int $daysInMonth number of days in the given month
* @property-read string $latinMeridiem "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark)
* @property-read string $latinUpperMeridiem "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark)
* @property-read string $timezoneAbbreviatedName the current timezone abbreviated name
* @property-read string $tzAbbrName alias of $timezoneAbbreviatedName
* @property-read string $dayName long name of weekday translated according to Carbon locale, in english if no translation available for current language
* @property-read string $shortDayName short name of weekday translated according to Carbon locale, in english if no translation available for current language
* @property-read string $minDayName very short name of weekday translated according to Carbon locale, in english if no translation available for current language
* @property-read string $monthName long name of month translated according to Carbon locale, in english if no translation available for current language
* @property-read string $shortMonthName short name of month translated according to Carbon locale, in english if no translation available for current language
* @property-read string $meridiem lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
* @property-read string $upperMeridiem uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
* @property-read int $noZeroHour current hour from 1 to 24
* @property-read int $weeksInYear 51 through 53
* @property-read int $isoWeeksInYear 51 through 53
* @property-read int $weekOfMonth 1 through 5
* @property-read int $weekNumberInMonth 1 through 5
* @property-read int $firstWeekDay 0 through 6
* @property-read int $lastWeekDay 0 through 6
* @property-read int $daysInYear 365 or 366
* @property-read int $quarter the quarter of this instance, 1 - 4
* @property-read int $decade the decade of this instance
* @property-read int $century the century of this instance
* @property-read int $millennium the millennium of this instance
* @property-read bool $dst daylight savings time indicator, true if DST, false otherwise
* @property-read bool $local checks if the timezone is local, true if local, false otherwise
* @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise
* @property-read string $timezoneName the current timezone name
* @property-read string $tzName alias of $timezoneName
* @property-read string $locale locale of the current instance
*
* @method bool isUtc() Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.)
* @method bool isLocal() Check if the current instance has non-UTC timezone.
* @method bool isValid() Check if the current instance is a valid date.
* @method bool isDST() Check if the current instance is in a daylight saving time.
* @method bool isSunday() Checks if the instance day is sunday.
* @method bool isMonday() Checks if the instance day is monday.
* @method bool isTuesday() Checks if the instance day is tuesday.
* @method bool isWednesday() Checks if the instance day is wednesday.
* @method bool isThursday() Checks if the instance day is thursday.
* @method bool isFriday() Checks if the instance day is friday.
* @method bool isSaturday() Checks if the instance day is saturday.
* @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).
* @method bool isCurrentYear() Checks if the instance is in the same year as the current moment.
* @method bool isNextYear() Checks if the instance is in the same year as the current moment next year.
* @method bool isLastYear() Checks if the instance is in the same year as the current moment last year.
* @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).
* @method bool isCurrentWeek() Checks if the instance is in the same week as the current moment.
* @method bool isNextWeek() Checks if the instance is in the same week as the current moment next week.
* @method bool isLastWeek() Checks if the instance is in the same week as the current moment last week.
* @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).
* @method bool isCurrentDay() Checks if the instance is in the same day as the current moment.
* @method bool isNextDay() Checks if the instance is in the same day as the current moment next day.
* @method bool isLastDay() Checks if the instance is in the same day as the current moment last day.
* @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).
* @method bool isCurrentHour() Checks if the instance is in the same hour as the current moment.
* @method bool isNextHour() Checks if the instance is in the same hour as the current moment next hour.
* @method bool isLastHour() Checks if the instance is in the same hour as the current moment last hour.
* @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).
* @method bool isCurrentMinute() Checks if the instance is in the same minute as the current moment.
* @method bool isNextMinute() Checks if the instance is in the same minute as the current moment next minute.
* @method bool isLastMinute() Checks if the instance is in the same minute as the current moment last minute.
* @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).
* @method bool isCurrentSecond() Checks if the instance is in the same second as the current moment.
* @method bool isNextSecond() Checks if the instance is in the same second as the current moment next second.
* @method bool isLastSecond() Checks if the instance is in the same second as the current moment last second.
* @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).
* @method bool isCurrentMicro() Checks if the instance is in the same microsecond as the current moment.
* @method bool isNextMicro() Checks if the instance is in the same microsecond as the current moment next microsecond.
* @method bool isLastMicro() Checks if the instance is in the same microsecond as the current moment last microsecond.
* @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).
* @method bool isCurrentMicrosecond() Checks if the instance is in the same microsecond as the current moment.
* @method bool isNextMicrosecond() Checks if the instance is in the same microsecond as the current moment next microsecond.
* @method bool isLastMicrosecond() Checks if the instance is in the same microsecond as the current moment last microsecond.
* @method bool isCurrentMonth() Checks if the instance is in the same month as the current moment.
* @method bool isNextMonth() Checks if the instance is in the same month as the current moment next month.
* @method bool isLastMonth() Checks if the instance is in the same month as the current moment last month.
* @method bool isCurrentQuarter() Checks if the instance is in the same quarter as the current moment.
* @method bool isNextQuarter() Checks if the instance is in the same quarter as the current moment next quarter.
* @method bool isLastQuarter() Checks if the instance is in the same quarter as the current moment last quarter.
* @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).
* @method bool isCurrentDecade() Checks if the instance is in the same decade as the current moment.
* @method bool isNextDecade() Checks if the instance is in the same decade as the current moment next decade.
* @method bool isLastDecade() Checks if the instance is in the same decade as the current moment last decade.
* @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).
* @method bool isCurrentCentury() Checks if the instance is in the same century as the current moment.
* @method bool isNextCentury() Checks if the instance is in the same century as the current moment next century.
* @method bool isLastCentury() Checks if the instance is in the same century as the current moment last century.
* @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).
* @method bool isCurrentMillennium() Checks if the instance is in the same millennium as the current moment.
* @method bool isNextMillennium() Checks if the instance is in the same millennium as the current moment next millennium.
* @method bool isLastMillennium() Checks if the instance is in the same millennium as the current moment last millennium.
* @method $this years(int $value) Set current instance year to the given value.
* @method $this year(int $value) Set current instance year to the given value.
* @method $this setYears(int $value) Set current instance year to the given value.
* @method $this setYear(int $value) Set current instance year to the given value.
* @method $this months(int $value) Set current instance month to the given value.
* @method $this month(int $value) Set current instance month to the given value.
* @method $this setMonths(int $value) Set current instance month to the given value.
* @method $this setMonth(int $value) Set current instance month to the given value.
* @method $this days(int $value) Set current instance day to the given value.
* @method $this day(int $value) Set current instance day to the given value.
* @method $this setDays(int $value) Set current instance day to the given value.
* @method $this setDay(int $value) Set current instance day to the given value.
* @method $this hours(int $value) Set current instance hour to the given value.
* @method $this hour(int $value) Set current instance hour to the given value.
* @method $this setHours(int $value) Set current instance hour to the given value.
* @method $this setHour(int $value) Set current instance hour to the given value.
* @method $this minutes(int $value) Set current instance minute to the given value.
* @method $this minute(int $value) Set current instance minute to the given value.
* @method $this setMinutes(int $value) Set current instance minute to the given value.
* @method $this setMinute(int $value) Set current instance minute to the given value.
* @method $this seconds(int $value) Set current instance second to the given value.
* @method $this second(int $value) Set current instance second to the given value.
* @method $this setSeconds(int $value) Set current instance second to the given value.
* @method $this setSecond(int $value) Set current instance second to the given value.
* @method $this millis(int $value) Set current instance millisecond to the given value.
* @method $this milli(int $value) Set current instance millisecond to the given value.
* @method $this setMillis(int $value) Set current instance millisecond to the given value.
* @method $this setMilli(int $value) Set current instance millisecond to the given value.
* @method $this milliseconds(int $value) Set current instance millisecond to the given value.
* @method $this millisecond(int $value) Set current instance millisecond to the given value.
* @method $this setMilliseconds(int $value) Set current instance millisecond to the given value.
* @method $this setMillisecond(int $value) Set current instance millisecond to the given value.
* @method $this micros(int $value) Set current instance microsecond to the given value.
* @method $this micro(int $value) Set current instance microsecond to the given value.
* @method $this setMicros(int $value) Set current instance microsecond to the given value.
* @method $this setMicro(int $value) Set current instance microsecond to the given value.
* @method $this microseconds(int $value) Set current instance microsecond to the given value.
* @method $this microsecond(int $value) Set current instance microsecond to the given value.
* @method $this setMicroseconds(int $value) Set current instance microsecond to the given value.
* @method $this setMicrosecond(int $value) Set current instance microsecond to the given value.
* @method $this addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval).
* @method $this addYear() Add one year to the instance (using date interval).
* @method $this subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval).
* @method $this subYear() Sub one year to the instance (using date interval).
* @method $this addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed.
* @method $this subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed.
* @method $this addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval).
* @method $this addMonth() Add one month to the instance (using date interval).
* @method $this subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval).
* @method $this subMonth() Sub one month to the instance (using date interval).
* @method $this addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed.
* @method $this subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed.
* @method $this addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval).
* @method $this addDay() Add one day to the instance (using date interval).
* @method $this subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval).
* @method $this subDay() Sub one day to the instance (using date interval).
* @method $this addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval).
* @method $this addHour() Add one hour to the instance (using date interval).
* @method $this subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval).
* @method $this subHour() Sub one hour to the instance (using date interval).
* @method $this addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval).
* @method $this addMinute() Add one minute to the instance (using date interval).
* @method $this subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval).
* @method $this subMinute() Sub one minute to the instance (using date interval).
* @method $this addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval).
* @method $this addSecond() Add one second to the instance (using date interval).
* @method $this subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval).
* @method $this subSecond() Sub one second to the instance (using date interval).
* @method $this addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval).
* @method $this addMilli() Add one millisecond to the instance (using date interval).
* @method $this subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval).
* @method $this subMilli() Sub one millisecond to the instance (using date interval).
* @method $this addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval).
* @method $this addMillisecond() Add one millisecond to the instance (using date interval).
* @method $this subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval).
* @method $this subMillisecond() Sub one millisecond to the instance (using date interval).
* @method $this addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval).
* @method $this addMicro() Add one microsecond to the instance (using date interval).
* @method $this subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval).
* @method $this subMicro() Sub one microsecond to the instance (using date interval).
* @method $this addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval).
* @method $this addMicrosecond() Add one microsecond to the instance (using date interval).
* @method $this subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval).
* @method $this subMicrosecond() Sub one microsecond to the instance (using date interval).
* @method $this addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval).
* @method $this addMillennium() Add one millennium to the instance (using date interval).
* @method $this subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval).
* @method $this subMillennium() Sub one millennium to the instance (using date interval).
* @method $this addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed.
* @method $this subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed.
* @method $this addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval).
* @method $this addCentury() Add one century to the instance (using date interval).
* @method $this subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval).
* @method $this subCentury() Sub one century to the instance (using date interval).
* @method $this addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed.
* @method $this subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed.
* @method $this addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval).
* @method $this addDecade() Add one decade to the instance (using date interval).
* @method $this subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval).
* @method $this subDecade() Sub one decade to the instance (using date interval).
* @method $this addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed.
* @method $this subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed.
* @method $this addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval).
* @method $this addQuarter() Add one quarter to the instance (using date interval).
* @method $this subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval).
* @method $this subQuarter() Sub one quarter to the instance (using date interval).
* @method $this addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed.
* @method $this subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method $this subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed.
* @method $this addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method $this subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method $this addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval).
* @method $this addWeek() Add one week to the instance (using date interval).
* @method $this subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval).
* @method $this subWeek() Sub one week to the instance (using date interval).
* @method $this addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval).
* @method $this addWeekday() Add one weekday to the instance (using date interval).
* @method $this subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval).
* @method $this subWeekday() Sub one weekday to the instance (using date interval).
* @method $this addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp).
* @method $this addRealMicro() Add one microsecond to the instance (using timestamp).
* @method $this subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp).
* @method $this subRealMicro() Sub one microsecond to the instance (using timestamp).
* @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.
* @method $this addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp).
* @method $this addRealMicrosecond() Add one microsecond to the instance (using timestamp).
* @method $this subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp).
* @method $this subRealMicrosecond() Sub one microsecond to the instance (using timestamp).
* @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.
* @method $this addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp).
* @method $this addRealMilli() Add one millisecond to the instance (using timestamp).
* @method $this subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp).
* @method $this subRealMilli() Sub one millisecond to the instance (using timestamp).
* @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.
* @method $this addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp).
* @method $this addRealMillisecond() Add one millisecond to the instance (using timestamp).
* @method $this subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp).
* @method $this subRealMillisecond() Sub one millisecond to the instance (using timestamp).
* @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.
* @method $this addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp).
* @method $this addRealSecond() Add one second to the instance (using timestamp).
* @method $this subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp).
* @method $this subRealSecond() Sub one second to the instance (using timestamp).
* @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.
* @method $this addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp).
* @method $this addRealMinute() Add one minute to the instance (using timestamp).
* @method $this subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp).
* @method $this subRealMinute() Sub one minute to the instance (using timestamp).
* @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.
* @method $this addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp).
* @method $this addRealHour() Add one hour to the instance (using timestamp).
* @method $this subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp).
* @method $this subRealHour() Sub one hour to the instance (using timestamp).
* @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.
* @method $this addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp).
* @method $this addRealDay() Add one day to the instance (using timestamp).
* @method $this subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp).
* @method $this subRealDay() Sub one day to the instance (using timestamp).
* @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.
* @method $this addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp).
* @method $this addRealWeek() Add one week to the instance (using timestamp).
* @method $this subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp).
* @method $this subRealWeek() Sub one week to the instance (using timestamp).
* @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.
* @method $this addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp).
* @method $this addRealMonth() Add one month to the instance (using timestamp).
* @method $this subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp).
* @method $this subRealMonth() Sub one month to the instance (using timestamp).
* @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.
* @method $this addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp).
* @method $this addRealQuarter() Add one quarter to the instance (using timestamp).
* @method $this subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp).
* @method $this subRealQuarter() Sub one quarter to the instance (using timestamp).
* @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.
* @method $this addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp).
* @method $this addRealYear() Add one year to the instance (using timestamp).
* @method $this subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp).
* @method $this subRealYear() Sub one year to the instance (using timestamp).
* @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.
* @method $this addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp).
* @method $this addRealDecade() Add one decade to the instance (using timestamp).
* @method $this subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp).
* @method $this subRealDecade() Sub one decade to the instance (using timestamp).
* @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.
* @method $this addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp).
* @method $this addRealCentury() Add one century to the instance (using timestamp).
* @method $this subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp).
* @method $this subRealCentury() Sub one century to the instance (using timestamp).
* @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.
* @method $this addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp).
* @method $this addRealMillennium() Add one millennium to the instance (using timestamp).
* @method $this subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp).
* @method $this subRealMillennium() Sub one millennium to the instance (using timestamp).
* @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.
* @method $this roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
* @method $this roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
* @method $this floorYear(float $precision = 1) Truncate the current instance year with given precision.
* @method $this floorYears(float $precision = 1) Truncate the current instance year with given precision.
* @method $this ceilYear(float $precision = 1) Ceil the current instance year with given precision.
* @method $this ceilYears(float $precision = 1) Ceil the current instance year with given precision.
* @method $this roundMonth(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
* @method $this roundMonths(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
* @method $this floorMonth(float $precision = 1) Truncate the current instance month with given precision.
* @method $this floorMonths(float $precision = 1) Truncate the current instance month with given precision.
* @method $this ceilMonth(float $precision = 1) Ceil the current instance month with given precision.
* @method $this ceilMonths(float $precision = 1) Ceil the current instance month with given precision.
* @method $this roundDay(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
* @method $this roundDays(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
* @method $this floorDay(float $precision = 1) Truncate the current instance day with given precision.
* @method $this floorDays(float $precision = 1) Truncate the current instance day with given precision.
* @method $this ceilDay(float $precision = 1) Ceil the current instance day with given precision.
* @method $this ceilDays(float $precision = 1) Ceil the current instance day with given precision.
* @method $this roundHour(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
* @method $this roundHours(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
* @method $this floorHour(float $precision = 1) Truncate the current instance hour with given precision.
* @method $this floorHours(float $precision = 1) Truncate the current instance hour with given precision.
* @method $this ceilHour(float $precision = 1) Ceil the current instance hour with given precision.
* @method $this ceilHours(float $precision = 1) Ceil the current instance hour with given precision.
* @method $this roundMinute(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
* @method $this roundMinutes(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
* @method $this floorMinute(float $precision = 1) Truncate the current instance minute with given precision.
* @method $this floorMinutes(float $precision = 1) Truncate the current instance minute with given precision.
* @method $this ceilMinute(float $precision = 1) Ceil the current instance minute with given precision.
* @method $this ceilMinutes(float $precision = 1) Ceil the current instance minute with given precision.
* @method $this roundSecond(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
* @method $this roundSeconds(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
* @method $this floorSecond(float $precision = 1) Truncate the current instance second with given precision.
* @method $this floorSeconds(float $precision = 1) Truncate the current instance second with given precision.
* @method $this ceilSecond(float $precision = 1) Ceil the current instance second with given precision.
* @method $this ceilSeconds(float $precision = 1) Ceil the current instance second with given precision.
* @method $this roundMillennium(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
* @method $this roundMillennia(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
* @method $this floorMillennium(float $precision = 1) Truncate the current instance millennium with given precision.
* @method $this floorMillennia(float $precision = 1) Truncate the current instance millennium with given precision.
* @method $this ceilMillennium(float $precision = 1) Ceil the current instance millennium with given precision.
* @method $this ceilMillennia(float $precision = 1) Ceil the current instance millennium with given precision.
* @method $this roundCentury(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
* @method $this roundCenturies(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
* @method $this floorCentury(float $precision = 1) Truncate the current instance century with given precision.
* @method $this floorCenturies(float $precision = 1) Truncate the current instance century with given precision.
* @method $this ceilCentury(float $precision = 1) Ceil the current instance century with given precision.
* @method $this ceilCenturies(float $precision = 1) Ceil the current instance century with given precision.
* @method $this roundDecade(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
* @method $this roundDecades(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
* @method $this floorDecade(float $precision = 1) Truncate the current instance decade with given precision.
* @method $this floorDecades(float $precision = 1) Truncate the current instance decade with given precision.
* @method $this ceilDecade(float $precision = 1) Ceil the current instance decade with given precision.
* @method $this ceilDecades(float $precision = 1) Ceil the current instance decade with given precision.
* @method $this roundQuarter(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
* @method $this roundQuarters(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
* @method $this floorQuarter(float $precision = 1) Truncate the current instance quarter with given precision.
* @method $this floorQuarters(float $precision = 1) Truncate the current instance quarter with given precision.
* @method $this ceilQuarter(float $precision = 1) Ceil the current instance quarter with given precision.
* @method $this ceilQuarters(float $precision = 1) Ceil the current instance quarter with given precision.
* @method $this roundMillisecond(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
* @method $this roundMilliseconds(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
* @method $this floorMillisecond(float $precision = 1) Truncate the current instance millisecond with given precision.
* @method $this floorMilliseconds(float $precision = 1) Truncate the current instance millisecond with given precision.
* @method $this ceilMillisecond(float $precision = 1) Ceil the current instance millisecond with given precision.
* @method $this ceilMilliseconds(float $precision = 1) Ceil the current instance millisecond with given precision.
* @method $this roundMicrosecond(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
* @method $this roundMicroseconds(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
* @method $this floorMicrosecond(float $precision = 1) Truncate the current instance microsecond with given precision.
* @method $this floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision.
* @method $this ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision.
* @method $this ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision.
* @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.)
* @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.)
* @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.)
* @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.)
* @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.)
* @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.)
* @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.)
* @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.)
* @method static static|false createFromFormat(string $format, string $time, DateTimeZone|string|false|null $timezone = null) Parse a string into a new Carbon object according to the specified format.
* @method static static __set_state(array $array) https://php.net/manual/en/datetime.set-state.php
*
* </autodoc>
*/
class Carbon extends DateTime implements CarbonInterface
{
use Date;
/**
* Returns true if the current class/instance is mutable.
*
* @return bool
*/
public static function isMutable()
{
return \true;
}
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use DateTimeInterface;
interface CarbonConverterInterface
{
public function convertDate(DateTimeInterface $dateTime, bool $negated = \false) : CarbonInterface;
}
@@ -0,0 +1,568 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Traits\Date;
use MailPoetVendor\Carbon\Traits\DeprecatedProperties;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
/**
* A simple API extension for DateTimeImmutable.
*
*
*
* <autodoc generated by `composer phpdoc`>
*
* @property int $year
* @property int $yearIso
* @property int $month
* @property int $day
* @property int $hour
* @property int $minute
* @property int $second
* @property int $micro
* @property int $microsecond
* @property int|float|string $timestamp seconds since the Unix Epoch
* @property string $englishDayOfWeek the day of week in English
* @property string $shortEnglishDayOfWeek the abbreviated day of week in English
* @property string $englishMonth the month in English
* @property string $shortEnglishMonth the abbreviated month in English
* @property int $milliseconds
* @property int $millisecond
* @property int $milli
* @property int $week 1 through 53
* @property int $isoWeek 1 through 53
* @property int $weekYear year according to week format
* @property int $isoWeekYear year according to ISO week format
* @property int $dayOfYear 1 through 366
* @property int $age does a diffInYears() with default parameters
* @property int $offset the timezone offset in seconds from UTC
* @property int $offsetMinutes the timezone offset in minutes from UTC
* @property int $offsetHours the timezone offset in hours from UTC
* @property CarbonTimeZone $timezone the current timezone
* @property CarbonTimeZone $tz alias of $timezone
* @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday)
* @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday)
* @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday
* @property-read int $daysInMonth number of days in the given month
* @property-read string $latinMeridiem "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark)
* @property-read string $latinUpperMeridiem "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark)
* @property-read string $timezoneAbbreviatedName the current timezone abbreviated name
* @property-read string $tzAbbrName alias of $timezoneAbbreviatedName
* @property-read string $dayName long name of weekday translated according to Carbon locale, in english if no translation available for current language
* @property-read string $shortDayName short name of weekday translated according to Carbon locale, in english if no translation available for current language
* @property-read string $minDayName very short name of weekday translated according to Carbon locale, in english if no translation available for current language
* @property-read string $monthName long name of month translated according to Carbon locale, in english if no translation available for current language
* @property-read string $shortMonthName short name of month translated according to Carbon locale, in english if no translation available for current language
* @property-read string $meridiem lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
* @property-read string $upperMeridiem uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
* @property-read int $noZeroHour current hour from 1 to 24
* @property-read int $weeksInYear 51 through 53
* @property-read int $isoWeeksInYear 51 through 53
* @property-read int $weekOfMonth 1 through 5
* @property-read int $weekNumberInMonth 1 through 5
* @property-read int $firstWeekDay 0 through 6
* @property-read int $lastWeekDay 0 through 6
* @property-read int $daysInYear 365 or 366
* @property-read int $quarter the quarter of this instance, 1 - 4
* @property-read int $decade the decade of this instance
* @property-read int $century the century of this instance
* @property-read int $millennium the millennium of this instance
* @property-read bool $dst daylight savings time indicator, true if DST, false otherwise
* @property-read bool $local checks if the timezone is local, true if local, false otherwise
* @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise
* @property-read string $timezoneName the current timezone name
* @property-read string $tzName alias of $timezoneName
* @property-read string $locale locale of the current instance
*
* @method bool isUtc() Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.)
* @method bool isLocal() Check if the current instance has non-UTC timezone.
* @method bool isValid() Check if the current instance is a valid date.
* @method bool isDST() Check if the current instance is in a daylight saving time.
* @method bool isSunday() Checks if the instance day is sunday.
* @method bool isMonday() Checks if the instance day is monday.
* @method bool isTuesday() Checks if the instance day is tuesday.
* @method bool isWednesday() Checks if the instance day is wednesday.
* @method bool isThursday() Checks if the instance day is thursday.
* @method bool isFriday() Checks if the instance day is friday.
* @method bool isSaturday() Checks if the instance day is saturday.
* @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).
* @method bool isCurrentYear() Checks if the instance is in the same year as the current moment.
* @method bool isNextYear() Checks if the instance is in the same year as the current moment next year.
* @method bool isLastYear() Checks if the instance is in the same year as the current moment last year.
* @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).
* @method bool isCurrentWeek() Checks if the instance is in the same week as the current moment.
* @method bool isNextWeek() Checks if the instance is in the same week as the current moment next week.
* @method bool isLastWeek() Checks if the instance is in the same week as the current moment last week.
* @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).
* @method bool isCurrentDay() Checks if the instance is in the same day as the current moment.
* @method bool isNextDay() Checks if the instance is in the same day as the current moment next day.
* @method bool isLastDay() Checks if the instance is in the same day as the current moment last day.
* @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).
* @method bool isCurrentHour() Checks if the instance is in the same hour as the current moment.
* @method bool isNextHour() Checks if the instance is in the same hour as the current moment next hour.
* @method bool isLastHour() Checks if the instance is in the same hour as the current moment last hour.
* @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).
* @method bool isCurrentMinute() Checks if the instance is in the same minute as the current moment.
* @method bool isNextMinute() Checks if the instance is in the same minute as the current moment next minute.
* @method bool isLastMinute() Checks if the instance is in the same minute as the current moment last minute.
* @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).
* @method bool isCurrentSecond() Checks if the instance is in the same second as the current moment.
* @method bool isNextSecond() Checks if the instance is in the same second as the current moment next second.
* @method bool isLastSecond() Checks if the instance is in the same second as the current moment last second.
* @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).
* @method bool isCurrentMicro() Checks if the instance is in the same microsecond as the current moment.
* @method bool isNextMicro() Checks if the instance is in the same microsecond as the current moment next microsecond.
* @method bool isLastMicro() Checks if the instance is in the same microsecond as the current moment last microsecond.
* @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).
* @method bool isCurrentMicrosecond() Checks if the instance is in the same microsecond as the current moment.
* @method bool isNextMicrosecond() Checks if the instance is in the same microsecond as the current moment next microsecond.
* @method bool isLastMicrosecond() Checks if the instance is in the same microsecond as the current moment last microsecond.
* @method bool isCurrentMonth() Checks if the instance is in the same month as the current moment.
* @method bool isNextMonth() Checks if the instance is in the same month as the current moment next month.
* @method bool isLastMonth() Checks if the instance is in the same month as the current moment last month.
* @method bool isCurrentQuarter() Checks if the instance is in the same quarter as the current moment.
* @method bool isNextQuarter() Checks if the instance is in the same quarter as the current moment next quarter.
* @method bool isLastQuarter() Checks if the instance is in the same quarter as the current moment last quarter.
* @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).
* @method bool isCurrentDecade() Checks if the instance is in the same decade as the current moment.
* @method bool isNextDecade() Checks if the instance is in the same decade as the current moment next decade.
* @method bool isLastDecade() Checks if the instance is in the same decade as the current moment last decade.
* @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).
* @method bool isCurrentCentury() Checks if the instance is in the same century as the current moment.
* @method bool isNextCentury() Checks if the instance is in the same century as the current moment next century.
* @method bool isLastCentury() Checks if the instance is in the same century as the current moment last century.
* @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).
* @method bool isCurrentMillennium() Checks if the instance is in the same millennium as the current moment.
* @method bool isNextMillennium() Checks if the instance is in the same millennium as the current moment next millennium.
* @method bool isLastMillennium() Checks if the instance is in the same millennium as the current moment last millennium.
* @method CarbonImmutable years(int $value) Set current instance year to the given value.
* @method CarbonImmutable year(int $value) Set current instance year to the given value.
* @method CarbonImmutable setYears(int $value) Set current instance year to the given value.
* @method CarbonImmutable setYear(int $value) Set current instance year to the given value.
* @method CarbonImmutable months(int $value) Set current instance month to the given value.
* @method CarbonImmutable month(int $value) Set current instance month to the given value.
* @method CarbonImmutable setMonths(int $value) Set current instance month to the given value.
* @method CarbonImmutable setMonth(int $value) Set current instance month to the given value.
* @method CarbonImmutable days(int $value) Set current instance day to the given value.
* @method CarbonImmutable day(int $value) Set current instance day to the given value.
* @method CarbonImmutable setDays(int $value) Set current instance day to the given value.
* @method CarbonImmutable setDay(int $value) Set current instance day to the given value.
* @method CarbonImmutable hours(int $value) Set current instance hour to the given value.
* @method CarbonImmutable hour(int $value) Set current instance hour to the given value.
* @method CarbonImmutable setHours(int $value) Set current instance hour to the given value.
* @method CarbonImmutable setHour(int $value) Set current instance hour to the given value.
* @method CarbonImmutable minutes(int $value) Set current instance minute to the given value.
* @method CarbonImmutable minute(int $value) Set current instance minute to the given value.
* @method CarbonImmutable setMinutes(int $value) Set current instance minute to the given value.
* @method CarbonImmutable setMinute(int $value) Set current instance minute to the given value.
* @method CarbonImmutable seconds(int $value) Set current instance second to the given value.
* @method CarbonImmutable second(int $value) Set current instance second to the given value.
* @method CarbonImmutable setSeconds(int $value) Set current instance second to the given value.
* @method CarbonImmutable setSecond(int $value) Set current instance second to the given value.
* @method CarbonImmutable millis(int $value) Set current instance millisecond to the given value.
* @method CarbonImmutable milli(int $value) Set current instance millisecond to the given value.
* @method CarbonImmutable setMillis(int $value) Set current instance millisecond to the given value.
* @method CarbonImmutable setMilli(int $value) Set current instance millisecond to the given value.
* @method CarbonImmutable milliseconds(int $value) Set current instance millisecond to the given value.
* @method CarbonImmutable millisecond(int $value) Set current instance millisecond to the given value.
* @method CarbonImmutable setMilliseconds(int $value) Set current instance millisecond to the given value.
* @method CarbonImmutable setMillisecond(int $value) Set current instance millisecond to the given value.
* @method CarbonImmutable micros(int $value) Set current instance microsecond to the given value.
* @method CarbonImmutable micro(int $value) Set current instance microsecond to the given value.
* @method CarbonImmutable setMicros(int $value) Set current instance microsecond to the given value.
* @method CarbonImmutable setMicro(int $value) Set current instance microsecond to the given value.
* @method CarbonImmutable microseconds(int $value) Set current instance microsecond to the given value.
* @method CarbonImmutable microsecond(int $value) Set current instance microsecond to the given value.
* @method CarbonImmutable setMicroseconds(int $value) Set current instance microsecond to the given value.
* @method CarbonImmutable setMicrosecond(int $value) Set current instance microsecond to the given value.
* @method CarbonImmutable addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addYear() Add one year to the instance (using date interval).
* @method CarbonImmutable subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subYear() Sub one year to the instance (using date interval).
* @method CarbonImmutable addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addMonth() Add one month to the instance (using date interval).
* @method CarbonImmutable subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subMonth() Sub one month to the instance (using date interval).
* @method CarbonImmutable addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addDay() Add one day to the instance (using date interval).
* @method CarbonImmutable subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subDay() Sub one day to the instance (using date interval).
* @method CarbonImmutable addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addHour() Add one hour to the instance (using date interval).
* @method CarbonImmutable subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subHour() Sub one hour to the instance (using date interval).
* @method CarbonImmutable addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addMinute() Add one minute to the instance (using date interval).
* @method CarbonImmutable subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subMinute() Sub one minute to the instance (using date interval).
* @method CarbonImmutable addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addSecond() Add one second to the instance (using date interval).
* @method CarbonImmutable subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subSecond() Sub one second to the instance (using date interval).
* @method CarbonImmutable addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addMilli() Add one millisecond to the instance (using date interval).
* @method CarbonImmutable subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subMilli() Sub one millisecond to the instance (using date interval).
* @method CarbonImmutable addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addMillisecond() Add one millisecond to the instance (using date interval).
* @method CarbonImmutable subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subMillisecond() Sub one millisecond to the instance (using date interval).
* @method CarbonImmutable addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addMicro() Add one microsecond to the instance (using date interval).
* @method CarbonImmutable subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subMicro() Sub one microsecond to the instance (using date interval).
* @method CarbonImmutable addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addMicrosecond() Add one microsecond to the instance (using date interval).
* @method CarbonImmutable subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subMicrosecond() Sub one microsecond to the instance (using date interval).
* @method CarbonImmutable addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addMillennium() Add one millennium to the instance (using date interval).
* @method CarbonImmutable subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subMillennium() Sub one millennium to the instance (using date interval).
* @method CarbonImmutable addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addCentury() Add one century to the instance (using date interval).
* @method CarbonImmutable subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subCentury() Sub one century to the instance (using date interval).
* @method CarbonImmutable addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addDecade() Add one decade to the instance (using date interval).
* @method CarbonImmutable subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subDecade() Sub one decade to the instance (using date interval).
* @method CarbonImmutable addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addQuarter() Add one quarter to the instance (using date interval).
* @method CarbonImmutable subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subQuarter() Sub one quarter to the instance (using date interval).
* @method CarbonImmutable addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed.
* @method CarbonImmutable addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
* @method CarbonImmutable addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addWeek() Add one week to the instance (using date interval).
* @method CarbonImmutable subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subWeek() Sub one week to the instance (using date interval).
* @method CarbonImmutable addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable addWeekday() Add one weekday to the instance (using date interval).
* @method CarbonImmutable subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval).
* @method CarbonImmutable subWeekday() Sub one weekday to the instance (using date interval).
* @method CarbonImmutable addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealMicro() Add one microsecond to the instance (using timestamp).
* @method CarbonImmutable subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealMicro() Sub one microsecond to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealMicrosecond() Add one microsecond to the instance (using timestamp).
* @method CarbonImmutable subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealMicrosecond() Sub one microsecond to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealMilli() Add one millisecond to the instance (using timestamp).
* @method CarbonImmutable subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealMilli() Sub one millisecond to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealMillisecond() Add one millisecond to the instance (using timestamp).
* @method CarbonImmutable subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealMillisecond() Sub one millisecond to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealSecond() Add one second to the instance (using timestamp).
* @method CarbonImmutable subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealSecond() Sub one second to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealMinute() Add one minute to the instance (using timestamp).
* @method CarbonImmutable subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealMinute() Sub one minute to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealHour() Add one hour to the instance (using timestamp).
* @method CarbonImmutable subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealHour() Sub one hour to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealDay() Add one day to the instance (using timestamp).
* @method CarbonImmutable subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealDay() Sub one day to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealWeek() Add one week to the instance (using timestamp).
* @method CarbonImmutable subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealWeek() Sub one week to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealMonth() Add one month to the instance (using timestamp).
* @method CarbonImmutable subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealMonth() Sub one month to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealQuarter() Add one quarter to the instance (using timestamp).
* @method CarbonImmutable subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealQuarter() Sub one quarter to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealYear() Add one year to the instance (using timestamp).
* @method CarbonImmutable subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealYear() Sub one year to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealDecade() Add one decade to the instance (using timestamp).
* @method CarbonImmutable subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealDecade() Sub one decade to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealCentury() Add one century to the instance (using timestamp).
* @method CarbonImmutable subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealCentury() Sub one century to the instance (using timestamp).
* @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.
* @method CarbonImmutable addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable addRealMillennium() Add one millennium to the instance (using timestamp).
* @method CarbonImmutable subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp).
* @method CarbonImmutable subRealMillennium() Sub one millennium to the instance (using timestamp).
* @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.
* @method CarbonImmutable roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
* @method CarbonImmutable roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
* @method CarbonImmutable floorYear(float $precision = 1) Truncate the current instance year with given precision.
* @method CarbonImmutable floorYears(float $precision = 1) Truncate the current instance year with given precision.
* @method CarbonImmutable ceilYear(float $precision = 1) Ceil the current instance year with given precision.
* @method CarbonImmutable ceilYears(float $precision = 1) Ceil the current instance year with given precision.
* @method CarbonImmutable roundMonth(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
* @method CarbonImmutable roundMonths(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
* @method CarbonImmutable floorMonth(float $precision = 1) Truncate the current instance month with given precision.
* @method CarbonImmutable floorMonths(float $precision = 1) Truncate the current instance month with given precision.
* @method CarbonImmutable ceilMonth(float $precision = 1) Ceil the current instance month with given precision.
* @method CarbonImmutable ceilMonths(float $precision = 1) Ceil the current instance month with given precision.
* @method CarbonImmutable roundDay(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
* @method CarbonImmutable roundDays(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
* @method CarbonImmutable floorDay(float $precision = 1) Truncate the current instance day with given precision.
* @method CarbonImmutable floorDays(float $precision = 1) Truncate the current instance day with given precision.
* @method CarbonImmutable ceilDay(float $precision = 1) Ceil the current instance day with given precision.
* @method CarbonImmutable ceilDays(float $precision = 1) Ceil the current instance day with given precision.
* @method CarbonImmutable roundHour(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
* @method CarbonImmutable roundHours(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
* @method CarbonImmutable floorHour(float $precision = 1) Truncate the current instance hour with given precision.
* @method CarbonImmutable floorHours(float $precision = 1) Truncate the current instance hour with given precision.
* @method CarbonImmutable ceilHour(float $precision = 1) Ceil the current instance hour with given precision.
* @method CarbonImmutable ceilHours(float $precision = 1) Ceil the current instance hour with given precision.
* @method CarbonImmutable roundMinute(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
* @method CarbonImmutable roundMinutes(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
* @method CarbonImmutable floorMinute(float $precision = 1) Truncate the current instance minute with given precision.
* @method CarbonImmutable floorMinutes(float $precision = 1) Truncate the current instance minute with given precision.
* @method CarbonImmutable ceilMinute(float $precision = 1) Ceil the current instance minute with given precision.
* @method CarbonImmutable ceilMinutes(float $precision = 1) Ceil the current instance minute with given precision.
* @method CarbonImmutable roundSecond(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
* @method CarbonImmutable roundSeconds(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
* @method CarbonImmutable floorSecond(float $precision = 1) Truncate the current instance second with given precision.
* @method CarbonImmutable floorSeconds(float $precision = 1) Truncate the current instance second with given precision.
* @method CarbonImmutable ceilSecond(float $precision = 1) Ceil the current instance second with given precision.
* @method CarbonImmutable ceilSeconds(float $precision = 1) Ceil the current instance second with given precision.
* @method CarbonImmutable roundMillennium(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
* @method CarbonImmutable roundMillennia(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
* @method CarbonImmutable floorMillennium(float $precision = 1) Truncate the current instance millennium with given precision.
* @method CarbonImmutable floorMillennia(float $precision = 1) Truncate the current instance millennium with given precision.
* @method CarbonImmutable ceilMillennium(float $precision = 1) Ceil the current instance millennium with given precision.
* @method CarbonImmutable ceilMillennia(float $precision = 1) Ceil the current instance millennium with given precision.
* @method CarbonImmutable roundCentury(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
* @method CarbonImmutable roundCenturies(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
* @method CarbonImmutable floorCentury(float $precision = 1) Truncate the current instance century with given precision.
* @method CarbonImmutable floorCenturies(float $precision = 1) Truncate the current instance century with given precision.
* @method CarbonImmutable ceilCentury(float $precision = 1) Ceil the current instance century with given precision.
* @method CarbonImmutable ceilCenturies(float $precision = 1) Ceil the current instance century with given precision.
* @method CarbonImmutable roundDecade(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
* @method CarbonImmutable roundDecades(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
* @method CarbonImmutable floorDecade(float $precision = 1) Truncate the current instance decade with given precision.
* @method CarbonImmutable floorDecades(float $precision = 1) Truncate the current instance decade with given precision.
* @method CarbonImmutable ceilDecade(float $precision = 1) Ceil the current instance decade with given precision.
* @method CarbonImmutable ceilDecades(float $precision = 1) Ceil the current instance decade with given precision.
* @method CarbonImmutable roundQuarter(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
* @method CarbonImmutable roundQuarters(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
* @method CarbonImmutable floorQuarter(float $precision = 1) Truncate the current instance quarter with given precision.
* @method CarbonImmutable floorQuarters(float $precision = 1) Truncate the current instance quarter with given precision.
* @method CarbonImmutable ceilQuarter(float $precision = 1) Ceil the current instance quarter with given precision.
* @method CarbonImmutable ceilQuarters(float $precision = 1) Ceil the current instance quarter with given precision.
* @method CarbonImmutable roundMillisecond(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
* @method CarbonImmutable roundMilliseconds(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
* @method CarbonImmutable floorMillisecond(float $precision = 1) Truncate the current instance millisecond with given precision.
* @method CarbonImmutable floorMilliseconds(float $precision = 1) Truncate the current instance millisecond with given precision.
* @method CarbonImmutable ceilMillisecond(float $precision = 1) Ceil the current instance millisecond with given precision.
* @method CarbonImmutable ceilMilliseconds(float $precision = 1) Ceil the current instance millisecond with given precision.
* @method CarbonImmutable roundMicrosecond(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
* @method CarbonImmutable roundMicroseconds(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
* @method CarbonImmutable floorMicrosecond(float $precision = 1) Truncate the current instance microsecond with given precision.
* @method CarbonImmutable floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision.
* @method CarbonImmutable ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision.
* @method CarbonImmutable ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision.
* @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.)
* @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.)
* @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.)
* @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.)
* @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.)
* @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.)
* @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.)
* @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.)
* @method static static|false createFromFormat(string $format, string $time, DateTimeZone|string|false|null $timezone = null) Parse a string into a new CarbonImmutable object according to the specified format.
* @method static static __set_state(array $array) https://php.net/manual/en/datetime.set-state.php
*
* </autodoc>
*/
class CarbonImmutable extends DateTimeImmutable implements CarbonInterface
{
use Date {
__clone as dateTraitClone;
}
public function __clone()
{
$this->dateTraitClone();
$this->endOfTime = \false;
$this->startOfTime = \false;
}
/**
* Create a very old date representing start of time.
*
* @return static
*/
public static function startOfTime() : self
{
$date = static::parse('0001-01-01')->years(self::getStartOfTimeYear());
$date->startOfTime = \true;
return $date;
}
/**
* Create a very far date representing end of time.
*
* @return static
*/
public static function endOfTime() : self
{
$date = static::parse('9999-12-31 23:59:59.999999')->years(self::getEndOfTimeYear());
$date->endOfTime = \true;
return $date;
}
/**
* @codeCoverageIgnore
*/
private static function getEndOfTimeYear() : int
{
if (\version_compare(\PHP_VERSION, '7.3.0-dev', '<')) {
return 145261681241552;
}
// Remove if https://bugs.php.net/bug.php?id=81107 is fixed
if (\version_compare(\PHP_VERSION, '8.1.0-dev', '>=')) {
return 1118290769066902787;
}
return \PHP_INT_MAX;
}
/**
* @codeCoverageIgnore
*/
private static function getStartOfTimeYear() : int
{
if (\version_compare(\PHP_VERSION, '7.3.0-dev', '<')) {
return -135908816449551;
}
// Remove if https://bugs.php.net/bug.php?id=81107 is fixed
if (\version_compare(\PHP_VERSION, '8.1.0-dev', '>=')) {
return -1118290769066898816;
}
return \max(\PHP_INT_MIN, -9223372036854773760);
}
}
@@ -0,0 +1,12 @@
<?php
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
class CarbonPeriodImmutable extends CarbonPeriod
{
protected const DEFAULT_DATE_CLASS = CarbonImmutable::class;
protected $dateClass = CarbonImmutable::class;
protected function copyIfImmutable()
{
return $this->constructed ? clone $this : $this;
}
}
@@ -0,0 +1,157 @@
<?php
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Exceptions\InvalidCastException;
use MailPoetVendor\Carbon\Exceptions\InvalidTimeZoneException;
use DateTimeInterface;
use DateTimeZone;
use Throwable;
class CarbonTimeZone extends DateTimeZone
{
public function __construct($timezone = null)
{
parent::__construct(static::getDateTimeZoneNameFromMixed($timezone));
}
protected static function parseNumericTimezone($timezone)
{
if ($timezone <= -100 || $timezone >= 100) {
throw new InvalidTimeZoneException('Absolute timezone offset cannot be greater than 100.');
}
return ($timezone >= 0 ? '+' : '') . \ltrim($timezone, '+') . ':00';
}
protected static function getDateTimeZoneNameFromMixed($timezone)
{
if ($timezone === null) {
return \date_default_timezone_get();
}
if (\is_string($timezone)) {
$timezone = \preg_replace('/^\\s*([+-]\\d+)(\\d{2})\\s*$/', '$1:$2', $timezone);
}
if (\is_numeric($timezone)) {
return static::parseNumericTimezone($timezone);
}
return $timezone;
}
protected static function getDateTimeZoneFromName(&$name)
{
return @\timezone_open($name = (string) static::getDateTimeZoneNameFromMixed($name));
}
public function cast(string $className)
{
if (!\method_exists($className, 'instance')) {
if (\is_a($className, DateTimeZone::class, \true)) {
return new $className($this->getName());
}
throw new InvalidCastException("{$className} has not the instance() method needed to cast the date.");
}
return $className::instance($this);
}
public static function instance($object = null, $objectDump = null)
{
$tz = $object;
if ($tz instanceof static) {
return $tz;
}
if ($tz === null) {
return new static();
}
if (!$tz instanceof DateTimeZone) {
$tz = static::getDateTimeZoneFromName($object);
}
if ($tz !== \false) {
return new static($tz->getName());
}
if (Carbon::isStrictModeEnabled()) {
throw new InvalidTimeZoneException('Unknown or bad timezone (' . ($objectDump ?: $object) . ')');
}
return \false;
}
public function getAbbreviatedName($dst = \false)
{
$name = $this->getName();
foreach ($this->listAbbreviations() as $abbreviation => $zones) {
foreach ($zones as $zone) {
if ($zone['timezone_id'] === $name && $zone['dst'] == $dst) {
return $abbreviation;
}
}
}
return 'unknown';
}
public function getAbbr($dst = \false)
{
return $this->getAbbreviatedName($dst);
}
public function toOffsetName(DateTimeInterface $date = null)
{
return static::getOffsetNameFromMinuteOffset($this->getOffset($date ?: Carbon::now($this)) / 60);
}
public function toOffsetTimeZone(DateTimeInterface $date = null)
{
return new static($this->toOffsetName($date));
}
public function toRegionName(DateTimeInterface $date = null, $isDst = 1)
{
$name = $this->getName();
$firstChar = \substr($name, 0, 1);
if ($firstChar !== '+' && $firstChar !== '-') {
return $name;
}
$date = $date ?: Carbon::now($this);
// Integer construction no longer supported since PHP 8
// @codeCoverageIgnoreStart
try {
$offset = @$this->getOffset($date) ?: 0;
} catch (Throwable $e) {
$offset = 0;
}
// @codeCoverageIgnoreEnd
$name = @\timezone_name_from_abbr('', $offset, $isDst);
if ($name) {
return $name;
}
foreach (\timezone_identifiers_list() as $timezone) {
if (Carbon::instance($date)->tz($timezone)->getOffset() === $offset) {
return $timezone;
}
}
return \false;
}
public function toRegionTimeZone(DateTimeInterface $date = null)
{
$tz = $this->toRegionName($date);
if ($tz !== \false) {
return new static($tz);
}
if (Carbon::isStrictModeEnabled()) {
throw new InvalidTimeZoneException('Unknown timezone for offset ' . $this->getOffset($date ?: Carbon::now($this)) . ' seconds.');
}
return \false;
}
public function __toString()
{
return $this->getName();
}
public function getType() : int
{
return \preg_match('/"timezone_type";i:(\\d)/', \serialize($this), $match) ? (int) $match[1] : 3;
}
public static function create($object = null)
{
return static::instance($object);
}
public static function createFromHourOffset(float $hourOffset)
{
return static::createFromMinuteOffset($hourOffset * Carbon::MINUTES_PER_HOUR);
}
public static function createFromMinuteOffset(float $minuteOffset)
{
return static::instance(static::getOffsetNameFromMinuteOffset($minuteOffset));
}
public static function getOffsetNameFromMinuteOffset(float $minutes) : string
{
$minutes = \round($minutes);
$unsignedMinutes = \abs($minutes);
return ($minutes < 0 ? '-' : '+') . \str_pad((string) \floor($unsignedMinutes / 60), 2, '0', \STR_PAD_LEFT) . ':' . \str_pad((string) ($unsignedMinutes % 60), 2, '0', \STR_PAD_LEFT);
}
}
@@ -0,0 +1,17 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use Throwable;
class BadComparisonUnitException extends UnitException
{
protected $unit;
public function __construct($unit, $code = 0, Throwable $previous = null)
{
$this->unit = $unit;
parent::__construct("Bad comparison unit: '{$unit}'", $code, $previous);
}
public function getUnit() : string
{
return $this->unit;
}
}
@@ -0,0 +1,18 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use BadMethodCallException as BaseBadMethodCallException;
use Throwable;
class BadFluentConstructorException extends BaseBadMethodCallException implements BadMethodCallException
{
protected $method;
public function __construct($method, $code = 0, Throwable $previous = null)
{
$this->method = $method;
parent::__construct(\sprintf("Unknown fluent constructor '%s'.", $method), $code, $previous);
}
public function getMethod() : string
{
return $this->method;
}
}
@@ -0,0 +1,18 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use BadMethodCallException as BaseBadMethodCallException;
use Throwable;
class BadFluentSetterException extends BaseBadMethodCallException implements BadMethodCallException
{
protected $setter;
public function __construct($setter, $code = 0, Throwable $previous = null)
{
$this->setter = $setter;
parent::__construct(\sprintf("Unknown fluent setter '%s'", $setter), $code, $previous);
}
public function getSetter() : string
{
return $this->setter;
}
}
@@ -0,0 +1,7 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
interface BadMethodCallException extends Exception
{
//
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use RuntimeException as BaseRuntimeException;
final class EndLessPeriodException extends BaseRuntimeException implements RuntimeException
{
//
}
@@ -0,0 +1,7 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
interface Exception
{
//
}
@@ -0,0 +1,18 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use RuntimeException as BaseRuntimeException;
use Throwable;
class ImmutableException extends BaseRuntimeException implements RuntimeException
{
protected $value;
public function __construct($value, $code = 0, Throwable $previous = null)
{
$this->value = $value;
parent::__construct("{$value} is immutable.", $code, $previous);
}
public function getValue() : string
{
return $this->value;
}
}
@@ -0,0 +1,7 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
interface InvalidArgumentException extends Exception
{
//
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
class InvalidCastException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}
@@ -0,0 +1,24 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
use Throwable;
class InvalidDateException extends BaseInvalidArgumentException implements InvalidArgumentException
{
private $field;
private $value;
public function __construct($field, $value, $code = 0, Throwable $previous = null)
{
$this->field = $field;
$this->value = $value;
parent::__construct($field . ' : ' . $value . ' is not a valid value.', $code, $previous);
}
public function getField()
{
return $this->field;
}
public function getValue()
{
return $this->value;
}
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
class InvalidFormatException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
class InvalidIntervalException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
class InvalidPeriodDateException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
class InvalidPeriodParameterException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
class InvalidTimeZoneException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
class InvalidTypeException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}
@@ -0,0 +1,19 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\CarbonInterface;
use InvalidArgumentException as BaseInvalidArgumentException;
use Throwable;
class NotACarbonClassException extends BaseInvalidArgumentException implements InvalidArgumentException
{
protected $className;
public function __construct($className, $code = 0, Throwable $previous = null)
{
$this->className = $className;
parent::__construct(\sprintf('Given class does not implement %s: %s', CarbonInterface::class, $className), $code, $previous);
}
public function getClassName() : string
{
return $this->className;
}
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
class NotAPeriodException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}
@@ -0,0 +1,13 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
use Throwable;
class NotLocaleAwareException extends BaseInvalidArgumentException implements InvalidArgumentException
{
public function __construct($object, $code = 0, Throwable $previous = null)
{
$dump = \is_object($object) ? \get_class($object) : \gettype($object);
parent::__construct("{$dump} does neither implements Symfony\\Contracts\\Translation\\LocaleAwareInterface nor getLocale() method.", $code, $previous);
}
}
@@ -0,0 +1,38 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
use Throwable;
// This will extends OutOfRangeException instead of InvalidArgumentException since 3.0.0
// use OutOfRangeException as BaseOutOfRangeException;
class OutOfRangeException extends BaseInvalidArgumentException implements InvalidArgumentException
{
private $unit;
private $min;
private $max;
private $value;
public function __construct($unit, $min, $max, $value, $code = 0, Throwable $previous = null)
{
$this->unit = $unit;
$this->min = $min;
$this->max = $max;
$this->value = $value;
parent::__construct("{$unit} must be between {$min} and {$max}, {$value} given", $code, $previous);
}
public function getMax()
{
return $this->max;
}
public function getMin()
{
return $this->min;
}
public function getUnit()
{
return $this->unit;
}
public function getValue()
{
return $this->value;
}
}
@@ -0,0 +1,31 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
use Throwable;
class ParseErrorException extends BaseInvalidArgumentException implements InvalidArgumentException
{
protected $expected;
protected $actual;
protected $help;
public function __construct($expected, $actual, $help = '', $code = 0, Throwable $previous = null)
{
$this->expected = $expected;
$this->actual = $actual;
$this->help = $help;
$actual = $actual === '' ? 'data is missing' : "get '{$actual}'";
parent::__construct(\trim("Format expected {$expected} but {$actual}\n{$help}"), $code, $previous);
}
public function getExpected() : string
{
return $this->expected;
}
public function getActual() : string
{
return $this->actual;
}
public function getHelp() : string
{
return $this->help;
}
}
@@ -0,0 +1,7 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
interface RuntimeException extends Exception
{
//
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
class UnitException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}
@@ -0,0 +1,17 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use Throwable;
class UnitNotConfiguredException extends UnitException
{
protected $unit;
public function __construct($unit, $code = 0, Throwable $previous = null)
{
$this->unit = $unit;
parent::__construct("Unit {$unit} have no configuration to get total from other units.", $code, $previous);
}
public function getUnit() : string
{
return $this->unit;
}
}
@@ -0,0 +1,18 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
use Throwable;
class UnknownGetterException extends BaseInvalidArgumentException implements InvalidArgumentException
{
protected $getter;
public function __construct($getter, $code = 0, Throwable $previous = null)
{
$this->getter = $getter;
parent::__construct("Unknown getter '{$getter}'", $code, $previous);
}
public function getGetter() : string
{
return $this->getter;
}
}
@@ -0,0 +1,18 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use BadMethodCallException as BaseBadMethodCallException;
use Throwable;
class UnknownMethodException extends BaseBadMethodCallException implements BadMethodCallException
{
protected $method;
public function __construct($method, $code = 0, Throwable $previous = null)
{
$this->method = $method;
parent::__construct("Method {$method} does not exist.", $code, $previous);
}
public function getMethod() : string
{
return $this->method;
}
}
@@ -0,0 +1,18 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use InvalidArgumentException as BaseInvalidArgumentException;
use Throwable;
class UnknownSetterException extends BaseInvalidArgumentException implements BadMethodCallException
{
protected $setter;
public function __construct($setter, $code = 0, Throwable $previous = null)
{
$this->setter = $setter;
parent::__construct("Unknown setter '{$setter}'", $code, $previous);
}
public function getSetter() : string
{
return $this->setter;
}
}
@@ -0,0 +1,17 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use Throwable;
class UnknownUnitException extends UnitException
{
protected $unit;
public function __construct($unit, $code = 0, Throwable $previous = null)
{
$this->unit = $unit;
parent::__construct("Unknown unit '{$unit}'.", $code, $previous);
}
public function getUnit() : string
{
return $this->unit;
}
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon\Exceptions;
if (!defined('ABSPATH')) exit;
use RuntimeException as BaseRuntimeException;
class UnreachableException extends BaseRuntimeException implements RuntimeException
{
//
}
@@ -0,0 +1,303 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use Closure;
use DateTimeInterface;
use ReflectionMethod;
/**
* A factory to generate Carbon instances with common settings.
*
* <autodoc generated by `composer phpdoc`>
*
* @method bool canBeCreatedFromFormat($date, $format) Checks if the (date)time string is in a given format and valid to create a
* new instance.
* @method Carbon|false create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) Create a new Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* @method Carbon createFromDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to now.
* @method Carbon|false createFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method Carbon|false createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null) Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
* @method Carbon|false createFromLocaleFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific format and a string in a given language.
* @method Carbon|false createFromLocaleIsoFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific ISO format and a string in a given language.
* @method Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null) Create a Carbon instance from just a time. The date portion is set to today.
* @method Carbon createFromTimeString($time, $tz = null) Create a Carbon instance from a time string. The date portion is set to today.
* @method Carbon createFromTimestamp($timestamp, $tz = null) Create a Carbon instance from a timestamp and set the timezone (use default one if not specified).
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createFromTimestampMs($timestamp, $tz = null) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createFromTimestampMsUTC($timestamp) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createFromTimestampUTC($timestamp) Create a Carbon instance from an timestamp keeping the timezone to UTC.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createMidnightDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to midnight.
* @method Carbon|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) Create a new safe Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* If one of the set values is not valid, an InvalidDateException
* will be thrown.
* @method CarbonInterface createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null) Create a new Carbon instance from a specific date and time using strict validation.
* @method Carbon disableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method Carbon enableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method mixed executeWithLocale($locale, $func) Set the current locale to the given, execute the passed function, reset the locale to previous one,
* then return the result of the closure (or null if the closure was void).
* @method Carbon fromSerialized($value) Create an instance from a serialized string.
* @method void genericMacro($macro, $priority = 0) Register a custom macro.
* @method array getAvailableLocales() Returns the list of internally available locales and already loaded custom locales.
* (It will ignore custom translator dynamic loading.)
* @method Language[] getAvailableLocalesInfo() Returns list of Language object for each available locale. This object allow you to get the ISO name, native
* name, region and variant of the locale.
* @method array getDays() Get the days of the week
* @method string|null getFallbackLocale() Get the fallback locale.
* @method array getFormatsToIsoReplacements() List of replacements from date() format to isoFormat().
* @method int getHumanDiffOptions() Return default humanDiff() options (merged flags as integer).
* @method array getIsoUnits() Returns list of locale units for ISO formatting.
* @method array getLastErrors() {@inheritdoc}
* @method string getLocale() Get the current translator locale.
* @method callable|null getMacro($name) Get the raw callable macro registered globally for a given name.
* @method int getMidDayAt() get midday/noon hour
* @method Closure|Carbon getTestNow() Get the Carbon instance (real or mock) to be returned when a "now"
* instance is created.
* @method string getTimeFormatByPrecision($unitPrecision) Return a format from H:i to H:i:s.u according to given unit precision.
* @method string getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null) Returns raw translation message for a given key.
* @method \Symfony\Component\Translation\TranslatorInterface getTranslator() Get the default translator instance in use.
* @method int getWeekEndsAt() Get the last day of week
* @method int getWeekStartsAt() Get the first day of week
* @method array getWeekendDays() Get weekend days
* @method bool hasFormat($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasFormatWithModifiers($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasMacro($name) Checks if macro is registered globally.
* @method bool hasRelativeKeywords($time) Determine if a time string will produce a relative date.
* @method bool hasTestNow() Determine if there is a valid test instance set. A valid test instance
* is anything that is not null.
* @method Carbon instance($date) Create a Carbon instance from a DateTime one.
* @method bool isImmutable() Returns true if the current class/instance is immutable.
* @method bool isModifiableUnit($unit) Returns true if a property can be changed via setter.
* @method bool isMutable() Returns true if the current class/instance is mutable.
* @method bool isStrictModeEnabled() Returns true if the strict mode is globally in use, false else.
* (It can be overridden in specific instances.)
* @method bool localeHasDiffOneDayWords($locale) Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
* Support is considered enabled if the 3 words are translated in the given locale.
* @method bool localeHasDiffSyntax($locale) Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasDiffTwoDayWords($locale) Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
* Support is considered enabled if the 2 words are translated in the given locale.
* @method bool localeHasPeriodSyntax($locale) Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasShortUnits($locale) Returns true if the given locale is internally supported and has short-units support.
* Support is considered enabled if either year, day or hour has a short variant translated.
* @method void macro($name, $macro) Register a custom macro.
* @method Carbon|null make($var) Make a Carbon instance from given variable if possible.
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
* and recurrences). Throw an exception for invalid format, but otherwise return null.
* @method Carbon maxValue() Create a Carbon instance for the greatest supported date.
* @method Carbon minValue() Create a Carbon instance for the lowest supported date.
* @method void mixin($mixin) Mix another object into the class.
* @method Carbon now($tz = null) Get a Carbon instance for the current date and time.
* @method Carbon parse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method Carbon parseFromLocale($time, $locale = null, $tz = null) Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
* @method string pluralUnit(string $unit) Returns standardized plural of a given singular/plural unit name (in English).
* @method Carbon|false rawCreateFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method Carbon rawParse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method Carbon resetMacros() Remove all macros and generic macros.
* @method void resetMonthsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void resetToStringFormat() Reset the format used to the default when type juggling a Carbon instance to a string
* @method void resetYearsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void serializeUsing($callback) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather transform Carbon object before the serialization.
* JSON serialize all Carbon instances using the given callback.
* @method Carbon setFallbackLocale($locale) Set the fallback locale.
* @method Carbon setHumanDiffOptions($humanDiffOptions) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method bool setLocale($locale) Set the current translator locale and indicate if the source locale file exists.
* Pass 'auto' as locale to use closest language from the current LC_TIME locale.
* @method void setMidDayAt($hour) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider mid-day is always 12pm, then if you need to test if it's an other
* hour, test it explicitly:
* $date->format('G') == 13
* or to set explicitly to a given hour:
* $date->setTime(13, 0, 0, 0)
* Set midday/noon hour
* @method Carbon setTestNow($testNow = null) Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
* Note the timezone parameter was left out of the examples above and
* has no affect as the mock value will be returned regardless of its value.
* Only the moment is mocked with setTestNow(), the timezone will still be the one passed
* as parameter of date_default_timezone_get() as a fallback (see setTestNowAndTimezone()).
* To clear the test instance call this method using the default
* parameter of null.
* /!\ Use this method for unit tests only.
* @method Carbon setTestNowAndTimezone($testNow = null, $tz = null) Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
* It will also align default timezone (e.g. call date_default_timezone_set()) with
* the second argument or if null, with the timezone of the given date object.
* To clear the test instance call this method using the default
* parameter of null.
* /!\ Use this method for unit tests only.
* @method void setToStringFormat($format) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather let Carbon object being cast to string with DEFAULT_TO_STRING_FORMAT, and
* use other method or custom format passed to format() method if you need to dump another string
* format.
* Set the default format used when type juggling a Carbon instance to a string.
* @method void setTranslator(TranslatorInterface $translator) Set the default translator instance to use.
* @method Carbon setUtf8($utf8) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use UTF-8 language packages on every machine.
* Set if UTF8 will be used for localized date/time.
* @method void setWeekEndsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek
* or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the
* start of week according to current locale selected and implicitly the end of week.
* Set the last day of week
* @method void setWeekStartsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the
* 'first_day_of_week' locale setting to change the start of week according to current locale
* selected and implicitly the end of week.
* Set the first day of week
* @method void setWeekendDays($days) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider week-end is always saturday and sunday, and if you have some custom
* week-end days to handle, give to those days an other name and create a macro for them:
* ```
* Carbon::macro('isDayOff', function ($date) {
* return $date->isSunday() || $date->isMonday();
* });
* Carbon::macro('isNotDayOff', function ($date) {
* return !$date->isDayOff();
* });
* if ($someDate->isDayOff()) ...
* if ($someDate->isNotDayOff()) ...
* // Add 5 not-off days
* $count = 5;
* while ($someDate->isDayOff() || ($count-- > 0)) {
* $someDate->addDay();
* }
* ```
* Set weekend days
* @method bool shouldOverflowMonths() Get the month overflow global behavior (can be overridden in specific instances).
* @method bool shouldOverflowYears() Get the month overflow global behavior (can be overridden in specific instances).
* @method string singularUnit(string $unit) Returns standardized singular of a given singular/plural unit name (in English).
* @method Carbon today($tz = null) Create a Carbon instance for today.
* @method Carbon tomorrow($tz = null) Create a Carbon instance for tomorrow.
* @method string translateTimeString($timeString, $from = null, $to = null, $mode = CarbonInterface::TRANSLATE_ALL) Translate a time string from a locale to an other.
* @method string translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null) Translate using translation string or callback available.
* @method void useMonthsOverflow($monthsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method Carbon useStrictMode($strictModeEnabled = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method void useYearsOverflow($yearsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method mixed withTestNow($testNow, $callback) Temporarily sets a static date to be used within the callback.
* Using setTestNow to set the date, executing the callback, then
* clearing the test instance.
* /!\ Use this method for unit tests only.
* @method Carbon yesterday($tz = null) Create a Carbon instance for yesterday.
*
* </autodoc>
*/
class Factory
{
protected $className = Carbon::class;
protected $settings = [];
public function __construct(array $settings = [], ?string $className = null)
{
if ($className) {
$this->className = $className;
}
$this->settings = $settings;
}
public function getClassName()
{
return $this->className;
}
public function setClassName(string $className)
{
$this->className = $className;
return $this;
}
public function className(string $className = null)
{
return $className === null ? $this->getClassName() : $this->setClassName($className);
}
public function getSettings()
{
return $this->settings;
}
public function setSettings(array $settings)
{
$this->settings = $settings;
return $this;
}
public function settings(array $settings = null)
{
return $settings === null ? $this->getSettings() : $this->setSettings($settings);
}
public function mergeSettings(array $settings)
{
$this->settings = \array_merge($this->settings, $settings);
return $this;
}
public function __call($name, $arguments)
{
$method = new ReflectionMethod($this->className, $name);
$settings = $this->settings;
if ($settings && isset($settings['timezone'])) {
$tzParameters = \array_filter($method->getParameters(), function ($parameter) {
return \in_array($parameter->getName(), ['tz', 'timezone'], \true);
});
if (isset($arguments[0]) && \in_array($name, ['instance', 'make', 'create', 'parse'], \true)) {
if ($arguments[0] instanceof DateTimeInterface) {
$settings['innerTimezone'] = $settings['timezone'];
} elseif (\is_string($arguments[0]) && \date_parse($arguments[0])['is_localtime']) {
unset($settings['timezone'], $settings['innerTimezone']);
}
} elseif (\count($tzParameters)) {
\array_splice($arguments, \key($tzParameters), 0, [$settings['timezone']]);
unset($settings['timezone']);
}
}
$result = $this->className::$name(...$arguments);
return $result instanceof CarbonInterface && !empty($settings) ? $result->settings($settings) : $result;
}
}
@@ -0,0 +1,254 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use Closure;
use DateTimeImmutable;
use DateTimeZone;
use MailPoetVendor\Psr\Clock\ClockInterface;
/**
* A factory to generate CarbonImmutable instances with common settings.
*
* <autodoc generated by `composer phpdoc`>
*
* @method bool canBeCreatedFromFormat($date, $format) Checks if the (date)time string is in a given format and valid to create a
* new instance.
* @method CarbonImmutable|false create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) Create a new Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* @method CarbonImmutable createFromDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to now.
* @method CarbonImmutable|false createFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method CarbonImmutable|false createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null) Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
* @method CarbonImmutable|false createFromLocaleFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific format and a string in a given language.
* @method CarbonImmutable|false createFromLocaleIsoFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific ISO format and a string in a given language.
* @method CarbonImmutable createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null) Create a Carbon instance from just a time. The date portion is set to today.
* @method CarbonImmutable createFromTimeString($time, $tz = null) Create a Carbon instance from a time string. The date portion is set to today.
* @method CarbonImmutable createFromTimestamp($timestamp, $tz = null) Create a Carbon instance from a timestamp and set the timezone (use default one if not specified).
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createFromTimestampMs($timestamp, $tz = null) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createFromTimestampMsUTC($timestamp) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createFromTimestampUTC($timestamp) Create a Carbon instance from an timestamp keeping the timezone to UTC.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createMidnightDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to midnight.
* @method CarbonImmutable|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) Create a new safe Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* If one of the set values is not valid, an InvalidDateException
* will be thrown.
* @method CarbonInterface createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null) Create a new Carbon instance from a specific date and time using strict validation.
* @method CarbonImmutable disableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method CarbonImmutable enableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method mixed executeWithLocale($locale, $func) Set the current locale to the given, execute the passed function, reset the locale to previous one,
* then return the result of the closure (or null if the closure was void).
* @method CarbonImmutable fromSerialized($value) Create an instance from a serialized string.
* @method void genericMacro($macro, $priority = 0) Register a custom macro.
* @method array getAvailableLocales() Returns the list of internally available locales and already loaded custom locales.
* (It will ignore custom translator dynamic loading.)
* @method Language[] getAvailableLocalesInfo() Returns list of Language object for each available locale. This object allow you to get the ISO name, native
* name, region and variant of the locale.
* @method array getDays() Get the days of the week
* @method string|null getFallbackLocale() Get the fallback locale.
* @method array getFormatsToIsoReplacements() List of replacements from date() format to isoFormat().
* @method int getHumanDiffOptions() Return default humanDiff() options (merged flags as integer).
* @method array getIsoUnits() Returns list of locale units for ISO formatting.
* @method array getLastErrors() {@inheritdoc}
* @method string getLocale() Get the current translator locale.
* @method callable|null getMacro($name) Get the raw callable macro registered globally for a given name.
* @method int getMidDayAt() get midday/noon hour
* @method Closure|CarbonImmutable getTestNow() Get the Carbon instance (real or mock) to be returned when a "now"
* instance is created.
* @method string getTimeFormatByPrecision($unitPrecision) Return a format from H:i to H:i:s.u according to given unit precision.
* @method string getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null) Returns raw translation message for a given key.
* @method \Symfony\Component\Translation\TranslatorInterface getTranslator() Get the default translator instance in use.
* @method int getWeekEndsAt() Get the last day of week
* @method int getWeekStartsAt() Get the first day of week
* @method array getWeekendDays() Get weekend days
* @method bool hasFormat($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasFormatWithModifiers($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasMacro($name) Checks if macro is registered globally.
* @method bool hasRelativeKeywords($time) Determine if a time string will produce a relative date.
* @method bool hasTestNow() Determine if there is a valid test instance set. A valid test instance
* is anything that is not null.
* @method CarbonImmutable instance($date) Create a Carbon instance from a DateTime one.
* @method bool isImmutable() Returns true if the current class/instance is immutable.
* @method bool isModifiableUnit($unit) Returns true if a property can be changed via setter.
* @method bool isMutable() Returns true if the current class/instance is mutable.
* @method bool isStrictModeEnabled() Returns true if the strict mode is globally in use, false else.
* (It can be overridden in specific instances.)
* @method bool localeHasDiffOneDayWords($locale) Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
* Support is considered enabled if the 3 words are translated in the given locale.
* @method bool localeHasDiffSyntax($locale) Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasDiffTwoDayWords($locale) Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
* Support is considered enabled if the 2 words are translated in the given locale.
* @method bool localeHasPeriodSyntax($locale) Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasShortUnits($locale) Returns true if the given locale is internally supported and has short-units support.
* Support is considered enabled if either year, day or hour has a short variant translated.
* @method void macro($name, $macro) Register a custom macro.
* @method CarbonImmutable|null make($var) Make a Carbon instance from given variable if possible.
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
* and recurrences). Throw an exception for invalid format, but otherwise return null.
* @method CarbonImmutable maxValue() Create a Carbon instance for the greatest supported date.
* @method CarbonImmutable minValue() Create a Carbon instance for the lowest supported date.
* @method void mixin($mixin) Mix another object into the class.
* @method CarbonImmutable parse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method CarbonImmutable parseFromLocale($time, $locale = null, $tz = null) Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
* @method string pluralUnit(string $unit) Returns standardized plural of a given singular/plural unit name (in English).
* @method CarbonImmutable|false rawCreateFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method CarbonImmutable rawParse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method CarbonImmutable resetMacros() Remove all macros and generic macros.
* @method void resetMonthsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void resetToStringFormat() Reset the format used to the default when type juggling a Carbon instance to a string
* @method void resetYearsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void serializeUsing($callback) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather transform Carbon object before the serialization.
* JSON serialize all Carbon instances using the given callback.
* @method CarbonImmutable setFallbackLocale($locale) Set the fallback locale.
* @method CarbonImmutable setHumanDiffOptions($humanDiffOptions) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method bool setLocale($locale) Set the current translator locale and indicate if the source locale file exists.
* Pass 'auto' as locale to use closest language from the current LC_TIME locale.
* @method void setMidDayAt($hour) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider mid-day is always 12pm, then if you need to test if it's an other
* hour, test it explicitly:
* $date->format('G') == 13
* or to set explicitly to a given hour:
* $date->setTime(13, 0, 0, 0)
* Set midday/noon hour
* @method CarbonImmutable setTestNow($testNow = null) Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
* Note the timezone parameter was left out of the examples above and
* has no affect as the mock value will be returned regardless of its value.
* Only the moment is mocked with setTestNow(), the timezone will still be the one passed
* as parameter of date_default_timezone_get() as a fallback (see setTestNowAndTimezone()).
* To clear the test instance call this method using the default
* parameter of null.
* /!\ Use this method for unit tests only.
* @method CarbonImmutable setTestNowAndTimezone($testNow = null, $tz = null) Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
* It will also align default timezone (e.g. call date_default_timezone_set()) with
* the second argument or if null, with the timezone of the given date object.
* To clear the test instance call this method using the default
* parameter of null.
* /!\ Use this method for unit tests only.
* @method void setToStringFormat($format) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather let Carbon object being cast to string with DEFAULT_TO_STRING_FORMAT, and
* use other method or custom format passed to format() method if you need to dump another string
* format.
* Set the default format used when type juggling a Carbon instance to a string.
* @method void setTranslator(TranslatorInterface $translator) Set the default translator instance to use.
* @method CarbonImmutable setUtf8($utf8) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use UTF-8 language packages on every machine.
* Set if UTF8 will be used for localized date/time.
* @method void setWeekEndsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek
* or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the
* start of week according to current locale selected and implicitly the end of week.
* Set the last day of week
* @method void setWeekStartsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the
* 'first_day_of_week' locale setting to change the start of week according to current locale
* selected and implicitly the end of week.
* Set the first day of week
* @method void setWeekendDays($days) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider week-end is always saturday and sunday, and if you have some custom
* week-end days to handle, give to those days an other name and create a macro for them:
* ```
* Carbon::macro('isDayOff', function ($date) {
* return $date->isSunday() || $date->isMonday();
* });
* Carbon::macro('isNotDayOff', function ($date) {
* return !$date->isDayOff();
* });
* if ($someDate->isDayOff()) ...
* if ($someDate->isNotDayOff()) ...
* // Add 5 not-off days
* $count = 5;
* while ($someDate->isDayOff() || ($count-- > 0)) {
* $someDate->addDay();
* }
* ```
* Set weekend days
* @method bool shouldOverflowMonths() Get the month overflow global behavior (can be overridden in specific instances).
* @method bool shouldOverflowYears() Get the month overflow global behavior (can be overridden in specific instances).
* @method string singularUnit(string $unit) Returns standardized singular of a given singular/plural unit name (in English).
* @method CarbonImmutable today($tz = null) Create a Carbon instance for today.
* @method CarbonImmutable tomorrow($tz = null) Create a Carbon instance for tomorrow.
* @method string translateTimeString($timeString, $from = null, $to = null, $mode = CarbonInterface::TRANSLATE_ALL) Translate a time string from a locale to an other.
* @method string translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null) Translate using translation string or callback available.
* @method void useMonthsOverflow($monthsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method CarbonImmutable useStrictMode($strictModeEnabled = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method void useYearsOverflow($yearsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method mixed withTestNow($testNow, $callback) Temporarily sets a static date to be used within the callback.
* Using setTestNow to set the date, executing the callback, then
* clearing the test instance.
* /!\ Use this method for unit tests only.
* @method CarbonImmutable yesterday($tz = null) Create a Carbon instance for yesterday.
*
* </autodoc>
*/
class FactoryImmutable extends Factory implements ClockInterface
{
protected $className = CarbonImmutable::class;
/**
* Get a Carbon instance for the current date and time.
*
* @param DateTimeZone|string|int|null $tz
*
* @return CarbonImmutable
*/
public function now($tz = null) : DateTimeImmutable
{
$className = $this->className;
return new $className(null, $tz);
}
}
@@ -0,0 +1,58 @@
<?php
namespace MailPoetVendor;
if (!defined('ABSPATH')) exit;
return [
'year' => '{1}:count year|{0}:count years|]1,Inf[:count years',
'a_year' => '{1}a year|{0}:count years|]1,Inf[:count years',
'y' => '{1}:countyr|{0}:countyrs|]1,Inf[:countyrs',
'month' => '{1}:count month|{0}:count months|]1,Inf[:count months',
'a_month' => '{1}a month|{0}:count months|]1,Inf[:count months',
'm' => '{1}:countmo|{0}:countmos|]1,Inf[:countmos',
'week' => '{1}:count week|{0}:count weeks|]1,Inf[:count weeks',
'a_week' => '{1}a week|{0}:count weeks|]1,Inf[:count weeks',
'w' => ':countw',
'day' => '{1}:count day|{0}:count days|]1,Inf[:count days',
'a_day' => '{1}a day|{0}:count days|]1,Inf[:count days',
'd' => ':countd',
'hour' => '{1}:count hour|{0}:count hours|]1,Inf[:count hours',
'a_hour' => '{1}an hour|{0}:count hours|]1,Inf[:count hours',
'h' => ':counth',
'minute' => '{1}:count minute|{0}:count minutes|]1,Inf[:count minutes',
'a_minute' => '{1}a minute|{0}:count minutes|]1,Inf[:count minutes',
'min' => ':countm',
'second' => '{1}:count second|{0}:count seconds|]1,Inf[:count seconds',
'a_second' => '{1}a few seconds|{0}:count seconds|]1,Inf[:count seconds',
's' => ':counts',
'millisecond' => '{1}:count millisecond|{0}:count milliseconds|]1,Inf[:count milliseconds',
'a_millisecond' => '{1}a millisecond|{0}:count milliseconds|]1,Inf[:count milliseconds',
'ms' => ':countms',
'microsecond' => '{1}:count microsecond|{0}:count microseconds|]1,Inf[:count microseconds',
'a_microsecond' => '{1}a microsecond|{0}:count microseconds|]1,Inf[:count microseconds',
'µs' => ':countµs',
'ago' => ':time ago',
'from_now' => ':time from now',
'after' => ':time after',
'before' => ':time before',
'diff_now' => 'just now',
'diff_today' => 'today',
'diff_yesterday' => 'yesterday',
'diff_tomorrow' => 'tomorrow',
'diff_before_yesterday' => 'before yesterday',
'diff_after_tomorrow' => 'after tomorrow',
'period_recurrences' => '{1}once|{0}:count times|]1,Inf[:count times',
'period_interval' => 'every :interval',
'period_start_date' => 'from :date',
'period_end_date' => 'to :date',
'months' => ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
'months_short' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
'weekdays' => ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
'weekdays_short' => ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
'weekdays_min' => ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
'ordinal' => function ($number) {
$lastDigit = $number % 10;
return $number . ((int) ($number % 100 / 10) === 1 ? 'th' : ($lastDigit === 1 ? 'st' : ($lastDigit === 2 ? 'nd' : ($lastDigit === 3 ? 'rd' : 'th'))));
},
'list' => [', ', ' and '],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
];
@@ -0,0 +1,150 @@
<?php
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use JsonSerializable;
use ReturnTypeWillChange;
class Language implements JsonSerializable
{
protected static $languagesNames;
protected static $regionsNames;
protected $id;
protected $code;
protected $variant;
protected $region;
protected $names;
protected $isoName;
protected $nativeName;
public function __construct(string $id)
{
$this->id = \str_replace('-', '_', $id);
$parts = \explode('_', $this->id);
$this->code = $parts[0];
if (isset($parts[1])) {
if (!\preg_match('/^[A-Z]+$/', $parts[1])) {
$this->variant = $parts[1];
$parts[1] = $parts[2] ?? null;
}
if ($parts[1]) {
$this->region = $parts[1];
}
}
}
public static function all()
{
if (!static::$languagesNames) {
static::$languagesNames = (require __DIR__ . '/List/languages.php');
}
return static::$languagesNames;
}
public static function regions()
{
if (!static::$regionsNames) {
static::$regionsNames = (require __DIR__ . '/List/regions.php');
}
return static::$regionsNames;
}
public function getNames() : array
{
if (!$this->names) {
$this->names = static::all()[$this->code] ?? ['isoName' => $this->code, 'nativeName' => $this->code];
}
return $this->names;
}
public function getId() : string
{
return $this->id;
}
public function getCode() : string
{
return $this->code;
}
public function getVariant() : ?string
{
return $this->variant;
}
public function getVariantName() : ?string
{
if ($this->variant === 'Latn') {
return 'Latin';
}
if ($this->variant === 'Cyrl') {
return 'Cyrillic';
}
return $this->variant;
}
public function getRegion() : ?string
{
return $this->region;
}
public function getRegionName() : ?string
{
return $this->region ? static::regions()[$this->region] ?? $this->region : null;
}
public function getFullIsoName() : string
{
if (!$this->isoName) {
$this->isoName = $this->getNames()['isoName'];
}
return $this->isoName;
}
public function setIsoName(string $isoName) : self
{
$this->isoName = $isoName;
return $this;
}
public function getFullNativeName() : string
{
if (!$this->nativeName) {
$this->nativeName = $this->getNames()['nativeName'];
}
return $this->nativeName;
}
public function setNativeName(string $nativeName) : self
{
$this->nativeName = $nativeName;
return $this;
}
public function getIsoName() : string
{
$name = $this->getFullIsoName();
return \trim(\strstr($name, ',', \true) ?: $name);
}
public function getNativeName() : string
{
$name = $this->getFullNativeName();
return \trim(\strstr($name, ',', \true) ?: $name);
}
public function getIsoDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getIsoName() . ($region ? ' (' . $region . ')' : '') . ($variant ? ' (' . $variant . ')' : '');
}
public function getNativeDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getNativeName() . ($region ? ' (' . $region . ')' : '') . ($variant ? ' (' . $variant . ')' : '');
}
public function getFullIsoDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getFullIsoName() . ($region ? ' (' . $region . ')' : '') . ($variant ? ' (' . $variant . ')' : '');
}
public function getFullNativeDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getFullNativeName() . ($region ? ' (' . $region . ')' : '') . ($variant ? ' (' . $variant . ')' : '');
}
public function __toString()
{
return $this->getId();
}
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->getIsoDescription();
}
}
@@ -0,0 +1,8 @@
<?php
if (!defined('ABSPATH')) exit;
return [
'en' => [
'isoName' => 'English',
'nativeName' => 'English',
],
];
File diff suppressed because one or more lines are too long
@@ -0,0 +1,22 @@
<?php
namespace MailPoetVendor\Carbon\MessageFormatter;
if (!defined('ABSPATH')) exit;
use ReflectionMethod;
use MailPoetVendor\Symfony\Component\Translation\Formatter\MessageFormatter;
use MailPoetVendor\Symfony\Component\Translation\Formatter\MessageFormatterInterface;
// @codeCoverageIgnoreStart
$transMethod = new ReflectionMethod(MessageFormatterInterface::class, 'format');
require $transMethod->getParameters()[0]->hasType() ? __DIR__ . '/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperStrongType.php' : __DIR__ . '/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php';
// @codeCoverageIgnoreEnd
final class MessageFormatterMapper extends LazyMessageFormatter
{
protected $formatter;
public function __construct(?MessageFormatterInterface $formatter = null)
{
$this->formatter = $formatter ?? new MessageFormatter();
}
protected function transformLocale(?string $locale) : ?string
{
return $locale ? \preg_replace('/[_@][A-Za-z][a-z]{2,}/', '', $locale) : $locale;
}
}
@@ -0,0 +1,120 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Exceptions\UnknownUnitException;
trait Boundaries
{
public function startOfDay()
{
return $this->setTime(0, 0, 0, 0);
}
public function endOfDay()
{
return $this->setTime(static::HOURS_PER_DAY - 1, static::MINUTES_PER_HOUR - 1, static::SECONDS_PER_MINUTE - 1, static::MICROSECONDS_PER_SECOND - 1);
}
public function startOfMonth()
{
return $this->setDate($this->year, $this->month, 1)->startOfDay();
}
public function endOfMonth()
{
return $this->setDate($this->year, $this->month, $this->daysInMonth)->endOfDay();
}
public function startOfQuarter()
{
$month = ($this->quarter - 1) * static::MONTHS_PER_QUARTER + 1;
return $this->setDate($this->year, $month, 1)->startOfDay();
}
public function endOfQuarter()
{
return $this->startOfQuarter()->addMonths(static::MONTHS_PER_QUARTER - 1)->endOfMonth();
}
public function startOfYear()
{
return $this->setDate($this->year, 1, 1)->startOfDay();
}
public function endOfYear()
{
return $this->setDate($this->year, 12, 31)->endOfDay();
}
public function startOfDecade()
{
$year = $this->year - $this->year % static::YEARS_PER_DECADE;
return $this->setDate($year, 1, 1)->startOfDay();
}
public function endOfDecade()
{
$year = $this->year - $this->year % static::YEARS_PER_DECADE + static::YEARS_PER_DECADE - 1;
return $this->setDate($year, 12, 31)->endOfDay();
}
public function startOfCentury()
{
$year = $this->year - ($this->year - 1) % static::YEARS_PER_CENTURY;
return $this->setDate($year, 1, 1)->startOfDay();
}
public function endOfCentury()
{
$year = $this->year - 1 - ($this->year - 1) % static::YEARS_PER_CENTURY + static::YEARS_PER_CENTURY;
return $this->setDate($year, 12, 31)->endOfDay();
}
public function startOfMillennium()
{
$year = $this->year - ($this->year - 1) % static::YEARS_PER_MILLENNIUM;
return $this->setDate($year, 1, 1)->startOfDay();
}
public function endOfMillennium()
{
$year = $this->year - 1 - ($this->year - 1) % static::YEARS_PER_MILLENNIUM + static::YEARS_PER_MILLENNIUM;
return $this->setDate($year, 12, 31)->endOfDay();
}
public function startOfWeek($weekStartsAt = null)
{
return $this->subDays((7 + $this->dayOfWeek - ($weekStartsAt ?? $this->firstWeekDay)) % 7)->startOfDay();
}
public function endOfWeek($weekEndsAt = null)
{
return $this->addDays((7 - $this->dayOfWeek + ($weekEndsAt ?? $this->lastWeekDay)) % 7)->endOfDay();
}
public function startOfHour()
{
return $this->setTime($this->hour, 0, 0, 0);
}
public function endOfHour()
{
return $this->setTime($this->hour, static::MINUTES_PER_HOUR - 1, static::SECONDS_PER_MINUTE - 1, static::MICROSECONDS_PER_SECOND - 1);
}
public function startOfMinute()
{
return $this->setTime($this->hour, $this->minute, 0, 0);
}
public function endOfMinute()
{
return $this->setTime($this->hour, $this->minute, static::SECONDS_PER_MINUTE - 1, static::MICROSECONDS_PER_SECOND - 1);
}
public function startOfSecond()
{
return $this->setTime($this->hour, $this->minute, $this->second, 0);
}
public function endOfSecond()
{
return $this->setTime($this->hour, $this->minute, $this->second, static::MICROSECONDS_PER_SECOND - 1);
}
public function startOf($unit, ...$params)
{
$ucfUnit = \ucfirst(static::singularUnit($unit));
$method = "startOf{$ucfUnit}";
if (!\method_exists($this, $method)) {
throw new UnknownUnitException($unit);
}
return $this->{$method}(...$params);
}
public function endOf($unit, ...$params)
{
$ucfUnit = \ucfirst(static::singularUnit($unit));
$method = "endOf{$ucfUnit}";
if (!\method_exists($this, $method)) {
throw new UnknownUnitException($unit);
}
return $this->{$method}(...$params);
}
}
@@ -0,0 +1,18 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Exceptions\InvalidCastException;
use DateTimeInterface;
trait Cast
{
public function cast(string $className)
{
if (!\method_exists($className, 'instance')) {
if (\is_a($className, DateTimeInterface::class, \true)) {
return new $className($this->rawFormat('Y-m-d H:i:s.u'), $this->getTimezone());
}
throw new InvalidCastException("{$className} has not the instance() method needed to cast the date.");
}
return $className::instance($this);
}
}
@@ -0,0 +1,322 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use BadMethodCallException;
use MailPoetVendor\Carbon\CarbonInterface;
use MailPoetVendor\Carbon\Exceptions\BadComparisonUnitException;
use InvalidArgumentException;
trait Comparison
{
protected $endOfTime = \false;
protected $startOfTime = \false;
public function eq($date) : bool
{
return $this->equalTo($date);
}
public function equalTo($date) : bool
{
$this->discourageNull($date);
$this->discourageBoolean($date);
return $this == $this->resolveCarbon($date);
}
public function ne($date) : bool
{
return $this->notEqualTo($date);
}
public function notEqualTo($date) : bool
{
return !$this->equalTo($date);
}
public function gt($date) : bool
{
return $this->greaterThan($date);
}
public function greaterThan($date) : bool
{
$this->discourageNull($date);
$this->discourageBoolean($date);
return $this > $this->resolveCarbon($date);
}
public function isAfter($date) : bool
{
return $this->greaterThan($date);
}
public function gte($date) : bool
{
return $this->greaterThanOrEqualTo($date);
}
public function greaterThanOrEqualTo($date) : bool
{
$this->discourageNull($date);
$this->discourageBoolean($date);
return $this >= $this->resolveCarbon($date);
}
public function lt($date) : bool
{
return $this->lessThan($date);
}
public function lessThan($date) : bool
{
$this->discourageNull($date);
$this->discourageBoolean($date);
return $this < $this->resolveCarbon($date);
}
public function isBefore($date) : bool
{
return $this->lessThan($date);
}
public function lte($date) : bool
{
return $this->lessThanOrEqualTo($date);
}
public function lessThanOrEqualTo($date) : bool
{
$this->discourageNull($date);
$this->discourageBoolean($date);
return $this <= $this->resolveCarbon($date);
}
public function between($date1, $date2, $equal = \true) : bool
{
$date1 = $this->resolveCarbon($date1);
$date2 = $this->resolveCarbon($date2);
if ($date1->greaterThan($date2)) {
[$date1, $date2] = [$date2, $date1];
}
if ($equal) {
return $this >= $date1 && $this <= $date2;
}
return $this > $date1 && $this < $date2;
}
public function betweenIncluded($date1, $date2) : bool
{
return $this->between($date1, $date2, \true);
}
public function betweenExcluded($date1, $date2) : bool
{
return $this->between($date1, $date2, \false);
}
public function isBetween($date1, $date2, $equal = \true) : bool
{
return $this->between($date1, $date2, $equal);
}
public function isWeekday()
{
return !$this->isWeekend();
}
public function isWeekend()
{
return \in_array($this->dayOfWeek, static::$weekendDays, \true);
}
public function isYesterday()
{
return $this->toDateString() === static::yesterday($this->getTimezone())->toDateString();
}
public function isToday()
{
return $this->toDateString() === $this->nowWithSameTz()->toDateString();
}
public function isTomorrow()
{
return $this->toDateString() === static::tomorrow($this->getTimezone())->toDateString();
}
public function isFuture()
{
return $this->greaterThan($this->nowWithSameTz());
}
public function isPast()
{
return $this->lessThan($this->nowWithSameTz());
}
public function isLeapYear()
{
return $this->rawFormat('L') === '1';
}
public function isLongYear()
{
return static::create($this->year, 12, 28, 0, 0, 0, $this->tz)->weekOfYear === 53;
}
public function isLongIsoYear()
{
return static::create($this->isoWeekYear, 12, 28, 0, 0, 0, $this->tz)->weekOfYear === 53;
}
public function isSameAs($format, $date = null)
{
return $this->rawFormat($format) === $this->resolveCarbon($date)->rawFormat($format);
}
public function isSameUnit($unit, $date = null)
{
$units = [
// @call isSameUnit
'year' => 'Y',
// @call isSameUnit
'week' => 'o-W',
// @call isSameUnit
'day' => 'Y-m-d',
// @call isSameUnit
'hour' => 'Y-m-d H',
// @call isSameUnit
'minute' => 'Y-m-d H:i',
// @call isSameUnit
'second' => 'Y-m-d H:i:s',
// @call isSameUnit
'micro' => 'Y-m-d H:i:s.u',
// @call isSameUnit
'microsecond' => 'Y-m-d H:i:s.u',
];
if (isset($units[$unit])) {
return $this->isSameAs($units[$unit], $date);
}
if (isset($this->{$unit})) {
return $this->resolveCarbon($date)->{$unit} === $this->{$unit};
}
if ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) {
throw new BadComparisonUnitException($unit);
}
return \false;
}
public function isCurrentUnit($unit)
{
return $this->{'isSame' . \ucfirst($unit)}();
}
public function isSameQuarter($date = null, $ofSameYear = \true)
{
$date = $this->resolveCarbon($date);
return $this->quarter === $date->quarter && (!$ofSameYear || $this->isSameYear($date));
}
public function isSameMonth($date = null, $ofSameYear = \true)
{
return $this->isSameAs($ofSameYear ? 'Y-m' : 'm', $date);
}
public function isDayOfWeek($dayOfWeek)
{
if (\is_string($dayOfWeek) && \defined($constant = static::class . '::' . \strtoupper($dayOfWeek))) {
$dayOfWeek = \constant($constant);
}
return $this->dayOfWeek === $dayOfWeek;
}
public function isBirthday($date = null)
{
return $this->isSameAs('md', $date);
}
public function isLastOfMonth()
{
return $this->day === $this->daysInMonth;
}
public function isStartOfDay($checkMicroseconds = \false)
{
return $checkMicroseconds ? $this->rawFormat('H:i:s.u') === '00:00:00.000000' : $this->rawFormat('H:i:s') === '00:00:00';
}
public function isEndOfDay($checkMicroseconds = \false)
{
return $checkMicroseconds ? $this->rawFormat('H:i:s.u') === '23:59:59.999999' : $this->rawFormat('H:i:s') === '23:59:59';
}
public function isMidnight()
{
return $this->isStartOfDay();
}
public function isMidday()
{
return $this->rawFormat('G:i:s') === static::$midDayAt . ':00:00';
}
public static function hasFormat($date, $format)
{
// createFromFormat() is known to handle edge cases silently.
// E.g. "1975-5-1" (Y-n-j) will still be parsed correctly when "Y-m-d" is supplied as the format.
// To ensure we're really testing against our desired format, perform an additional regex validation.
return self::matchFormatPattern((string) $date, \preg_quote((string) $format, '/'), static::$regexFormats);
}
public static function hasFormatWithModifiers($date, $format) : bool
{
return self::matchFormatPattern((string) $date, (string) $format, \array_merge(static::$regexFormats, static::$regexFormatModifiers));
}
public static function canBeCreatedFromFormat($date, $format)
{
try {
// Try to create a DateTime object. Throws an InvalidArgumentException if the provided time string
// doesn't match the format in any way.
if (!static::rawCreateFromFormat($format, $date)) {
return \false;
}
} catch (InvalidArgumentException $e) {
return \false;
}
return static::hasFormatWithModifiers($date, $format);
}
public function is(string $tester)
{
$tester = \trim($tester);
if (\preg_match('/^\\d+$/', $tester)) {
return $this->year === (int) $tester;
}
if (\preg_match('/^(?:Jan|January|Feb|February|Mar|March|Apr|April|May|Jun|June|Jul|July|Aug|August|Sep|September|Oct|October|Nov|November|Dec|December)$/i', $tester)) {
return $this->isSameMonth(static::parse($tester), \false);
}
if (\preg_match('/^\\d{3,}-\\d{1,2}$/', $tester)) {
return $this->isSameMonth(static::parse($tester));
}
if (\preg_match('/^\\d{1,2}-\\d{1,2}$/', $tester)) {
return $this->isSameDay(static::parse($this->year . '-' . $tester));
}
$modifier = \preg_replace('/(\\d)h$/i', '$1:00', $tester);
$median = static::parse('5555-06-15 12:30:30.555555')->modify($modifier);
$current = $this->avoidMutation();
$other = $this->avoidMutation()->modify($modifier);
if ($current->eq($other)) {
return \true;
}
if (\preg_match('/\\d:\\d{1,2}:\\d{1,2}$/', $tester)) {
return $current->startOfSecond()->eq($other);
}
if (\preg_match('/\\d:\\d{1,2}$/', $tester)) {
return $current->startOfMinute()->eq($other);
}
if (\preg_match('/\\d(?:h|am|pm)$/', $tester)) {
return $current->startOfHour()->eq($other);
}
if (\preg_match('/^(?:january|february|march|april|may|june|july|august|september|october|november|december)(?:\\s+\\d+)?$/i', $tester)) {
return $current->startOfMonth()->eq($other->startOfMonth());
}
$units = ['month' => [1, 'year'], 'day' => [1, 'month'], 'hour' => [0, 'day'], 'minute' => [0, 'hour'], 'second' => [0, 'minute'], 'microsecond' => [0, 'second']];
foreach ($units as $unit => [$minimum, $startUnit]) {
if ($minimum === $median->{$unit}) {
$current = $current->startOf($startUnit);
break;
}
}
return $current->eq($other);
}
private static function matchFormatPattern(string $date, string $format, array $replacements) : bool
{
// Preg quote, but remove escaped backslashes since we'll deal with escaped characters in the format string.
$regex = \str_replace('\\\\', '\\', $format);
// Replace not-escaped letters
$regex = \preg_replace_callback('/(?<!\\\\)((?:\\\\{2})*)([' . \implode('', \array_keys($replacements)) . '])/', function ($match) use($replacements) {
return $match[1] . \strtr($match[2], $replacements);
}, $regex);
// Replace escaped letters by the letter itself
$regex = \preg_replace('/(?<!\\\\)((?:\\\\{2})*)\\\\(\\w)/', '$1$2', $regex);
// Escape not escaped slashes
$regex = \preg_replace('#(?<!\\\\)((?:\\\\{2})*)/#', '$1\\/', $regex);
return (bool) @\preg_match('/^' . $regex . '$/', $date);
}
public function isStartOfTime() : bool
{
return $this->startOfTime ?? \false;
}
public function isEndOfTime() : bool
{
return $this->endOfTime ?? \false;
}
private function discourageNull($value) : void
{
if ($value === null) {
@\trigger_error("Since 2.61.0, it's deprecated to compare a date to null, meaning of such comparison is ambiguous and will no longer be possible in 3.0.0, you should explicitly pass 'now' or make an other check to eliminate null values.", \E_USER_DEPRECATED);
}
}
private function discourageBoolean($value) : void
{
if (\is_bool($value)) {
@\trigger_error("Since 2.61.0, it's deprecated to compare a date to true or false, meaning of such comparison is ambiguous and will no longer be possible in 3.0.0, you should explicitly pass 'now' or make an other check to eliminate boolean values.", \E_USER_DEPRECATED);
}
}
}
@@ -0,0 +1,197 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Carbon;
use MailPoetVendor\Carbon\CarbonImmutable;
use MailPoetVendor\Carbon\CarbonInterface;
use MailPoetVendor\Carbon\CarbonInterval;
use MailPoetVendor\Carbon\CarbonPeriod;
use MailPoetVendor\Carbon\CarbonPeriodImmutable;
use MailPoetVendor\Carbon\Exceptions\UnitException;
use Closure;
use DateTime;
use DateTimeImmutable;
use ReturnTypeWillChange;
trait Converter
{
use ToStringFormat;
#[\ReturnTypeWillChange]
public function format($format)
{
$function = $this->localFormatFunction ?: static::$formatFunction;
if (!$function) {
return $this->rawFormat($format);
}
if (\is_string($function) && \method_exists($this, $function)) {
$function = [$this, $function];
}
return $function(...\func_get_args());
}
public function rawFormat($format)
{
return parent::format($format);
}
public function __toString()
{
$format = $this->localToStringFormat ?? static::$toStringFormat;
return $format instanceof Closure ? $format($this) : $this->rawFormat($format ?: (\defined('static::DEFAULT_TO_STRING_FORMAT') ? static::DEFAULT_TO_STRING_FORMAT : CarbonInterface::DEFAULT_TO_STRING_FORMAT));
}
public function toDateString()
{
return $this->rawFormat('Y-m-d');
}
public function toFormattedDateString()
{
return $this->rawFormat('M j, Y');
}
public function toFormattedDayDateString() : string
{
return $this->rawFormat('D, M j, Y');
}
public function toTimeString($unitPrecision = 'second')
{
return $this->rawFormat(static::getTimeFormatByPrecision($unitPrecision));
}
public function toDateTimeString($unitPrecision = 'second')
{
return $this->rawFormat('Y-m-d ' . static::getTimeFormatByPrecision($unitPrecision));
}
public static function getTimeFormatByPrecision($unitPrecision)
{
switch (static::singularUnit($unitPrecision)) {
case 'minute':
return 'H:i';
case 'second':
return 'H:i:s';
case 'm':
case 'millisecond':
return 'H:i:s.v';
case 'µ':
case 'microsecond':
return 'H:i:s.u';
}
throw new UnitException('Precision unit expected among: minute, second, millisecond and microsecond.');
}
public function toDateTimeLocalString($unitPrecision = 'second')
{
return $this->rawFormat('Y-m-d\\T' . static::getTimeFormatByPrecision($unitPrecision));
}
public function toDayDateTimeString()
{
return $this->rawFormat('D, M j, Y g:i A');
}
public function toAtomString()
{
return $this->rawFormat(DateTime::ATOM);
}
public function toCookieString()
{
return $this->rawFormat(DateTime::COOKIE);
}
public function toIso8601String()
{
return $this->toAtomString();
}
public function toRfc822String()
{
return $this->rawFormat(DateTime::RFC822);
}
public function toIso8601ZuluString($unitPrecision = 'second')
{
return $this->avoidMutation()->utc()->rawFormat('Y-m-d\\T' . static::getTimeFormatByPrecision($unitPrecision) . '\\Z');
}
public function toRfc850String()
{
return $this->rawFormat(DateTime::RFC850);
}
public function toRfc1036String()
{
return $this->rawFormat(DateTime::RFC1036);
}
public function toRfc1123String()
{
return $this->rawFormat(DateTime::RFC1123);
}
public function toRfc2822String()
{
return $this->rawFormat(DateTime::RFC2822);
}
public function toRfc3339String($extended = \false)
{
$format = DateTime::RFC3339;
if ($extended) {
$format = DateTime::RFC3339_EXTENDED;
}
return $this->rawFormat($format);
}
public function toRssString()
{
return $this->rawFormat(DateTime::RSS);
}
public function toW3cString()
{
return $this->rawFormat(DateTime::W3C);
}
public function toRfc7231String()
{
return $this->avoidMutation()->setTimezone('GMT')->rawFormat(\defined('static::RFC7231_FORMAT') ? static::RFC7231_FORMAT : CarbonInterface::RFC7231_FORMAT);
}
public function toArray()
{
return ['year' => $this->year, 'month' => $this->month, 'day' => $this->day, 'dayOfWeek' => $this->dayOfWeek, 'dayOfYear' => $this->dayOfYear, 'hour' => $this->hour, 'minute' => $this->minute, 'second' => $this->second, 'micro' => $this->micro, 'timestamp' => $this->timestamp, 'formatted' => $this->rawFormat(\defined('static::DEFAULT_TO_STRING_FORMAT') ? static::DEFAULT_TO_STRING_FORMAT : CarbonInterface::DEFAULT_TO_STRING_FORMAT), 'timezone' => $this->timezone];
}
public function toObject()
{
return (object) $this->toArray();
}
public function toString()
{
return $this->avoidMutation()->locale('en')->isoFormat('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
}
public function toISOString($keepOffset = \false)
{
if (!$this->isValid()) {
return null;
}
$yearFormat = $this->year < 0 || $this->year > 9999 ? 'YYYYYY' : 'YYYY';
$tzFormat = $keepOffset ? 'Z' : '[Z]';
$date = $keepOffset ? $this : $this->avoidMutation()->utc();
return $date->isoFormat("{$yearFormat}-MM-DD[T]HH:mm:ss.SSSSSS{$tzFormat}");
}
public function toJSON()
{
return $this->toISOString();
}
public function toDateTime()
{
return new DateTime($this->rawFormat('Y-m-d H:i:s.u'), $this->getTimezone());
}
public function toDateTimeImmutable()
{
return new DateTimeImmutable($this->rawFormat('Y-m-d H:i:s.u'), $this->getTimezone());
}
public function toDate()
{
return $this->toDateTime();
}
public function toPeriod($end = null, $interval = null, $unit = null)
{
if ($unit) {
$interval = CarbonInterval::make("{$interval} " . static::pluralUnit($unit));
}
$period = ($this->isMutable() ? new CarbonPeriod() : new CarbonPeriodImmutable())->setDateClass(static::class)->setStartDate($this);
if ($interval) {
$period = $period->setDateInterval($interval);
}
if (\is_int($end) || \is_string($end) && \ctype_digit($end)) {
$period = $period->setRecurrences($end);
} elseif ($end) {
$period = $period->setEndDate($end);
}
return $period;
}
public function range($end = null, $interval = null, $unit = null)
{
return $this->toPeriod($end, $interval, $unit);
}
}
@@ -0,0 +1,405 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Carbon;
use MailPoetVendor\Carbon\CarbonImmutable;
use MailPoetVendor\Carbon\CarbonInterface;
use MailPoetVendor\Carbon\Exceptions\InvalidDateException;
use MailPoetVendor\Carbon\Exceptions\InvalidFormatException;
use MailPoetVendor\Carbon\Exceptions\OutOfRangeException;
use MailPoetVendor\Carbon\Translator;
use Closure;
use MailPoetVendor\DateMalformedStringException;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
use Exception;
use ReturnTypeWillChange;
trait Creator
{
use ObjectInitialisation;
protected static $lastErrors;
public function __construct($time = null, $tz = null)
{
if ($time instanceof DateTimeInterface) {
$time = $this->constructTimezoneFromDateTime($time, $tz)->format('Y-m-d H:i:s.u');
}
if (\is_numeric($time) && (!\is_string($time) || !\preg_match('/^\\d{1,14}$/', $time))) {
$time = static::createFromTimestampUTC($time)->format('Y-m-d\\TH:i:s.uP');
}
// If the class has a test now set and we are trying to create a now()
// instance then override as required
$isNow = empty($time) || $time === 'now';
if (\method_exists(static::class, 'hasTestNow') && \method_exists(static::class, 'getTestNow') && static::hasTestNow() && ($isNow || static::hasRelativeKeywords($time))) {
static::mockConstructorParameters($time, $tz);
}
// Work-around for PHP bug https://bugs.php.net/bug.php?id=67127
if (!\str_contains((string) 0.1, '.')) {
$locale = \setlocale(\LC_NUMERIC, '0');
// @codeCoverageIgnore
\setlocale(\LC_NUMERIC, 'C');
// @codeCoverageIgnore
}
try {
parent::__construct($time ?: 'now', static::safeCreateDateTimeZone($tz) ?: null);
} catch (Exception $exception) {
throw new InvalidFormatException($exception->getMessage(), 0, $exception);
}
$this->constructedObjectId = \spl_object_hash($this);
if (isset($locale)) {
\setlocale(\LC_NUMERIC, $locale);
// @codeCoverageIgnore
}
self::setLastErrors(parent::getLastErrors());
}
private function constructTimezoneFromDateTime(DateTimeInterface $date, &$tz)
{
if ($tz !== null) {
$safeTz = static::safeCreateDateTimeZone($tz);
if ($safeTz) {
return ($date instanceof DateTimeImmutable ? $date : clone $date)->setTimezone($safeTz);
}
return $date;
}
$tz = $date->getTimezone();
return $date;
}
public function __clone()
{
$this->constructedObjectId = \spl_object_hash($this);
}
public static function instance($date)
{
if ($date instanceof static) {
return clone $date;
}
static::expectDateTime($date);
$instance = new static($date->format('Y-m-d H:i:s.u'), $date->getTimezone());
if ($date instanceof CarbonInterface) {
$settings = $date->getSettings();
if (!$date->hasLocalTranslator()) {
unset($settings['locale']);
}
$instance->settings($settings);
}
return $instance;
}
public static function rawParse($time = null, $tz = null)
{
if ($time instanceof DateTimeInterface) {
return static::instance($time);
}
try {
return new static($time, $tz);
} catch (Exception $exception) {
// @codeCoverageIgnoreStart
try {
$date = @static::now($tz)->change($time);
} catch (DateMalformedStringException $ignoredException) {
$date = null;
}
// @codeCoverageIgnoreEnd
if (!$date) {
throw new InvalidFormatException("Could not parse '{$time}': " . $exception->getMessage(), 0, $exception);
}
return $date;
}
}
public static function parse($time = null, $tz = null)
{
$function = static::$parseFunction;
if (!$function) {
return static::rawParse($time, $tz);
}
if (\is_string($function) && \method_exists(static::class, $function)) {
$function = [static::class, $function];
}
return $function(...\func_get_args());
}
public static function parseFromLocale($time, $locale = null, $tz = null)
{
return static::rawParse(static::translateTimeString($time, $locale, 'en'), $tz);
}
public static function now($tz = null)
{
return new static(null, $tz);
}
public static function today($tz = null)
{
return static::rawParse('today', $tz);
}
public static function tomorrow($tz = null)
{
return static::rawParse('tomorrow', $tz);
}
public static function yesterday($tz = null)
{
return static::rawParse('yesterday', $tz);
}
public static function maxValue()
{
if (self::$PHPIntSize === 4) {
// 32 bit
return static::createFromTimestamp(\PHP_INT_MAX);
// @codeCoverageIgnore
}
// 64 bit
return static::create(9999, 12, 31, 23, 59, 59);
}
public static function minValue()
{
if (self::$PHPIntSize === 4) {
// 32 bit
return static::createFromTimestamp(~\PHP_INT_MAX);
// @codeCoverageIgnore
}
// 64 bit
return static::create(1, 1, 1, 0, 0, 0);
}
private static function assertBetween($unit, $value, $min, $max)
{
if (static::isStrictModeEnabled() && ($value < $min || $value > $max)) {
throw new OutOfRangeException($unit, $min, $max, $value);
}
}
private static function createNowInstance($tz)
{
if (!static::hasTestNow()) {
return static::now($tz);
}
$now = static::getTestNow();
if ($now instanceof Closure) {
return $now(static::now($tz));
}
return $now->avoidMutation()->tz($tz);
}
public static function create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null)
{
if (\is_string($year) && !\is_numeric($year) || $year instanceof DateTimeInterface) {
return static::parse($year, $tz ?: (\is_string($month) || $month instanceof DateTimeZone ? $month : null));
}
$defaults = null;
$getDefault = function ($unit) use($tz, &$defaults) {
if ($defaults === null) {
$now = self::createNowInstance($tz);
$defaults = \array_combine(['year', 'month', 'day', 'hour', 'minute', 'second'], \explode('-', $now->rawFormat('Y-n-j-G-i-s.u')));
}
return $defaults[$unit];
};
$year = $year ?? $getDefault('year');
$month = $month ?? $getDefault('month');
$day = $day ?? $getDefault('day');
$hour = $hour ?? $getDefault('hour');
$minute = $minute ?? $getDefault('minute');
$second = (float) ($second ?? $getDefault('second'));
self::assertBetween('month', $month, 0, 99);
self::assertBetween('day', $day, 0, 99);
self::assertBetween('hour', $hour, 0, 99);
self::assertBetween('minute', $minute, 0, 99);
self::assertBetween('second', $second, 0, 99);
$fixYear = null;
if ($year < 0) {
$fixYear = $year;
$year = 0;
} elseif ($year > 9999) {
$fixYear = $year - 9999;
$year = 9999;
}
$second = ($second < 10 ? '0' : '') . \number_format($second, 6);
$instance = static::rawCreateFromFormat('!Y-n-j G:i:s.u', \sprintf('%s-%s-%s %s:%02s:%02s', $year, $month, $day, $hour, $minute, $second), $tz);
if ($fixYear !== null) {
$instance = $instance->addYears($fixYear);
}
return $instance;
}
public static function createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null)
{
$fields = static::getRangesByUnit();
foreach ($fields as $field => $range) {
if (${$field} !== null && (!\is_int(${$field}) || ${$field} < $range[0] || ${$field} > $range[1])) {
if (static::isStrictModeEnabled()) {
throw new InvalidDateException($field, ${$field});
}
return \false;
}
}
$instance = static::create($year, $month, $day, $hour, $minute, $second, $tz);
foreach (\array_reverse($fields) as $field => $range) {
if (${$field} !== null && (!\is_int(${$field}) || ${$field} !== $instance->{$field})) {
if (static::isStrictModeEnabled()) {
throw new InvalidDateException($field, ${$field});
}
return \false;
}
}
return $instance;
}
public static function createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null) : self
{
$initialStrictMode = static::isStrictModeEnabled();
static::useStrictMode(\true);
try {
$date = static::create($year, $month, $day, $hour, $minute, $second, $tz);
} finally {
static::useStrictMode($initialStrictMode);
}
return $date;
}
public static function createFromDate($year = null, $month = null, $day = null, $tz = null)
{
return static::create($year, $month, $day, null, null, null, $tz);
}
public static function createMidnightDate($year = null, $month = null, $day = null, $tz = null)
{
return static::create($year, $month, $day, 0, 0, 0, $tz);
}
public static function createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null)
{
return static::create(null, null, null, $hour, $minute, $second, $tz);
}
public static function createFromTimeString($time, $tz = null)
{
return static::today($tz)->setTimeFromTimeString($time);
}
private static function createFromFormatAndTimezone($format, $time, $originalTz)
{
// Work-around for https://bugs.php.net/bug.php?id=75577
// @codeCoverageIgnoreStart
if (\version_compare(\PHP_VERSION, '7.3.0-dev', '<')) {
$format = \str_replace('.v', '.u', $format);
}
// @codeCoverageIgnoreEnd
if ($originalTz === null) {
return parent::createFromFormat($format, (string) $time);
}
$tz = \is_int($originalTz) ? @\timezone_name_from_abbr('', (int) ($originalTz * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE), 1) : $originalTz;
$tz = static::safeCreateDateTimeZone($tz, $originalTz);
if ($tz === \false) {
return \false;
}
return parent::createFromFormat($format, (string) $time, $tz);
}
public static function rawCreateFromFormat($format, $time, $tz = null)
{
// Work-around for https://bugs.php.net/bug.php?id=80141
$format = \preg_replace('/(?<!\\\\)((?:\\\\{2})*)c/', '$1Y-m-d\\TH:i:sP', $format);
if (\preg_match('/(?<!\\\\)(?:\\\\{2})*(a|A)/', $format, $aMatches, \PREG_OFFSET_CAPTURE) && \preg_match('/(?<!\\\\)(?:\\\\{2})*(h|g|H|G)/', $format, $hMatches, \PREG_OFFSET_CAPTURE) && $aMatches[1][1] < $hMatches[1][1] && \preg_match('/(am|pm|AM|PM)/', $time)) {
$format = \preg_replace('/^(.*)(?<!\\\\)((?:\\\\{2})*)(a|A)(.*)$/U', '$1$2$4 $3', $format);
$time = \preg_replace('/^(.*)(am|pm|AM|PM)(.*)$/U', '$1$3 $2', $time);
}
if ($tz === \false) {
$tz = null;
}
// First attempt to create an instance, so that error messages are based on the unmodified format.
$date = self::createFromFormatAndTimezone($format, $time, $tz);
$lastErrors = parent::getLastErrors();
$mock = static::getMockedTestNow($tz);
if ($mock && $date instanceof DateTimeInterface) {
// Set timezone from mock if custom timezone was neither given directly nor as a part of format.
// First let's skip the part that will be ignored by the parser.
$nonEscaped = '(?<!\\\\)(\\\\{2})*';
$nonIgnored = \preg_replace("/^.*{$nonEscaped}!/s", '', $format);
if ($tz === null && !\preg_match("/{$nonEscaped}[eOPT]/", $nonIgnored)) {
$tz = clone $mock->getTimezone();
}
$mock = $mock->copy();
// Prepend mock datetime only if the format does not contain non escaped unix epoch reset flag.
if (!\preg_match("/{$nonEscaped}[!|]/", $format)) {
if (\preg_match('/[HhGgisvuB]/', $format)) {
$mock = $mock->setTime(0, 0);
}
$format = static::MOCK_DATETIME_FORMAT . ' ' . $format;
$time = ($mock instanceof self ? $mock->rawFormat(static::MOCK_DATETIME_FORMAT) : $mock->format(static::MOCK_DATETIME_FORMAT)) . ' ' . $time;
}
// Regenerate date from the modified format to base result on the mocked instance instead of now.
$date = self::createFromFormatAndTimezone($format, $time, $tz);
}
if ($date instanceof DateTimeInterface) {
$instance = static::instance($date);
$instance::setLastErrors($lastErrors);
return $instance;
}
if (static::isStrictModeEnabled()) {
throw new InvalidFormatException(\implode(\PHP_EOL, $lastErrors['errors']));
}
return \false;
}
#[\ReturnTypeWillChange]
public static function createFromFormat($format, $time, $tz = null)
{
$function = static::$createFromFormatFunction;
if (!$function) {
return static::rawCreateFromFormat($format, $time, $tz);
}
if (\is_string($function) && \method_exists(static::class, $function)) {
$function = [static::class, $function];
}
return $function(...\func_get_args());
}
public static function createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null)
{
$format = \preg_replace_callback('/(?<!\\\\)(\\\\{2})*(LTS|LT|[Ll]{1,4})/', function ($match) use($locale, $translator) {
[$code] = $match;
static $formats = null;
if ($formats === null) {
$translator = $translator ?: Translator::get($locale);
$formats = ['LT' => static::getTranslationMessageWith($translator, 'formats.LT', $locale, 'h:mm A'), 'LTS' => static::getTranslationMessageWith($translator, 'formats.LTS', $locale, 'h:mm:ss A'), 'L' => static::getTranslationMessageWith($translator, 'formats.L', $locale, 'MM/DD/YYYY'), 'LL' => static::getTranslationMessageWith($translator, 'formats.LL', $locale, 'MMMM D, YYYY'), 'LLL' => static::getTranslationMessageWith($translator, 'formats.LLL', $locale, 'MMMM D, YYYY h:mm A'), 'LLLL' => static::getTranslationMessageWith($translator, 'formats.LLLL', $locale, 'dddd, MMMM D, YYYY h:mm A')];
}
return $formats[$code] ?? \preg_replace_callback('/MMMM|MM|DD|dddd/', function ($code) {
return \mb_substr($code[0], 1);
}, $formats[\strtoupper($code)] ?? '');
}, $format);
$format = \preg_replace_callback('/(?<!\\\\)(\\\\{2})*(' . CarbonInterface::ISO_FORMAT_REGEXP . '|[A-Za-z])/', function ($match) {
[$code] = $match;
static $replacements = null;
if ($replacements === null) {
$replacements = ['OD' => 'd', 'OM' => 'M', 'OY' => 'Y', 'OH' => 'G', 'Oh' => 'g', 'Om' => 'i', 'Os' => 's', 'D' => 'd', 'DD' => 'd', 'Do' => 'd', 'd' => '!', 'dd' => '!', 'ddd' => 'D', 'dddd' => 'D', 'DDD' => 'z', 'DDDD' => 'z', 'DDDo' => 'z', 'e' => '!', 'E' => '!', 'H' => 'G', 'HH' => 'H', 'h' => 'g', 'hh' => 'h', 'k' => 'G', 'kk' => 'G', 'hmm' => 'gi', 'hmmss' => 'gis', 'Hmm' => 'Gi', 'Hmmss' => 'Gis', 'm' => 'i', 'mm' => 'i', 'a' => 'a', 'A' => 'a', 's' => 's', 'ss' => 's', 'S' => '*', 'SS' => '*', 'SSS' => '*', 'SSSS' => '*', 'SSSSS' => '*', 'SSSSSS' => 'u', 'SSSSSSS' => 'u*', 'SSSSSSSS' => 'u*', 'SSSSSSSSS' => 'u*', 'M' => 'm', 'MM' => 'm', 'MMM' => 'M', 'MMMM' => 'M', 'Mo' => 'm', 'Q' => '!', 'Qo' => '!', 'G' => '!', 'GG' => '!', 'GGG' => '!', 'GGGG' => '!', 'GGGGG' => '!', 'g' => '!', 'gg' => '!', 'ggg' => '!', 'gggg' => '!', 'ggggg' => '!', 'W' => '!', 'WW' => '!', 'Wo' => '!', 'w' => '!', 'ww' => '!', 'wo' => '!', 'x' => 'U???', 'X' => 'U', 'Y' => 'Y', 'YY' => 'y', 'YYYY' => 'Y', 'YYYYY' => 'Y', 'YYYYYY' => 'Y', 'z' => 'e', 'zz' => 'e', 'Z' => 'e', 'ZZ' => 'e'];
}
$format = $replacements[$code] ?? '?';
if ($format === '!') {
throw new InvalidFormatException("Format {$code} not supported for creation.");
}
return $format;
}, $format);
return static::rawCreateFromFormat($format, $time, $tz);
}
public static function createFromLocaleFormat($format, $locale, $time, $tz = null)
{
$format = \preg_replace_callback('/(?:\\\\[a-zA-Z]|[bfkqCEJKQRV]){2,}/', static function (array $match) use($locale) : string {
$word = \str_replace('\\', '', $match[0]);
$translatedWord = static::translateTimeString($word, $locale, 'en');
return $word === $translatedWord ? $match[0] : \preg_replace('/[a-zA-Z]/', '\\\\$0', $translatedWord);
}, $format);
return static::rawCreateFromFormat($format, static::translateTimeString($time, $locale, 'en'), $tz);
}
public static function createFromLocaleIsoFormat($format, $locale, $time, $tz = null)
{
$time = static::translateTimeString($time, $locale, 'en', CarbonInterface::TRANSLATE_MONTHS | CarbonInterface::TRANSLATE_DAYS | CarbonInterface::TRANSLATE_MERIDIEM);
return static::createFromIsoFormat($format, $time, $tz, $locale);
}
public static function make($var)
{
if ($var instanceof DateTimeInterface) {
return static::instance($var);
}
$date = null;
if (\is_string($var)) {
$var = \trim($var);
if (!\preg_match('/^P[\\dT]/', $var) && !\preg_match('/^R\\d/', $var) && \preg_match('/[a-z\\d]/i', $var)) {
$date = static::parse($var);
}
}
return $date;
}
private static function setLastErrors($lastErrors)
{
if (\is_array($lastErrors) || $lastErrors === \false) {
static::$lastErrors = \is_array($lastErrors) ? $lastErrors : ['warning_count' => 0, 'warnings' => [], 'error_count' => 0, 'errors' => []];
}
}
#[\ReturnTypeWillChange]
public static function getLastErrors()
{
return static::$lastErrors;
}
}
@@ -0,0 +1,11 @@
<?php
declare (strict_types=1);
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
trait DeprecatedProperties
{
public $localeDayOfWeek;
public $shortLocaleDayOfWeek;
public $localeMonth;
public $shortLocaleMonth;
}
@@ -0,0 +1,425 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Carbon;
use MailPoetVendor\Carbon\CarbonImmutable;
use MailPoetVendor\Carbon\CarbonInterface;
use MailPoetVendor\Carbon\CarbonInterval;
use MailPoetVendor\Carbon\CarbonPeriod;
use MailPoetVendor\Carbon\Translator;
use Closure;
use DateInterval;
use DateTimeInterface;
use ReturnTypeWillChange;
trait Difference
{
protected static function fixNegativeMicroseconds(CarbonInterval $diff)
{
if ($diff->s !== 0 || $diff->i !== 0 || $diff->h !== 0 || $diff->d !== 0 || $diff->m !== 0 || $diff->y !== 0) {
$diff->f = (\round($diff->f * 1000000) + 1000000) / 1000000;
$diff->s--;
if ($diff->s < 0) {
$diff->s += 60;
$diff->i--;
if ($diff->i < 0) {
$diff->i += 60;
$diff->h--;
if ($diff->h < 0) {
$diff->h += 24;
$diff->d--;
if ($diff->d < 0) {
$diff->d += 30;
$diff->m--;
if ($diff->m < 0) {
$diff->m += 12;
$diff->y--;
}
}
}
}
}
return;
}
$diff->f *= -1;
$diff->invert();
}
protected static function fixDiffInterval(DateInterval $diff, $absolute, array $skip = [])
{
$diff = CarbonInterval::instance($diff, $skip);
// Work-around for https://bugs.php.net/bug.php?id=77145
// @codeCoverageIgnoreStart
if ($diff->f > 0 && $diff->y === -1 && $diff->m === 11 && $diff->d >= 27 && $diff->h === 23 && $diff->i === 59 && $diff->s === 59) {
$diff->y = 0;
$diff->m = 0;
$diff->d = 0;
$diff->h = 0;
$diff->i = 0;
$diff->s = 0;
$diff->f = (1000000 - \round($diff->f * 1000000)) / 1000000;
$diff->invert();
} elseif ($diff->f < 0) {
static::fixNegativeMicroseconds($diff);
}
// @codeCoverageIgnoreEnd
if ($absolute && $diff->invert) {
$diff->invert();
}
return $diff;
}
#[\ReturnTypeWillChange]
public function diff($date = null, $absolute = \false)
{
$other = $this->resolveCarbon($date);
// Work-around for https://bugs.php.net/bug.php?id=81458
// It was initially introduced for https://bugs.php.net/bug.php?id=80998
// The very specific case of 80998 was fixed in PHP 8.1beta3, but it introduced 81458
// So we still need to keep this for now
// @codeCoverageIgnoreStart
if (\version_compare(\PHP_VERSION, '8.1.0-dev', '>=') && $other->tz !== $this->tz) {
$other = $other->avoidMutation()->tz($this->tz);
}
// @codeCoverageIgnoreEnd
return parent::diff($other, (bool) $absolute);
}
public function diffAsCarbonInterval($date = null, $absolute = \true, array $skip = [])
{
return static::fixDiffInterval($this->diff($this->resolveCarbon($date), $absolute), $absolute, $skip);
}
public function diffInYears($date = null, $absolute = \true)
{
return (int) $this->diff($this->resolveCarbon($date), $absolute)->format('%r%y');
}
public function diffInQuarters($date = null, $absolute = \true)
{
return (int) ($this->diffInMonths($date, $absolute) / static::MONTHS_PER_QUARTER);
}
public function diffInMonths($date = null, $absolute = \true)
{
$date = $this->resolveCarbon($date)->avoidMutation()->tz($this->tz);
[$yearStart, $monthStart, $dayStart] = \explode('-', $this->format('Y-m-dHisu'));
[$yearEnd, $monthEnd, $dayEnd] = \explode('-', $date->format('Y-m-dHisu'));
$diff = ((int) $yearEnd - (int) $yearStart) * static::MONTHS_PER_YEAR + (int) $monthEnd - (int) $monthStart;
if ($diff > 0) {
$diff -= $dayStart > $dayEnd ? 1 : 0;
} elseif ($diff < 0) {
$diff += $dayStart < $dayEnd ? 1 : 0;
}
return $absolute ? \abs($diff) : $diff;
}
public function diffInWeeks($date = null, $absolute = \true)
{
return (int) ($this->diffInDays($date, $absolute) / static::DAYS_PER_WEEK);
}
public function diffInDays($date = null, $absolute = \true)
{
return $this->getIntervalDayDiff($this->diff($this->resolveCarbon($date), $absolute));
}
public function diffInDaysFiltered(Closure $callback, $date = null, $absolute = \true)
{
return $this->diffFiltered(CarbonInterval::day(), $callback, $date, $absolute);
}
public function diffInHoursFiltered(Closure $callback, $date = null, $absolute = \true)
{
return $this->diffFiltered(CarbonInterval::hour(), $callback, $date, $absolute);
}
public function diffFiltered(CarbonInterval $ci, Closure $callback, $date = null, $absolute = \true)
{
$start = $this;
$end = $this->resolveCarbon($date);
$inverse = \false;
if ($end < $start) {
$start = $end;
$end = $this;
$inverse = \true;
}
$options = CarbonPeriod::EXCLUDE_END_DATE | ($this->isMutable() ? 0 : CarbonPeriod::IMMUTABLE);
$diff = $ci->toPeriod($start, $end, $options)->filter($callback)->count();
return $inverse && !$absolute ? -$diff : $diff;
}
public function diffInWeekdays($date = null, $absolute = \true)
{
return $this->diffInDaysFiltered(static function (CarbonInterface $date) {
return $date->isWeekday();
}, $this->resolveCarbon($date)->avoidMutation()->modify($this->format('H:i:s.u')), $absolute);
}
public function diffInWeekendDays($date = null, $absolute = \true)
{
return $this->diffInDaysFiltered(static function (CarbonInterface $date) {
return $date->isWeekend();
}, $this->resolveCarbon($date)->avoidMutation()->modify($this->format('H:i:s.u')), $absolute);
}
public function diffInHours($date = null, $absolute = \true)
{
return (int) ($this->diffInSeconds($date, $absolute) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR);
}
public function diffInRealHours($date = null, $absolute = \true)
{
return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR);
}
public function diffInMinutes($date = null, $absolute = \true)
{
return (int) ($this->diffInSeconds($date, $absolute) / static::SECONDS_PER_MINUTE);
}
public function diffInRealMinutes($date = null, $absolute = \true)
{
return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE);
}
public function diffInSeconds($date = null, $absolute = \true)
{
$diff = $this->diff($date);
if ($diff->days === 0) {
$diff = static::fixDiffInterval($diff, $absolute);
}
$value = ((($diff->m || $diff->y ? $diff->days : $diff->d) * static::HOURS_PER_DAY + $diff->h) * static::MINUTES_PER_HOUR + $diff->i) * static::SECONDS_PER_MINUTE + $diff->s;
return $absolute || !$diff->invert ? $value : -$value;
}
public function diffInMicroseconds($date = null, $absolute = \true)
{
$diff = $this->diff($date);
$value = (int) \round((((($diff->m || $diff->y ? $diff->days : $diff->d) * static::HOURS_PER_DAY + $diff->h) * static::MINUTES_PER_HOUR + $diff->i) * static::SECONDS_PER_MINUTE + ($diff->f + $diff->s)) * static::MICROSECONDS_PER_SECOND);
return $absolute || !$diff->invert ? $value : -$value;
}
public function diffInMilliseconds($date = null, $absolute = \true)
{
return (int) ($this->diffInMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND);
}
public function diffInRealSeconds($date = null, $absolute = \true)
{
$date = $this->resolveCarbon($date);
$value = $date->getTimestamp() - $this->getTimestamp();
return $absolute ? \abs($value) : $value;
}
public function diffInRealMicroseconds($date = null, $absolute = \true)
{
$date = $this->resolveCarbon($date);
$value = ($date->timestamp - $this->timestamp) * static::MICROSECONDS_PER_SECOND + $date->micro - $this->micro;
return $absolute ? \abs($value) : $value;
}
public function diffInRealMilliseconds($date = null, $absolute = \true)
{
return (int) ($this->diffInRealMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND);
}
public function floatDiffInSeconds($date = null, $absolute = \true)
{
return (float) ($this->diffInMicroseconds($date, $absolute) / static::MICROSECONDS_PER_SECOND);
}
public function floatDiffInMinutes($date = null, $absolute = \true)
{
return $this->floatDiffInSeconds($date, $absolute) / static::SECONDS_PER_MINUTE;
}
public function floatDiffInHours($date = null, $absolute = \true)
{
return $this->floatDiffInMinutes($date, $absolute) / static::MINUTES_PER_HOUR;
}
public function floatDiffInDays($date = null, $absolute = \true)
{
$hoursDiff = $this->floatDiffInHours($date, $absolute);
$interval = $this->diff($date, $absolute);
if ($interval->y === 0 && $interval->m === 0 && $interval->d === 0) {
return $hoursDiff / static::HOURS_PER_DAY;
}
$daysDiff = $this->getIntervalDayDiff($interval);
return $daysDiff + \fmod($hoursDiff, static::HOURS_PER_DAY) / static::HOURS_PER_DAY;
}
public function floatDiffInWeeks($date = null, $absolute = \true)
{
return $this->floatDiffInDays($date, $absolute) / static::DAYS_PER_WEEK;
}
public function floatDiffInMonths($date = null, $absolute = \true)
{
$start = $this;
$end = $this->resolveCarbon($date);
$ascending = $start <= $end;
$sign = $absolute || $ascending ? 1 : -1;
if (!$ascending) {
[$start, $end] = [$end, $start];
}
$monthsDiff = $start->diffInMonths($end);
$floorEnd = $start->avoidMutation()->addMonths($monthsDiff);
if ($floorEnd >= $end) {
return $sign * $monthsDiff;
}
$startOfMonthAfterFloorEnd = $floorEnd->avoidMutation()->addMonth()->startOfMonth();
if ($startOfMonthAfterFloorEnd > $end) {
return $sign * ($monthsDiff + $floorEnd->floatDiffInDays($end) / $floorEnd->daysInMonth);
}
return $sign * ($monthsDiff + $floorEnd->floatDiffInDays($startOfMonthAfterFloorEnd) / $floorEnd->daysInMonth + $startOfMonthAfterFloorEnd->floatDiffInDays($end) / $end->daysInMonth);
}
public function floatDiffInYears($date = null, $absolute = \true)
{
$start = $this;
$end = $this->resolveCarbon($date);
$ascending = $start <= $end;
$sign = $absolute || $ascending ? 1 : -1;
if (!$ascending) {
[$start, $end] = [$end, $start];
}
$yearsDiff = $start->diffInYears($end);
$floorEnd = $start->avoidMutation()->addYears($yearsDiff);
if ($floorEnd >= $end) {
return $sign * $yearsDiff;
}
$startOfYearAfterFloorEnd = $floorEnd->avoidMutation()->addYear()->startOfYear();
if ($startOfYearAfterFloorEnd > $end) {
return $sign * ($yearsDiff + $floorEnd->floatDiffInDays($end) / $floorEnd->daysInYear);
}
return $sign * ($yearsDiff + $floorEnd->floatDiffInDays($startOfYearAfterFloorEnd) / $floorEnd->daysInYear + $startOfYearAfterFloorEnd->floatDiffInDays($end) / $end->daysInYear);
}
public function floatDiffInRealSeconds($date = null, $absolute = \true)
{
return $this->diffInRealMicroseconds($date, $absolute) / static::MICROSECONDS_PER_SECOND;
}
public function floatDiffInRealMinutes($date = null, $absolute = \true)
{
return $this->floatDiffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE;
}
public function floatDiffInRealHours($date = null, $absolute = \true)
{
return $this->floatDiffInRealMinutes($date, $absolute) / static::MINUTES_PER_HOUR;
}
public function floatDiffInRealDays($date = null, $absolute = \true)
{
$date = $this->resolveUTC($date);
$utc = $this->avoidMutation()->utc();
$hoursDiff = $utc->floatDiffInRealHours($date, $absolute);
return ($hoursDiff < 0 ? -1 : 1) * $utc->diffInDays($date) + \fmod($hoursDiff, static::HOURS_PER_DAY) / static::HOURS_PER_DAY;
}
public function floatDiffInRealWeeks($date = null, $absolute = \true)
{
return $this->floatDiffInRealDays($date, $absolute) / static::DAYS_PER_WEEK;
}
public function floatDiffInRealMonths($date = null, $absolute = \true)
{
$start = $this;
$end = $this->resolveCarbon($date);
$ascending = $start <= $end;
$sign = $absolute || $ascending ? 1 : -1;
if (!$ascending) {
[$start, $end] = [$end, $start];
}
$monthsDiff = $start->diffInMonths($end);
$floorEnd = $start->avoidMutation()->addMonths($monthsDiff);
if ($floorEnd >= $end) {
return $sign * $monthsDiff;
}
$startOfMonthAfterFloorEnd = $floorEnd->avoidMutation()->addMonth()->startOfMonth();
if ($startOfMonthAfterFloorEnd > $end) {
return $sign * ($monthsDiff + $floorEnd->floatDiffInRealDays($end) / $floorEnd->daysInMonth);
}
return $sign * ($monthsDiff + $floorEnd->floatDiffInRealDays($startOfMonthAfterFloorEnd) / $floorEnd->daysInMonth + $startOfMonthAfterFloorEnd->floatDiffInRealDays($end) / $end->daysInMonth);
}
public function floatDiffInRealYears($date = null, $absolute = \true)
{
$start = $this;
$end = $this->resolveCarbon($date);
$ascending = $start <= $end;
$sign = $absolute || $ascending ? 1 : -1;
if (!$ascending) {
[$start, $end] = [$end, $start];
}
$yearsDiff = $start->diffInYears($end);
$floorEnd = $start->avoidMutation()->addYears($yearsDiff);
if ($floorEnd >= $end) {
return $sign * $yearsDiff;
}
$startOfYearAfterFloorEnd = $floorEnd->avoidMutation()->addYear()->startOfYear();
if ($startOfYearAfterFloorEnd > $end) {
return $sign * ($yearsDiff + $floorEnd->floatDiffInRealDays($end) / $floorEnd->daysInYear);
}
return $sign * ($yearsDiff + $floorEnd->floatDiffInRealDays($startOfYearAfterFloorEnd) / $floorEnd->daysInYear + $startOfYearAfterFloorEnd->floatDiffInRealDays($end) / $end->daysInYear);
}
public function secondsSinceMidnight()
{
return $this->diffInSeconds($this->avoidMutation()->startOfDay());
}
public function secondsUntilEndOfDay()
{
return $this->diffInSeconds($this->avoidMutation()->endOfDay());
}
public function diffForHumans($other = null, $syntax = null, $short = \false, $parts = 1, $options = null)
{
if (\is_array($other)) {
$other['syntax'] = \array_key_exists('syntax', $other) ? $other['syntax'] : $syntax;
$syntax = $other;
$other = $syntax['other'] ?? null;
}
$intSyntax =& $syntax;
if (\is_array($syntax)) {
$syntax['syntax'] = $syntax['syntax'] ?? null;
$intSyntax =& $syntax['syntax'];
}
$intSyntax = (int) ($intSyntax ?? static::DIFF_RELATIVE_AUTO);
$intSyntax = $intSyntax === static::DIFF_RELATIVE_AUTO && $other === null ? static::DIFF_RELATIVE_TO_NOW : $intSyntax;
$parts = \min(7, \max(1, (int) $parts));
$skip = \is_array($syntax) ? $syntax['skip'] ?? [] : [];
return $this->diffAsCarbonInterval($other, \false, (array) $skip)->setLocalTranslator($this->getLocalTranslator())->forHumans($syntax, (bool) $short, $parts, $options ?? $this->localHumanDiffOptions ?? static::getHumanDiffOptions());
}
public function from($other = null, $syntax = null, $short = \false, $parts = 1, $options = null)
{
return $this->diffForHumans($other, $syntax, $short, $parts, $options);
}
public function since($other = null, $syntax = null, $short = \false, $parts = 1, $options = null)
{
return $this->diffForHumans($other, $syntax, $short, $parts, $options);
}
public function to($other = null, $syntax = null, $short = \false, $parts = 1, $options = null)
{
if (!$syntax && !$other) {
$syntax = CarbonInterface::DIFF_RELATIVE_TO_NOW;
}
return $this->resolveCarbon($other)->diffForHumans($this, $syntax, $short, $parts, $options);
}
public function until($other = null, $syntax = null, $short = \false, $parts = 1, $options = null)
{
return $this->to($other, $syntax, $short, $parts, $options);
}
public function fromNow($syntax = null, $short = \false, $parts = 1, $options = null)
{
$other = null;
if ($syntax instanceof DateTimeInterface) {
[$other, $syntax, $short, $parts, $options] = \array_pad(\func_get_args(), 5, null);
}
return $this->from($other, $syntax, $short, $parts, $options);
}
public function toNow($syntax = null, $short = \false, $parts = 1, $options = null)
{
return $this->to(null, $syntax, $short, $parts, $options);
}
public function ago($syntax = null, $short = \false, $parts = 1, $options = null)
{
$other = null;
if ($syntax instanceof DateTimeInterface) {
[$other, $syntax, $short, $parts, $options] = \array_pad(\func_get_args(), 5, null);
}
return $this->from($other, $syntax, $short, $parts, $options);
}
public function timespan($other = null, $timezone = null)
{
if (!$other instanceof DateTimeInterface) {
$other = static::parse($other, $timezone);
}
return $this->diffForHumans($other, ['join' => ', ', 'syntax' => CarbonInterface::DIFF_ABSOLUTE, 'options' => CarbonInterface::NO_ZERO_DIFF, 'parts' => -1]);
}
public function calendar($referenceTime = null, array $formats = [])
{
$current = $this->avoidMutation()->startOfDay();
$other = $this->resolveCarbon($referenceTime)->avoidMutation()->setTimezone($this->getTimezone())->startOfDay();
$diff = $other->diffInDays($current, \false);
$format = $diff < -6 ? 'sameElse' : ($diff < -1 ? 'lastWeek' : ($diff < 0 ? 'lastDay' : ($diff < 1 ? 'sameDay' : ($diff < 2 ? 'nextDay' : ($diff < 7 ? 'nextWeek' : 'sameElse')))));
$format = \array_merge($this->getCalendarFormats(), $formats)[$format];
if ($format instanceof Closure) {
$format = $format($current, $other) ?? '';
}
return $this->isoFormat((string) $format);
}
private function getIntervalDayDiff(DateInterval $interval) : int
{
$daysDiff = (int) $interval->format('%a');
$sign = $interval->format('%r') === '-' ? -1 : 1;
if (\is_int($interval->days) && $interval->y === 0 && $interval->m === 0 && \version_compare(\PHP_VERSION, '8.1.0-dev', '<') && \abs($interval->d - $daysDiff) === 1) {
$daysDiff = \abs($interval->d);
// @codeCoverageIgnore
}
return $daysDiff * $sign;
}
}
@@ -0,0 +1,35 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\CarbonInterval;
use MailPoetVendor\Carbon\Exceptions\InvalidIntervalException;
use DateInterval;
trait IntervalRounding
{
protected function callRoundMethod(string $method, array $parameters)
{
$action = \substr($method, 0, 4);
if ($action !== 'ceil') {
$action = \substr($method, 0, 5);
}
if (\in_array($action, ['round', 'floor', 'ceil'])) {
return $this->{$action . 'Unit'}(\substr($method, \strlen($action)), ...$parameters);
}
return null;
}
protected function roundWith($precision, $function)
{
$unit = 'second';
if ($precision instanceof DateInterval) {
$precision = (string) CarbonInterval::instance($precision, [], \true);
}
if (\is_string($precision) && \preg_match('/^\\s*(?<precision>\\d+)?\\s*(?<unit>\\w+)(?<other>\\W.*)?$/', $precision, $match)) {
if (\trim($match['other'] ?? '') !== '') {
throw new InvalidIntervalException('Rounding is only possible with single unit intervals.');
}
$precision = (int) ($match['precision'] ?: 1);
$unit = $match['unit'];
}
return $this->roundUnit($unit, $precision, $function);
}
}
@@ -0,0 +1,39 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Carbon;
use MailPoetVendor\Carbon\CarbonImmutable;
use MailPoetVendor\Carbon\CarbonInterface;
use Closure;
use DateTimeImmutable;
use DateTimeInterface;
trait IntervalStep
{
protected $step;
public function getStep() : ?Closure
{
return $this->step;
}
public function setStep(?Closure $step) : void
{
$this->step = $step;
}
public function convertDate(DateTimeInterface $dateTime, bool $negated = \false) : CarbonInterface
{
$carbonDate = $dateTime instanceof CarbonInterface ? $dateTime : $this->resolveCarbon($dateTime);
if ($this->step) {
return $carbonDate->setDateTimeFrom(($this->step)($carbonDate->avoidMutation(), $negated));
}
if ($negated) {
return $carbonDate->rawSub($this);
}
return $carbonDate->rawAdd($this);
}
private function resolveCarbon(DateTimeInterface $dateTime)
{
if ($dateTime instanceof DateTimeImmutable) {
return CarbonImmutable::instance($dateTime);
}
return Carbon::instance($dateTime);
}
}
@@ -0,0 +1,372 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\CarbonInterface;
use MailPoetVendor\Carbon\Exceptions\InvalidTypeException;
use MailPoetVendor\Carbon\Exceptions\NotLocaleAwareException;
use MailPoetVendor\Carbon\Language;
use MailPoetVendor\Carbon\Translator;
use MailPoetVendor\Carbon\TranslatorStrongTypeInterface;
use Closure;
use MailPoetVendor\Symfony\Component\Translation\TranslatorBagInterface;
use MailPoetVendor\Symfony\Component\Translation\TranslatorInterface;
use MailPoetVendor\Symfony\Contracts\Translation\LocaleAwareInterface;
use MailPoetVendor\Symfony\Contracts\Translation\TranslatorInterface as ContractsTranslatorInterface;
// @codeCoverageIgnoreStart
if (\interface_exists('MailPoetVendor\\Symfony\\Contracts\\Translation\\TranslatorInterface') && !\interface_exists('MailPoetVendor\\Symfony\\Component\\Translation\\TranslatorInterface')) {
\class_alias('MailPoetVendor\\Symfony\\Contracts\\Translation\\TranslatorInterface', 'MailPoetVendor\\Symfony\\Component\\Translation\\TranslatorInterface');
}
// @codeCoverageIgnoreEnd
trait Localization
{
protected static $translator;
protected $localTranslator;
protected static $humanDiffOptions = CarbonInterface::NO_ZERO_DIFF;
public static function setHumanDiffOptions($humanDiffOptions)
{
static::$humanDiffOptions = $humanDiffOptions;
}
public static function enableHumanDiffOption($humanDiffOption)
{
static::$humanDiffOptions = static::getHumanDiffOptions() | $humanDiffOption;
}
public static function disableHumanDiffOption($humanDiffOption)
{
static::$humanDiffOptions = static::getHumanDiffOptions() & ~$humanDiffOption;
}
public static function getHumanDiffOptions()
{
return static::$humanDiffOptions;
}
public static function getTranslator()
{
return static::translator();
}
public static function setTranslator(TranslatorInterface $translator)
{
static::$translator = $translator;
}
public function hasLocalTranslator()
{
return isset($this->localTranslator);
}
public function getLocalTranslator()
{
return $this->localTranslator ?: static::translator();
}
public function setLocalTranslator(TranslatorInterface $translator)
{
$this->localTranslator = $translator;
return $this;
}
public static function getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null)
{
if (!($translator instanceof TranslatorBagInterface && $translator instanceof TranslatorInterface)) {
throw new InvalidTypeException('Translator does not implement ' . TranslatorInterface::class . ' and ' . TranslatorBagInterface::class . '. ' . (\is_object($translator) ? \get_class($translator) : \gettype($translator)) . ' has been given.');
}
if (!$locale && $translator instanceof LocaleAwareInterface) {
$locale = $translator->getLocale();
}
$result = self::getFromCatalogue($translator, $translator->getCatalogue($locale), $key);
return $result === $key ? $default : $result;
}
public function getTranslationMessage(string $key, ?string $locale = null, ?string $default = null, $translator = null)
{
return static::getTranslationMessageWith($translator ?: $this->getLocalTranslator(), $key, $locale, $default);
}
public static function translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null) : string
{
$message = static::getTranslationMessageWith($translator, $key, null, $key);
if ($message instanceof Closure) {
return (string) $message(...\array_values($parameters));
}
if ($number !== null) {
$parameters['%count%'] = $number;
}
if (isset($parameters['%count%'])) {
$parameters[':count'] = $parameters['%count%'];
}
// @codeCoverageIgnoreStart
$choice = $translator instanceof ContractsTranslatorInterface ? $translator->trans($key, $parameters) : $translator->transChoice($key, $number, $parameters);
// @codeCoverageIgnoreEnd
return (string) $choice;
}
public function translate(string $key, array $parameters = [], $number = null, ?TranslatorInterface $translator = null, bool $altNumbers = \false) : string
{
$translation = static::translateWith($translator ?: $this->getLocalTranslator(), $key, $parameters, $number);
if ($number !== null && $altNumbers) {
return \str_replace($number, $this->translateNumber($number), $translation);
}
return $translation;
}
public function translateNumber(int $number) : string
{
$translateKey = "alt_numbers.{$number}";
$symbol = $this->translate($translateKey);
if ($symbol !== $translateKey) {
return $symbol;
}
if ($number > 99 && $this->translate('alt_numbers.99') !== 'alt_numbers.99') {
$start = '';
foreach ([10000, 1000, 100] as $exp) {
$key = "alt_numbers_pow.{$exp}";
if ($number >= $exp && $number < $exp * 10 && ($pow = $this->translate($key)) !== $key) {
$unit = \floor($number / $exp);
$number -= $unit * $exp;
$start .= ($unit > 1 ? $this->translate("alt_numbers.{$unit}") : '') . $pow;
}
}
$result = '';
while ($number) {
$chunk = $number % 100;
$result = $this->translate("alt_numbers.{$chunk}") . $result;
$number = \floor($number / 100);
}
return "{$start}{$result}";
}
if ($number > 9 && $this->translate('alt_numbers.9') !== 'alt_numbers.9') {
$result = '';
while ($number) {
$chunk = $number % 10;
$result = $this->translate("alt_numbers.{$chunk}") . $result;
$number = \floor($number / 10);
}
return $result;
}
return (string) $number;
}
public static function translateTimeString($timeString, $from = null, $to = null, $mode = CarbonInterface::TRANSLATE_ALL)
{
// Fallback source and destination locales
$from = $from ?: static::getLocale();
$to = $to ?: 'en';
if ($from === $to) {
return $timeString;
}
// Standardize apostrophe
$timeString = \strtr($timeString, ['' => "'"]);
$fromTranslations = [];
$toTranslations = [];
foreach (['from', 'to'] as $key) {
$language = ${$key};
$translator = Translator::get($language);
$translations = $translator->getMessages();
if (!isset($translations[$language])) {
return $timeString;
}
$translationKey = $key . 'Translations';
$messages = $translations[$language];
$months = $messages['months'] ?? [];
$weekdays = $messages['weekdays'] ?? [];
$meridiem = $messages['meridiem'] ?? ['AM', 'PM'];
if (isset($messages['ordinal_words'])) {
$timeString = self::replaceOrdinalWords($timeString, $key === 'from' ? \array_flip($messages['ordinal_words']) : $messages['ordinal_words']);
}
if ($key === 'from') {
foreach (['months', 'weekdays'] as $variable) {
$list = $messages[$variable . '_standalone'] ?? null;
if ($list) {
foreach (${$variable} as $index => &$name) {
$name .= '|' . $messages[$variable . '_standalone'][$index];
}
}
}
}
${$translationKey} = \array_merge($mode & CarbonInterface::TRANSLATE_MONTHS ? static::getTranslationArray($months, 12, $timeString) : [], $mode & CarbonInterface::TRANSLATE_MONTHS ? static::getTranslationArray($messages['months_short'] ?? [], 12, $timeString) : [], $mode & CarbonInterface::TRANSLATE_DAYS ? static::getTranslationArray($weekdays, 7, $timeString) : [], $mode & CarbonInterface::TRANSLATE_DAYS ? static::getTranslationArray($messages['weekdays_short'] ?? [], 7, $timeString) : [], $mode & CarbonInterface::TRANSLATE_DIFF ? static::translateWordsByKeys(['diff_now', 'diff_today', 'diff_yesterday', 'diff_tomorrow', 'diff_before_yesterday', 'diff_after_tomorrow'], $messages, $key) : [], $mode & CarbonInterface::TRANSLATE_UNITS ? static::translateWordsByKeys(['year', 'month', 'week', 'day', 'hour', 'minute', 'second'], $messages, $key) : [], $mode & CarbonInterface::TRANSLATE_MERIDIEM ? \array_map(function ($hour) use($meridiem) {
if (\is_array($meridiem)) {
return $meridiem[$hour < 12 ? 0 : 1];
}
return $meridiem($hour, 0, \false);
}, \range(0, 23)) : []);
}
return \substr(\preg_replace_callback('/(?<=[\\d\\s+.\\/,_-])(' . \implode('|', $fromTranslations) . ')(?=[\\d\\s+.\\/,_-])/iu', function ($match) use($fromTranslations, $toTranslations) {
[$chunk] = $match;
foreach ($fromTranslations as $index => $word) {
if (\preg_match("/^{$word}\$/iu", $chunk)) {
return $toTranslations[$index] ?? '';
}
}
return $chunk;
// @codeCoverageIgnore
}, " {$timeString} "), 1, -1);
}
public function translateTimeStringTo($timeString, $to = null)
{
return static::translateTimeString($timeString, $this->getTranslatorLocale(), $to);
}
public function locale(string $locale = null, ...$fallbackLocales)
{
if ($locale === null) {
return $this->getTranslatorLocale();
}
if (!$this->localTranslator || $this->getTranslatorLocale($this->localTranslator) !== $locale) {
$translator = Translator::get($locale);
if (!empty($fallbackLocales)) {
$translator->setFallbackLocales($fallbackLocales);
foreach ($fallbackLocales as $fallbackLocale) {
$messages = Translator::get($fallbackLocale)->getMessages();
if (isset($messages[$fallbackLocale])) {
$translator->setMessages($fallbackLocale, $messages[$fallbackLocale]);
}
}
}
$this->localTranslator = $translator;
}
return $this;
}
public static function getLocale()
{
return static::getLocaleAwareTranslator()->getLocale();
}
public static function setLocale($locale)
{
return static::getLocaleAwareTranslator()->setLocale($locale) !== \false;
}
public static function setFallbackLocale($locale)
{
$translator = static::getTranslator();
if (\method_exists($translator, 'setFallbackLocales')) {
$translator->setFallbackLocales([$locale]);
if ($translator instanceof Translator) {
$preferredLocale = $translator->getLocale();
$translator->setMessages($preferredLocale, \array_replace_recursive($translator->getMessages()[$locale] ?? [], Translator::get($locale)->getMessages()[$locale] ?? [], $translator->getMessages($preferredLocale)));
}
}
}
public static function getFallbackLocale()
{
$translator = static::getTranslator();
if (\method_exists($translator, 'getFallbackLocales')) {
return $translator->getFallbackLocales()[0] ?? null;
}
return null;
}
public static function executeWithLocale($locale, $func)
{
$currentLocale = static::getLocale();
$result = $func(static::setLocale($locale) ? static::getLocale() : \false, static::translator());
static::setLocale($currentLocale);
return $result;
}
public static function localeHasShortUnits($locale)
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
return $newLocale && (($y = static::translateWith($translator, 'y')) !== 'y' && $y !== static::translateWith($translator, 'year')) || ($y = static::translateWith($translator, 'd')) !== 'd' && $y !== static::translateWith($translator, 'day') || ($y = static::translateWith($translator, 'h')) !== 'h' && $y !== static::translateWith($translator, 'hour');
});
}
public static function localeHasDiffSyntax($locale)
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
if (!$newLocale) {
return \false;
}
foreach (['ago', 'from_now', 'before', 'after'] as $key) {
if ($translator instanceof TranslatorBagInterface && self::getFromCatalogue($translator, $translator->getCatalogue($newLocale), $key) instanceof Closure) {
continue;
}
if ($translator->trans($key) === $key) {
return \false;
}
}
return \true;
});
}
public static function localeHasDiffOneDayWords($locale)
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
return $newLocale && $translator->trans('diff_now') !== 'diff_now' && $translator->trans('diff_yesterday') !== 'diff_yesterday' && $translator->trans('diff_tomorrow') !== 'diff_tomorrow';
});
}
public static function localeHasDiffTwoDayWords($locale)
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
return $newLocale && $translator->trans('diff_before_yesterday') !== 'diff_before_yesterday' && $translator->trans('diff_after_tomorrow') !== 'diff_after_tomorrow';
});
}
public static function localeHasPeriodSyntax($locale)
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
return $newLocale && $translator->trans('period_recurrences') !== 'period_recurrences' && $translator->trans('period_interval') !== 'period_interval' && $translator->trans('period_start_date') !== 'period_start_date' && $translator->trans('period_end_date') !== 'period_end_date';
});
}
public static function getAvailableLocales()
{
$translator = static::getLocaleAwareTranslator();
return $translator instanceof Translator ? $translator->getAvailableLocales() : [$translator->getLocale()];
}
public static function getAvailableLocalesInfo()
{
$languages = [];
foreach (static::getAvailableLocales() as $id) {
$languages[$id] = new Language($id);
}
return $languages;
}
protected static function translator()
{
if (static::$translator === null) {
static::$translator = Translator::get();
}
return static::$translator;
}
protected function getTranslatorLocale($translator = null) : ?string
{
if (\func_num_args() === 0) {
$translator = $this->getLocalTranslator();
}
$translator = static::getLocaleAwareTranslator($translator);
return $translator ? $translator->getLocale() : null;
}
protected static function getLocaleAwareTranslator($translator = null)
{
if (\func_num_args() === 0) {
$translator = static::translator();
}
if ($translator && !($translator instanceof LocaleAwareInterface || \method_exists($translator, 'getLocale'))) {
throw new NotLocaleAwareException($translator);
// @codeCoverageIgnore
}
return $translator;
}
private static function getFromCatalogue($translator, $catalogue, string $id, string $domain = 'messages')
{
return $translator instanceof TranslatorStrongTypeInterface ? $translator->getFromCatalogue($catalogue, $id, $domain) : $catalogue->get($id, $domain);
}
private static function cleanWordFromTranslationString($word)
{
$word = \str_replace([':count', '%count', ':time'], '', $word);
$word = \strtr($word, ['' => "'"]);
$word = \preg_replace('/({\\d+(,(\\d+|Inf))?}|[\\[\\]]\\d+(,(\\d+|Inf))?[\\[\\]])/', '', $word);
return \trim($word);
}
private static function translateWordsByKeys($keys, $messages, $key) : array
{
return \array_map(function ($wordKey) use($messages, $key) {
$message = $key === 'from' && isset($messages[$wordKey . '_regexp']) ? $messages[$wordKey . '_regexp'] : $messages[$wordKey] ?? null;
if (!$message) {
return '>>DO NOT REPLACE<<';
}
$parts = \explode('|', $message);
return $key === 'to' ? self::cleanWordFromTranslationString(\end($parts)) : '(?:' . \implode('|', \array_map([static::class, 'cleanWordFromTranslationString'], $parts)) . ')';
}, $keys);
}
private static function getTranslationArray($translation, $length, $timeString) : array
{
$filler = '>>DO NOT REPLACE<<';
if (\is_array($translation)) {
return \array_pad($translation, $length, $filler);
}
$list = [];
$date = static::now();
for ($i = 0; $i < $length; $i++) {
$list[] = $translation($date, $timeString, $i) ?? $filler;
}
return $list;
}
private static function replaceOrdinalWords(string $timeString, array $ordinalWords) : string
{
return \preg_replace_callback('/(?<![a-z])[a-z]+(?![a-z])/i', function (array $match) use($ordinalWords) {
return $ordinalWords[\mb_strtolower($match[0])] ?? $match[0];
}, $timeString);
}
}
@@ -0,0 +1,42 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
trait Macro
{
use Mixin;
protected static $globalMacros = [];
protected static $globalGenericMacros = [];
public static function macro($name, $macro)
{
static::$globalMacros[$name] = $macro;
}
public static function resetMacros()
{
static::$globalMacros = [];
static::$globalGenericMacros = [];
}
public static function genericMacro($macro, $priority = 0)
{
if (!isset(static::$globalGenericMacros[$priority])) {
static::$globalGenericMacros[$priority] = [];
\krsort(static::$globalGenericMacros, \SORT_NUMERIC);
}
static::$globalGenericMacros[$priority][] = $macro;
}
public static function hasMacro($name)
{
return isset(static::$globalMacros[$name]);
}
public static function getMacro($name)
{
return static::$globalMacros[$name] ?? null;
}
public function hasLocalMacro($name)
{
return $this->localMacros && isset($this->localMacros[$name]) || static::hasMacro($name);
}
public function getLocalMacro($name)
{
return ($this->localMacros ?? [])[$name] ?? static::getMacro($name);
}
}
@@ -0,0 +1,16 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
trait MagicParameter
{
private function getMagicParameter(array $parameters, int $index, string $key, $default)
{
if (\array_key_exists($index, $parameters)) {
return $parameters[$index];
}
if (\array_key_exists($key, $parameters)) {
return $parameters[$key];
}
return $default;
}
}
@@ -0,0 +1,110 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\CarbonInterface;
use MailPoetVendor\Carbon\CarbonInterval;
use MailPoetVendor\Carbon\CarbonPeriod;
use Closure;
use Generator;
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
use Throwable;
trait Mixin
{
protected static $macroContextStack = [];
public static function mixin($mixin)
{
\is_string($mixin) && \trait_exists($mixin) ? self::loadMixinTrait($mixin) : self::loadMixinClass($mixin);
}
private static function loadMixinClass($mixin)
{
$methods = (new ReflectionClass($mixin))->getMethods(ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED);
foreach ($methods as $method) {
if ($method->isConstructor() || $method->isDestructor()) {
continue;
}
$method->setAccessible(\true);
static::macro($method->name, $method->invoke($mixin));
}
}
private static function loadMixinTrait($trait)
{
$context = eval(self::getAnonymousClassCodeForTrait($trait));
$className = \get_class($context);
$baseClass = static::class;
foreach (self::getMixableMethods($context) as $name) {
$closureBase = Closure::fromCallable([$context, $name]);
static::macro($name, function (...$parameters) use($closureBase, $className, $baseClass) {
$downContext = isset($this) ? $this : new $baseClass();
$context = isset($this) ? $this->cast($className) : new $className();
try {
// @ is required to handle error if not converted into exceptions
$closure = @$closureBase->bindTo($context);
} catch (Throwable $throwable) {
// @codeCoverageIgnore
$closure = $closureBase;
// @codeCoverageIgnore
}
// in case of errors not converted into exceptions
$closure = $closure ?: $closureBase;
$result = $closure(...$parameters);
if (!$result instanceof $className) {
return $result;
}
if ($downContext instanceof CarbonInterface && $result instanceof CarbonInterface) {
if ($context !== $result) {
$downContext = $downContext->copy();
}
return $downContext->setTimezone($result->getTimezone())->modify($result->format('Y-m-d H:i:s.u'))->settings($result->getSettings());
}
if ($downContext instanceof CarbonInterval && $result instanceof CarbonInterval) {
if ($context !== $result) {
$downContext = $downContext->copy();
}
$downContext->copyProperties($result);
self::copyStep($downContext, $result);
self::copyNegativeUnits($downContext, $result);
return $downContext->settings($result->getSettings());
}
if ($downContext instanceof CarbonPeriod && $result instanceof CarbonPeriod) {
if ($context !== $result) {
$downContext = $downContext->copy();
}
return $downContext->setDates($result->getStartDate(), $result->getEndDate())->setRecurrences($result->getRecurrences())->setOptions($result->getOptions())->settings($result->getSettings());
}
return $result;
});
}
}
private static function getAnonymousClassCodeForTrait(string $trait)
{
return 'return new class() extends ' . static::class . ' {use ' . $trait . ';};';
}
private static function getMixableMethods(self $context) : Generator
{
foreach (\get_class_methods($context) as $name) {
if (\method_exists(static::class, $name)) {
continue;
}
(yield $name);
}
}
protected static function bindMacroContext($context, callable $callable)
{
static::$macroContextStack[] = $context;
try {
return $callable();
} finally {
\array_pop(static::$macroContextStack);
}
}
protected static function context()
{
return \end(static::$macroContextStack) ?: null;
}
protected static function this()
{
return \end(static::$macroContextStack) ?: new static();
}
}
@@ -0,0 +1,157 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\CarbonInterface;
use ReturnTypeWillChange;
trait Modifiers
{
protected static $midDayAt = 12;
public static function getMidDayAt()
{
return static::$midDayAt;
}
public static function setMidDayAt($hour)
{
static::$midDayAt = $hour;
}
public function midDay()
{
return $this->setTime(static::$midDayAt, 0, 0, 0);
}
public function next($modifier = null)
{
if ($modifier === null) {
$modifier = $this->dayOfWeek;
}
return $this->change('next ' . (\is_string($modifier) ? $modifier : static::$days[$modifier]));
}
private function nextOrPreviousDay($weekday = \true, $forward = \true)
{
$date = $this;
$step = $forward ? 1 : -1;
do {
$date = $date->addDays($step);
} while ($weekday ? $date->isWeekend() : $date->isWeekday());
return $date;
}
public function nextWeekday()
{
return $this->nextOrPreviousDay();
}
public function previousWeekday()
{
return $this->nextOrPreviousDay(\true, \false);
}
public function nextWeekendDay()
{
return $this->nextOrPreviousDay(\false);
}
public function previousWeekendDay()
{
return $this->nextOrPreviousDay(\false, \false);
}
public function previous($modifier = null)
{
if ($modifier === null) {
$modifier = $this->dayOfWeek;
}
return $this->change('last ' . (\is_string($modifier) ? $modifier : static::$days[$modifier]));
}
public function firstOfMonth($dayOfWeek = null)
{
$date = $this->startOfDay();
if ($dayOfWeek === null) {
return $date->day(1);
}
return $date->modify('first ' . static::$days[$dayOfWeek] . ' of ' . $date->rawFormat('F') . ' ' . $date->year);
}
public function lastOfMonth($dayOfWeek = null)
{
$date = $this->startOfDay();
if ($dayOfWeek === null) {
return $date->day($date->daysInMonth);
}
return $date->modify('last ' . static::$days[$dayOfWeek] . ' of ' . $date->rawFormat('F') . ' ' . $date->year);
}
public function nthOfMonth($nth, $dayOfWeek)
{
$date = $this->avoidMutation()->firstOfMonth();
$check = $date->rawFormat('Y-m');
$date = $date->modify('+' . $nth . ' ' . static::$days[$dayOfWeek]);
return $date->rawFormat('Y-m') === $check ? $this->modify((string) $date) : \false;
}
public function firstOfQuarter($dayOfWeek = null)
{
return $this->setDate($this->year, $this->quarter * static::MONTHS_PER_QUARTER - 2, 1)->firstOfMonth($dayOfWeek);
}
public function lastOfQuarter($dayOfWeek = null)
{
return $this->setDate($this->year, $this->quarter * static::MONTHS_PER_QUARTER, 1)->lastOfMonth($dayOfWeek);
}
public function nthOfQuarter($nth, $dayOfWeek)
{
$date = $this->avoidMutation()->day(1)->month($this->quarter * static::MONTHS_PER_QUARTER);
$lastMonth = $date->month;
$year = $date->year;
$date = $date->firstOfQuarter()->modify('+' . $nth . ' ' . static::$days[$dayOfWeek]);
return $lastMonth < $date->month || $year !== $date->year ? \false : $this->modify((string) $date);
}
public function firstOfYear($dayOfWeek = null)
{
return $this->month(1)->firstOfMonth($dayOfWeek);
}
public function lastOfYear($dayOfWeek = null)
{
return $this->month(static::MONTHS_PER_YEAR)->lastOfMonth($dayOfWeek);
}
public function nthOfYear($nth, $dayOfWeek)
{
$date = $this->avoidMutation()->firstOfYear()->modify('+' . $nth . ' ' . static::$days[$dayOfWeek]);
return $this->year === $date->year ? $this->modify((string) $date) : \false;
}
public function average($date = null)
{
return $this->addRealMicroseconds((int) ($this->diffInRealMicroseconds($this->resolveCarbon($date), \false) / 2));
}
public function closest($date1, $date2)
{
return $this->diffInRealMicroseconds($date1) < $this->diffInRealMicroseconds($date2) ? $date1 : $date2;
}
public function farthest($date1, $date2)
{
return $this->diffInRealMicroseconds($date1) > $this->diffInRealMicroseconds($date2) ? $date1 : $date2;
}
public function min($date = null)
{
$date = $this->resolveCarbon($date);
return $this->lt($date) ? $this : $date;
}
public function minimum($date = null)
{
return $this->min($date);
}
public function max($date = null)
{
$date = $this->resolveCarbon($date);
return $this->gt($date) ? $this : $date;
}
public function maximum($date = null)
{
return $this->max($date);
}
#[\ReturnTypeWillChange]
public function modify($modify)
{
return parent::modify((string) $modify);
}
public function change($modifier)
{
return $this->modify(\preg_replace_callback('/^(next|previous|last)\\s+(\\d{1,2}(h|am|pm|:\\d{1,2}(:\\d{1,2})?))$/i', function ($match) {
$match[2] = \str_replace('h', ':00', $match[2]);
$test = $this->avoidMutation()->modify($match[2]);
$method = $match[1] === 'next' ? 'lt' : 'gt';
$match[1] = $test->{$method}($this) ? $match[1] . ' day' : 'today';
return $match[1] . ' ' . $match[2];
}, \strtr(\trim($modifier), [' at ' => ' ', 'just now' => 'now', 'after tomorrow' => 'tomorrow +1 day', 'before yesterday' => 'yesterday -1 day'])));
}
}
@@ -0,0 +1,27 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Carbon;
use MailPoetVendor\Carbon\CarbonImmutable;
trait Mutability
{
use Cast;
public static function isMutable()
{
return \false;
}
public static function isImmutable()
{
return !static::isMutable();
}
public function toMutable()
{
$date = $this->cast(Carbon::class);
return $date;
}
public function toImmutable()
{
$date = $this->cast(CarbonImmutable::class);
return $date;
}
}
@@ -0,0 +1,7 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
trait ObjectInitialisation
{
protected $constructedObjectId;
}
@@ -0,0 +1,171 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\CarbonInterface;
use DateTimeInterface;
use Throwable;
trait Options
{
use Localization;
public static $PHPIntSize = \PHP_INT_SIZE;
protected static $weekStartsAt = CarbonInterface::MONDAY;
protected static $weekEndsAt = CarbonInterface::SUNDAY;
protected static $weekendDays = [CarbonInterface::SATURDAY, CarbonInterface::SUNDAY];
protected static $regexFormats = [
'd' => '(3[01]|[12][0-9]|0[1-9])',
'D' => '(Sun|Mon|Tue|Wed|Thu|Fri|Sat)',
'j' => '([123][0-9]|[1-9])',
'l' => '([a-zA-Z]{2,})',
'N' => '([1-7])',
'S' => '(st|nd|rd|th)',
'w' => '([0-6])',
'z' => '(36[0-5]|3[0-5][0-9]|[12][0-9]{2}|[1-9]?[0-9])',
'W' => '(5[012]|[1-4][0-9]|0?[1-9])',
'F' => '([a-zA-Z]{2,})',
'm' => '(1[012]|0[1-9])',
'M' => '([a-zA-Z]{3})',
'n' => '(1[012]|[1-9])',
't' => '(2[89]|3[01])',
'L' => '(0|1)',
'o' => '([1-9][0-9]{0,4})',
'Y' => '([1-9]?[0-9]{4})',
'y' => '([0-9]{2})',
'a' => '(am|pm)',
'A' => '(AM|PM)',
'B' => '([0-9]{3})',
'g' => '(1[012]|[1-9])',
'G' => '(2[0-3]|1?[0-9])',
'h' => '(1[012]|0[1-9])',
'H' => '(2[0-3]|[01][0-9])',
'i' => '([0-5][0-9])',
's' => '([0-5][0-9])',
'u' => '([0-9]{1,6})',
'v' => '([0-9]{1,3})',
'e' => '([a-zA-Z]{1,5})|([a-zA-Z]*\\/[a-zA-Z]*)',
'I' => '(0|1)',
'O' => '([+-](1[0123]|0[0-9])[0134][05])',
'P' => '([+-](1[0123]|0[0-9]):[0134][05])',
'p' => '(Z|[+-](1[0123]|0[0-9]):[0134][05])',
'T' => '([a-zA-Z]{1,5})',
'Z' => '(-?[1-5]?[0-9]{1,4})',
'U' => '([0-9]*)',
// The formats below are combinations of the above formats.
'c' => '(([1-9]?[0-9]{4})-(1[012]|0[1-9])-(3[01]|[12][0-9]|0[1-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])[+-](1[012]|0[0-9]):([0134][05]))',
// Y-m-dTH:i:sP
'r' => '(([a-zA-Z]{3}), ([123][0-9]|0[1-9]) ([a-zA-Z]{3}) ([1-9]?[0-9]{4}) (2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9]) [+-](1[012]|0[0-9])([0134][05]))',
];
protected static $regexFormatModifiers = ['*' => '.+', ' ' => '[ ]', '#' => '[;:\\/.,()-]', '?' => '([^a]|[a])', '!' => '', '|' => '', '+' => ''];
protected static $monthsOverflow = \true;
protected static $yearsOverflow = \true;
protected static $strictModeEnabled = \true;
protected static $formatFunction;
protected static $createFromFormatFunction;
protected static $parseFunction;
protected $localMonthsOverflow;
protected $localYearsOverflow;
protected $localStrictModeEnabled;
protected $localHumanDiffOptions;
protected $localToStringFormat;
protected $localSerializer;
protected $localMacros;
protected $localGenericMacros;
protected $localFormatFunction;
public static function useStrictMode($strictModeEnabled = \true)
{
static::$strictModeEnabled = $strictModeEnabled;
}
public static function isStrictModeEnabled()
{
return static::$strictModeEnabled;
}
public static function useMonthsOverflow($monthsOverflow = \true)
{
static::$monthsOverflow = $monthsOverflow;
}
public static function resetMonthsOverflow()
{
static::$monthsOverflow = \true;
}
public static function shouldOverflowMonths()
{
return static::$monthsOverflow;
}
public static function useYearsOverflow($yearsOverflow = \true)
{
static::$yearsOverflow = $yearsOverflow;
}
public static function resetYearsOverflow()
{
static::$yearsOverflow = \true;
}
public static function shouldOverflowYears()
{
return static::$yearsOverflow;
}
public function settings(array $settings)
{
$this->localStrictModeEnabled = $settings['strictMode'] ?? null;
$this->localMonthsOverflow = $settings['monthOverflow'] ?? null;
$this->localYearsOverflow = $settings['yearOverflow'] ?? null;
$this->localHumanDiffOptions = $settings['humanDiffOptions'] ?? null;
$this->localToStringFormat = $settings['toStringFormat'] ?? null;
$this->localSerializer = $settings['toJsonFormat'] ?? null;
$this->localMacros = $settings['macros'] ?? null;
$this->localGenericMacros = $settings['genericMacros'] ?? null;
$this->localFormatFunction = $settings['formatFunction'] ?? null;
if (isset($settings['locale'])) {
$locales = $settings['locale'];
if (!\is_array($locales)) {
$locales = [$locales];
}
$this->locale(...$locales);
}
if (isset($settings['innerTimezone'])) {
return $this->setTimezone($settings['innerTimezone']);
}
if (isset($settings['timezone'])) {
return $this->shiftTimezone($settings['timezone']);
}
return $this;
}
public function getSettings()
{
$settings = [];
$map = ['localStrictModeEnabled' => 'strictMode', 'localMonthsOverflow' => 'monthOverflow', 'localYearsOverflow' => 'yearOverflow', 'localHumanDiffOptions' => 'humanDiffOptions', 'localToStringFormat' => 'toStringFormat', 'localSerializer' => 'toJsonFormat', 'localMacros' => 'macros', 'localGenericMacros' => 'genericMacros', 'locale' => 'locale', 'tzName' => 'timezone', 'localFormatFunction' => 'formatFunction'];
foreach ($map as $property => $key) {
$value = $this->{$property} ?? null;
if ($value !== null && ($key !== 'locale' || $value !== 'en' || $this->localTranslator)) {
$settings[$key] = $value;
}
}
return $settings;
}
public function __debugInfo()
{
$infos = \array_filter(\get_object_vars($this), static function ($var) {
return $var;
});
foreach (['dumpProperties', 'constructedObjectId', 'constructed'] as $property) {
if (isset($infos[$property])) {
unset($infos[$property]);
}
}
$this->addExtraDebugInfos($infos);
return $infos;
}
protected function addExtraDebugInfos(&$infos) : void
{
if ($this instanceof DateTimeInterface) {
try {
if (!isset($infos['date'])) {
$infos['date'] = $this->format(CarbonInterface::MOCK_DATETIME_FORMAT);
}
if (!isset($infos['timezone'])) {
$infos['timezone'] = $this->tzName;
}
} catch (Throwable $exception) {
// noop
}
}
}
}
@@ -0,0 +1,125 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\CarbonInterface;
use MailPoetVendor\Carbon\Exceptions\UnknownUnitException;
trait Rounding
{
use IntervalRounding;
public function roundUnit($unit, $precision = 1, $function = 'round')
{
$metaUnits = [
// @call roundUnit
'millennium' => [static::YEARS_PER_MILLENNIUM, 'year'],
// @call roundUnit
'century' => [static::YEARS_PER_CENTURY, 'year'],
// @call roundUnit
'decade' => [static::YEARS_PER_DECADE, 'year'],
// @call roundUnit
'quarter' => [static::MONTHS_PER_QUARTER, 'month'],
// @call roundUnit
'millisecond' => [1000, 'microsecond'],
];
$normalizedUnit = static::singularUnit($unit);
$ranges = \array_merge(static::getRangesByUnit($this->daysInMonth), [
// @call roundUnit
'microsecond' => [0, 999999],
]);
$factor = 1;
if ($normalizedUnit === 'week') {
$normalizedUnit = 'day';
$precision *= static::DAYS_PER_WEEK;
}
if (isset($metaUnits[$normalizedUnit])) {
[$factor, $normalizedUnit] = $metaUnits[$normalizedUnit];
}
$precision *= $factor;
if (!isset($ranges[$normalizedUnit])) {
throw new UnknownUnitException($unit);
}
$found = \false;
$fraction = 0;
$arguments = null;
$initialValue = null;
$factor = $this->year < 0 ? -1 : 1;
$changes = [];
$minimumInc = null;
foreach ($ranges as $unit => [$minimum, $maximum]) {
if ($normalizedUnit === $unit) {
$arguments = [$this->{$unit}, $minimum];
$initialValue = $this->{$unit};
$fraction = $precision - \floor($precision);
$found = \true;
continue;
}
if ($found) {
$delta = $maximum + 1 - $minimum;
$factor /= $delta;
$fraction *= $delta;
$inc = ($this->{$unit} - $minimum) * $factor;
if ($inc !== 0.0) {
$minimumInc = $minimumInc ?? $arguments[0] / \pow(2, 52);
// If value is still the same when adding a non-zero increment/decrement,
// it means precision got lost in the addition
if (\abs($inc) < $minimumInc) {
$inc = $minimumInc * ($inc < 0 ? -1 : 1);
}
// If greater than $precision, assume precision loss caused an overflow
if ($function !== 'floor' || \abs($arguments[0] + $inc - $initialValue) >= $precision) {
$arguments[0] += $inc;
}
}
$changes[$unit] = \round($minimum + ($fraction ? $fraction * $function(($this->{$unit} - $minimum) / $fraction) : 0));
// Cannot use modulo as it lose double precision
while ($changes[$unit] >= $delta) {
$changes[$unit] -= $delta;
}
$fraction -= \floor($fraction);
}
}
[$value, $minimum] = $arguments;
$normalizedValue = \floor($function(($value - $minimum) / $precision) * $precision + $minimum);
$result = $this;
foreach ($changes as $unit => $value) {
$result = $result->{$unit}($value);
}
return $result->{$normalizedUnit}($normalizedValue);
}
public function floorUnit($unit, $precision = 1)
{
return $this->roundUnit($unit, $precision, 'floor');
}
public function ceilUnit($unit, $precision = 1)
{
return $this->roundUnit($unit, $precision, 'ceil');
}
public function round($precision = 1, $function = 'round')
{
return $this->roundWith($precision, $function);
}
public function floor($precision = 1)
{
return $this->round($precision, 'floor');
}
public function ceil($precision = 1)
{
return $this->round($precision, 'ceil');
}
public function roundWeek($weekStartsAt = null)
{
return $this->closest($this->avoidMutation()->floorWeek($weekStartsAt), $this->avoidMutation()->ceilWeek($weekStartsAt));
}
public function floorWeek($weekStartsAt = null)
{
return $this->startOfWeek($weekStartsAt);
}
public function ceilWeek($weekStartsAt = null)
{
if ($this->isMutable()) {
$startOfWeek = $this->avoidMutation()->startOfWeek($weekStartsAt);
return $startOfWeek != $this ? $this->startOfWeek($weekStartsAt)->addWeek() : $this;
}
$startOfWeek = $this->startOfWeek($weekStartsAt);
return $startOfWeek != $this ? $startOfWeek->addWeek() : $this->avoidMutation();
}
}
@@ -0,0 +1,150 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Exceptions\InvalidFormatException;
use ReturnTypeWillChange;
use Throwable;
trait Serialization
{
use ObjectInitialisation;
protected static $serializer;
protected $dumpProperties = ['date', 'timezone_type', 'timezone'];
protected $dumpLocale;
protected $dumpDateProperties;
public function serialize()
{
return \serialize($this);
}
public static function fromSerialized($value)
{
$instance = @\unserialize((string) $value);
if (!$instance instanceof static) {
throw new InvalidFormatException("Invalid serialized value: {$value}");
}
return $instance;
}
#[\ReturnTypeWillChange]
public static function __set_state($dump)
{
if (\is_string($dump)) {
return static::parse($dump);
}
$date = \get_parent_class(static::class) && \method_exists(parent::class, '__set_state') ? parent::__set_state((array) $dump) : (object) $dump;
return static::instance($date);
}
public function __sleep()
{
$properties = $this->getSleepProperties();
if ($this->localTranslator ?? null) {
$properties[] = 'dumpLocale';
$this->dumpLocale = $this->locale ?? null;
}
return $properties;
}
public function __serialize() : array
{
// @codeCoverageIgnoreStart
if (isset($this->timezone_type, $this->timezone, $this->date)) {
return ['date' => $this->date ?? null, 'timezone_type' => $this->timezone_type, 'timezone' => $this->timezone ?? null];
}
// @codeCoverageIgnoreEnd
$timezone = $this->getTimezone();
$export = ['date' => $this->format('Y-m-d H:i:s.u'), 'timezone_type' => $timezone->getType(), 'timezone' => $timezone->getName()];
// @codeCoverageIgnoreStart
if (\extension_loaded('msgpack') && isset($this->constructedObjectId)) {
$export['dumpDateProperties'] = ['date' => $this->format('Y-m-d H:i:s.u'), 'timezone' => \serialize($this->timezone ?? null)];
}
// @codeCoverageIgnoreEnd
if ($this->localTranslator ?? null) {
$export['dumpLocale'] = $this->locale ?? null;
}
return $export;
}
#[\ReturnTypeWillChange]
public function __wakeup()
{
if (parent::class && \method_exists(parent::class, '__wakeup')) {
// @codeCoverageIgnoreStart
try {
parent::__wakeup();
} catch (Throwable $exception) {
try {
// FatalError occurs when calling msgpack_unpack() in PHP 7.4 or later.
['date' => $date, 'timezone' => $timezone] = $this->dumpDateProperties;
parent::__construct($date, \unserialize($timezone));
} catch (Throwable $ignoredException) {
throw $exception;
}
}
// @codeCoverageIgnoreEnd
}
$this->constructedObjectId = \spl_object_hash($this);
if (isset($this->dumpLocale)) {
$this->locale($this->dumpLocale);
$this->dumpLocale = null;
}
$this->cleanupDumpProperties();
}
public function __unserialize(array $data) : void
{
// @codeCoverageIgnoreStart
try {
$this->__construct($data['date'] ?? null, $data['timezone'] ?? null);
} catch (Throwable $exception) {
if (!isset($data['dumpDateProperties']['date'], $data['dumpDateProperties']['timezone'])) {
throw $exception;
}
try {
// FatalError occurs when calling msgpack_unpack() in PHP 7.4 or later.
['date' => $date, 'timezone' => $timezone] = $data['dumpDateProperties'];
$this->__construct($date, \unserialize($timezone));
} catch (Throwable $ignoredException) {
throw $exception;
}
}
// @codeCoverageIgnoreEnd
if (isset($data['dumpLocale'])) {
$this->locale($data['dumpLocale']);
}
}
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
$serializer = $this->localSerializer ?? static::$serializer;
if ($serializer) {
return \is_string($serializer) ? $this->rawFormat($serializer) : $serializer($this);
}
return $this->toJSON();
}
public static function serializeUsing($callback)
{
static::$serializer = $callback;
}
public function cleanupDumpProperties()
{
// @codeCoverageIgnoreStart
if (\PHP_VERSION < 8.199999999999999) {
foreach ($this->dumpProperties as $property) {
if (isset($this->{$property})) {
unset($this->{$property});
}
}
}
// @codeCoverageIgnoreEnd
return $this;
}
private function getSleepProperties() : array
{
$properties = $this->dumpProperties;
// @codeCoverageIgnoreStart
if (!\extension_loaded('msgpack')) {
return $properties;
}
if (isset($this->constructedObjectId)) {
$this->dumpDateProperties = ['date' => $this->format('Y-m-d H:i:s.u'), 'timezone' => \serialize($this->timezone ?? null)];
$properties[] = 'dumpDateProperties';
}
return $properties;
// @codeCoverageIgnoreEnd
}
}
@@ -0,0 +1,90 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\CarbonInterface;
use MailPoetVendor\Carbon\CarbonTimeZone;
use Closure;
use DateTimeImmutable;
use DateTimeInterface;
use InvalidArgumentException;
use Throwable;
trait Test
{
///////////////////////////////////////////////////////////////////
///////////////////////// TESTING AIDS ////////////////////////////
///////////////////////////////////////////////////////////////////
protected static $testNow;
protected static $testDefaultTimezone;
public static function setTestNow($testNow = null)
{
static::$testNow = $testNow instanceof self || $testNow instanceof Closure ? $testNow : static::make($testNow);
}
public static function setTestNowAndTimezone($testNow = null, $tz = null)
{
if ($testNow) {
self::$testDefaultTimezone = self::$testDefaultTimezone ?? \date_default_timezone_get();
}
$useDateInstanceTimezone = $testNow instanceof DateTimeInterface;
if ($useDateInstanceTimezone) {
self::setDefaultTimezone($testNow->getTimezone()->getName(), $testNow);
}
static::setTestNow($testNow);
if (!$useDateInstanceTimezone) {
$now = static::getMockedTestNow(\func_num_args() === 1 ? null : $tz);
$tzName = $now ? $now->tzName : null;
self::setDefaultTimezone($tzName ?? self::$testDefaultTimezone ?? 'UTC', $now);
}
if (!$testNow) {
self::$testDefaultTimezone = null;
}
}
public static function withTestNow($testNow, $callback)
{
static::setTestNow($testNow);
try {
$result = $callback();
} finally {
static::setTestNow();
}
return $result;
}
public static function getTestNow()
{
return static::$testNow;
}
public static function hasTestNow()
{
return static::getTestNow() !== null;
}
protected static function getMockedTestNow($tz)
{
$testNow = static::getTestNow();
if ($testNow instanceof Closure) {
$realNow = new DateTimeImmutable('now');
$testNow = $testNow(static::parse($realNow->format('Y-m-d H:i:s.u'), $tz ?: $realNow->getTimezone()));
}
return $testNow instanceof CarbonInterface ? $testNow->avoidMutation()->tz($tz) : $testNow;
}
protected static function mockConstructorParameters(&$time, $tz)
{
$testInstance = clone static::getMockedTestNow($tz);
if (static::hasRelativeKeywords($time)) {
$testInstance = $testInstance->modify($time);
}
$time = $testInstance instanceof self ? $testInstance->rawFormat(static::MOCK_DATETIME_FORMAT) : $testInstance->format(static::MOCK_DATETIME_FORMAT);
}
private static function setDefaultTimezone($timezone, DateTimeInterface $date = null)
{
$previous = null;
$success = \false;
try {
$success = \date_default_timezone_set($timezone);
} catch (Throwable $exception) {
$previous = $exception;
}
if (!$success) {
$suggestion = @CarbonTimeZone::create($timezone)->toRegionName($date);
throw new InvalidArgumentException("Timezone ID '{$timezone}' is invalid" . ($suggestion && $suggestion !== $timezone ? ", did you mean '{$suggestion}'?" : '.') . "\n" . "It must be one of the IDs from DateTimeZone::listIdentifiers(),\n" . 'For the record, hours/minutes offset are relevant only for a particular moment, ' . 'but not as a default timezone.', 0, $previous);
}
}
}
@@ -0,0 +1,74 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
trait Timestamp
{
public static function createFromTimestamp($timestamp, $tz = null)
{
return static::createFromTimestampUTC($timestamp)->setTimezone($tz);
}
public static function createFromTimestampUTC($timestamp)
{
[$integer, $decimal] = self::getIntegerAndDecimalParts($timestamp);
$delta = \floor($decimal / static::MICROSECONDS_PER_SECOND);
$integer += $delta;
$decimal -= $delta * static::MICROSECONDS_PER_SECOND;
$decimal = \str_pad((string) $decimal, 6, '0', \STR_PAD_LEFT);
return static::rawCreateFromFormat('U u', "{$integer} {$decimal}");
}
public static function createFromTimestampMsUTC($timestamp)
{
[$milliseconds, $microseconds] = self::getIntegerAndDecimalParts($timestamp, 3);
$sign = $milliseconds < 0 || $milliseconds === 0.0 && $microseconds < 0 ? -1 : 1;
$milliseconds = \abs($milliseconds);
$microseconds = $sign * \abs($microseconds) + static::MICROSECONDS_PER_MILLISECOND * ($milliseconds % static::MILLISECONDS_PER_SECOND);
$seconds = $sign * \floor($milliseconds / static::MILLISECONDS_PER_SECOND);
$delta = \floor($microseconds / static::MICROSECONDS_PER_SECOND);
$seconds += $delta;
$microseconds -= $delta * static::MICROSECONDS_PER_SECOND;
$microseconds = \str_pad($microseconds, 6, '0', \STR_PAD_LEFT);
return static::rawCreateFromFormat('U u', "{$seconds} {$microseconds}");
}
public static function createFromTimestampMs($timestamp, $tz = null)
{
return static::createFromTimestampMsUTC($timestamp)->setTimezone($tz);
}
public function timestamp($unixTimestamp)
{
return $this->setTimestamp($unixTimestamp);
}
public function getPreciseTimestamp($precision = 6)
{
return \round((float) $this->rawFormat('Uu') / \pow(10, 6 - $precision));
}
public function valueOf()
{
return $this->getPreciseTimestamp(3);
}
public function getTimestampMs()
{
return (int) $this->getPreciseTimestamp(3);
}
public function unix()
{
return $this->getTimestamp();
}
private static function getIntegerAndDecimalParts($numbers, $decimals = 6)
{
if (\is_int($numbers) || \is_float($numbers)) {
$numbers = \number_format($numbers, $decimals, '.', '');
}
$sign = \str_starts_with($numbers, '-') ? -1 : 1;
$integer = 0;
$decimal = 0;
foreach (\preg_split('`[^\\d.]+`', $numbers) as $chunk) {
[$integerPart, $decimalPart] = \explode('.', "{$chunk}.");
$integer += (int) $integerPart;
$decimal += (float) "0.{$decimalPart}";
}
$overflow = \floor($decimal);
$integer += $overflow;
$decimal -= $overflow;
return [$sign * $integer, $decimal === 0.0 ? 0.0 : $sign * \round($decimal * \pow(10, $decimals))];
}
}
@@ -0,0 +1,16 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use Closure;
trait ToStringFormat
{
protected static $toStringFormat;
public static function resetToStringFormat()
{
static::setToStringFormat(null);
}
public static function setToStringFormat($format)
{
static::$toStringFormat = $format;
}
}
@@ -0,0 +1,233 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\CarbonConverterInterface;
use MailPoetVendor\Carbon\CarbonInterface;
use MailPoetVendor\Carbon\CarbonInterval;
use MailPoetVendor\Carbon\Exceptions\UnitException;
use Closure;
use DateInterval;
use MailPoetVendor\DateMalformedStringException;
use ReturnTypeWillChange;
trait Units
{
public function addRealUnit($unit, $value = 1)
{
switch ($unit) {
// @call addRealUnit
case 'micro':
// @call addRealUnit
case 'microsecond':
$diff = $this->microsecond + $value;
$time = $this->getTimestamp();
$seconds = (int) \floor($diff / static::MICROSECONDS_PER_SECOND);
$time += $seconds;
$diff -= $seconds * static::MICROSECONDS_PER_SECOND;
$microtime = \str_pad((string) $diff, 6, '0', \STR_PAD_LEFT);
$tz = $this->tz;
return $this->tz('UTC')->modify("@{$time}.{$microtime}")->tz($tz);
// @call addRealUnit
case 'milli':
// @call addRealUnit
case 'millisecond':
return $this->addRealUnit('microsecond', $value * static::MICROSECONDS_PER_MILLISECOND);
// @call addRealUnit
case 'second':
break;
// @call addRealUnit
case 'minute':
$value *= static::SECONDS_PER_MINUTE;
break;
// @call addRealUnit
case 'hour':
$value *= static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;
break;
// @call addRealUnit
case 'day':
$value *= static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;
break;
// @call addRealUnit
case 'week':
$value *= static::DAYS_PER_WEEK * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;
break;
// @call addRealUnit
case 'month':
$value *= 30 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;
break;
// @call addRealUnit
case 'quarter':
$value *= static::MONTHS_PER_QUARTER * 30 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;
break;
// @call addRealUnit
case 'year':
$value *= 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;
break;
// @call addRealUnit
case 'decade':
$value *= static::YEARS_PER_DECADE * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;
break;
// @call addRealUnit
case 'century':
$value *= static::YEARS_PER_CENTURY * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;
break;
// @call addRealUnit
case 'millennium':
$value *= static::YEARS_PER_MILLENNIUM * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;
break;
default:
if ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) {
throw new UnitException("Invalid unit for real timestamp add/sub: '{$unit}'");
}
return $this;
}
return $this->setTimestamp((int) ($this->getTimestamp() + $value));
}
public function subRealUnit($unit, $value = 1)
{
return $this->addRealUnit($unit, -$value);
}
public static function isModifiableUnit($unit)
{
static $modifiableUnits = [
// @call addUnit
'millennium',
// @call addUnit
'century',
// @call addUnit
'decade',
// @call addUnit
'quarter',
// @call addUnit
'week',
// @call addUnit
'weekday',
];
return \in_array($unit, $modifiableUnits, \true) || \in_array($unit, static::$units, \true);
}
public function rawAdd(DateInterval $interval)
{
return parent::add($interval);
}
#[\ReturnTypeWillChange]
public function add($unit, $value = 1, $overflow = null)
{
if (\is_string($unit) && \func_num_args() === 1) {
$unit = CarbonInterval::make($unit, [], \true);
}
if ($unit instanceof CarbonConverterInterface) {
return $this->resolveCarbon($unit->convertDate($this, \false));
}
if ($unit instanceof Closure) {
return $this->resolveCarbon($unit($this, \false));
}
if ($unit instanceof DateInterval) {
return parent::add($unit);
}
if (\is_numeric($unit)) {
[$value, $unit] = [$unit, $value];
}
return $this->addUnit($unit, $value, $overflow);
}
public function addUnit($unit, $value = 1, $overflow = null)
{
$originalArgs = \func_get_args();
$date = $this;
if (!\is_numeric($value) || !(float) $value) {
return $date->isMutable() ? $date : $date->avoidMutation();
}
$unit = self::singularUnit($unit);
$metaUnits = ['millennium' => [static::YEARS_PER_MILLENNIUM, 'year'], 'century' => [static::YEARS_PER_CENTURY, 'year'], 'decade' => [static::YEARS_PER_DECADE, 'year'], 'quarter' => [static::MONTHS_PER_QUARTER, 'month']];
if (isset($metaUnits[$unit])) {
[$factor, $unit] = $metaUnits[$unit];
$value *= $factor;
}
if ($unit === 'weekday') {
$weekendDays = static::getWeekendDays();
if ($weekendDays !== [static::SATURDAY, static::SUNDAY]) {
$absoluteValue = \abs($value);
$sign = $value / \max(1, $absoluteValue);
$weekDaysCount = 7 - \min(6, \count(\array_unique($weekendDays)));
$weeks = \floor($absoluteValue / $weekDaysCount);
for ($diff = $absoluteValue % $weekDaysCount; $diff; $diff--) {
$date = $date->addDays($sign);
while (\in_array($date->dayOfWeek, $weekendDays, \true)) {
$date = $date->addDays($sign);
}
}
$value = $weeks * $sign;
$unit = 'week';
}
$timeString = $date->toTimeString();
} elseif ($canOverflow = \in_array($unit, ['month', 'year']) && ($overflow === \false || $overflow === null && ($ucUnit = \ucfirst($unit) . 's') && !($this->{'local' . $ucUnit . 'Overflow'} ?? static::{'shouldOverflow' . $ucUnit}()))) {
$day = $date->day;
}
$value = (int) $value;
if ($unit === 'milli' || $unit === 'millisecond') {
$unit = 'microsecond';
$value *= static::MICROSECONDS_PER_MILLISECOND;
}
// Work-around for bug https://bugs.php.net/bug.php?id=75642
if ($unit === 'micro' || $unit === 'microsecond') {
$microseconds = $this->micro + $value;
$second = (int) \floor($microseconds / static::MICROSECONDS_PER_SECOND);
$microseconds %= static::MICROSECONDS_PER_SECOND;
if ($microseconds < 0) {
$microseconds += static::MICROSECONDS_PER_SECOND;
}
$date = $date->microseconds($microseconds);
$unit = 'second';
$value = $second;
}
try {
$date = $date->modify("{$value} {$unit}");
if (isset($timeString)) {
$date = $date->setTimeFromTimeString($timeString);
} elseif (isset($canOverflow, $day) && $canOverflow && $day !== $date->day) {
$date = $date->modify('last day of previous month');
}
} catch (DateMalformedStringException $ignoredException) {
// @codeCoverageIgnore
$date = null;
// @codeCoverageIgnore
}
if (!$date) {
throw new UnitException('Unable to add unit ' . \var_export($originalArgs, \true));
}
return $date;
}
public function subUnit($unit, $value = 1, $overflow = null)
{
return $this->addUnit($unit, -$value, $overflow);
}
public function rawSub(DateInterval $interval)
{
return parent::sub($interval);
}
#[\ReturnTypeWillChange]
public function sub($unit, $value = 1, $overflow = null)
{
if (\is_string($unit) && \func_num_args() === 1) {
$unit = CarbonInterval::make($unit, [], \true);
}
if ($unit instanceof CarbonConverterInterface) {
return $this->resolveCarbon($unit->convertDate($this, \true));
}
if ($unit instanceof Closure) {
return $this->resolveCarbon($unit($this, \true));
}
if ($unit instanceof DateInterval) {
return parent::sub($unit);
}
if (\is_numeric($unit)) {
[$value, $unit] = [$unit, $value];
}
return $this->addUnit($unit, -(float) $value, $overflow);
}
public function subtract($unit, $value = 1, $overflow = null)
{
if (\is_string($unit) && \func_num_args() === 1) {
$unit = CarbonInterval::make($unit, [], \true);
}
return $this->sub($unit, $value, $overflow);
}
}
@@ -0,0 +1,89 @@
<?php
namespace MailPoetVendor\Carbon\Traits;
if (!defined('ABSPATH')) exit;
trait Week
{
public function isoWeekYear($year = null, $dayOfWeek = null, $dayOfYear = null)
{
return $this->weekYear($year, $dayOfWeek ?? 1, $dayOfYear ?? 4);
}
public function weekYear($year = null, $dayOfWeek = null, $dayOfYear = null)
{
$dayOfWeek = $dayOfWeek ?? $this->getTranslationMessage('first_day_of_week') ?? 0;
$dayOfYear = $dayOfYear ?? $this->getTranslationMessage('day_of_first_week_of_year') ?? 1;
if ($year !== null) {
$year = (int) \round($year);
if ($this->weekYear(null, $dayOfWeek, $dayOfYear) === $year) {
return $this->avoidMutation();
}
$week = $this->week(null, $dayOfWeek, $dayOfYear);
$day = $this->dayOfWeek;
$date = $this->year($year);
switch ($date->weekYear(null, $dayOfWeek, $dayOfYear) - $year) {
case 1:
$date = $date->subWeeks(26);
break;
case -1:
$date = $date->addWeeks(26);
break;
}
$date = $date->addWeeks($week - $date->week(null, $dayOfWeek, $dayOfYear))->startOfWeek($dayOfWeek);
if ($date->dayOfWeek === $day) {
return $date;
}
return $date->next($day);
}
$year = $this->year;
$day = $this->dayOfYear;
$date = $this->avoidMutation()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
if ($date->year === $year && $day < $date->dayOfYear) {
return $year - 1;
}
$date = $this->avoidMutation()->addYear()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
if ($date->year === $year && $day >= $date->dayOfYear) {
return $year + 1;
}
return $year;
}
public function isoWeeksInYear($dayOfWeek = null, $dayOfYear = null)
{
return $this->weeksInYear($dayOfWeek ?? 1, $dayOfYear ?? 4);
}
public function weeksInYear($dayOfWeek = null, $dayOfYear = null)
{
$dayOfWeek = $dayOfWeek ?? $this->getTranslationMessage('first_day_of_week') ?? 0;
$dayOfYear = $dayOfYear ?? $this->getTranslationMessage('day_of_first_week_of_year') ?? 1;
$year = $this->year;
$start = $this->avoidMutation()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
$startDay = $start->dayOfYear;
if ($start->year !== $year) {
$startDay -= $start->daysInYear;
}
$end = $this->avoidMutation()->addYear()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
$endDay = $end->dayOfYear;
if ($end->year !== $year) {
$endDay += $this->daysInYear;
}
return (int) \round(($endDay - $startDay) / 7);
}
public function week($week = null, $dayOfWeek = null, $dayOfYear = null)
{
$date = $this;
$dayOfWeek = $dayOfWeek ?? $this->getTranslationMessage('first_day_of_week') ?? 0;
$dayOfYear = $dayOfYear ?? $this->getTranslationMessage('day_of_first_week_of_year') ?? 1;
if ($week !== null) {
return $date->addWeeks(\round($week) - $this->week(null, $dayOfWeek, $dayOfYear));
}
$start = $date->avoidMutation()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
$end = $date->avoidMutation()->startOfWeek($dayOfWeek);
if ($start > $end) {
$start = $start->subWeeks(26)->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
}
$week = (int) ($start->diffInDays($end) / 7 + 1);
return $week > $end->weeksInYear($dayOfWeek, $dayOfYear) ? 1 : $week;
}
public function isoWeek($week = null, $dayOfWeek = null, $dayOfYear = null)
{
return $this->week($week, $dayOfWeek ?? 1, $dayOfYear ?? 4);
}
}
@@ -0,0 +1,12 @@
<?php
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use ReflectionMethod;
use MailPoetVendor\Symfony\Component\Translation;
use MailPoetVendor\Symfony\Contracts\Translation\TranslatorInterface;
$transMethod = new ReflectionMethod(\class_exists(TranslatorInterface::class) ? TranslatorInterface::class : Translation\Translator::class, 'trans');
require $transMethod->hasReturnType() ? __DIR__ . '/../../lazy/Carbon/TranslatorStrongType.php' : __DIR__ . '/../../lazy/Carbon/TranslatorWeakType.php';
class Translator extends LazyTranslator
{
// Proxy dynamically loaded LazyTranslator in a static way
}
@@ -0,0 +1,56 @@
<?php
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Carbon\Exceptions\ImmutableException;
use MailPoetVendor\Symfony\Component\Config\ConfigCacheFactoryInterface;
use MailPoetVendor\Symfony\Component\Translation\Formatter\MessageFormatterInterface;
class TranslatorImmutable extends Translator
{
private $constructed = \false;
public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = \false)
{
parent::__construct($locale, $formatter, $cacheDir, $debug);
$this->constructed = \true;
}
public function setDirectories(array $directories)
{
$this->disallowMutation(__METHOD__);
return parent::setDirectories($directories);
}
public function setLocale($locale)
{
$this->disallowMutation(__METHOD__);
return parent::setLocale($locale);
}
public function setMessages($locale, $messages)
{
$this->disallowMutation(__METHOD__);
return parent::setMessages($locale, $messages);
}
public function setTranslations($messages)
{
$this->disallowMutation(__METHOD__);
return parent::setTranslations($messages);
}
public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory) : void
{
$this->disallowMutation(__METHOD__);
parent::setConfigCacheFactory($configCacheFactory);
}
public function resetMessages($locale = null)
{
$this->disallowMutation(__METHOD__);
return parent::resetMessages($locale);
}
public function setFallbackLocales(array $locales)
{
$this->disallowMutation(__METHOD__);
parent::setFallbackLocales($locales);
}
private function disallowMutation($method)
{
if ($this->constructed) {
throw new ImmutableException($method . ' not allowed on ' . static::class);
}
}
}
@@ -0,0 +1,8 @@
<?php
namespace MailPoetVendor\Carbon;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Symfony\Component\Translation\MessageCatalogueInterface;
interface TranslatorStrongTypeInterface
{
public function getFromCatalogue(MessageCatalogueInterface $catalogue, string $id, string $domain = 'messages');
}
@@ -0,0 +1 @@
<?php