Last active
October 30, 2018 08:42
-
-
Save yoyosan/ab11dd34936d4e52b3cca313635bc537 to your computer and use it in GitHub Desktop.
Text for keybr practice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function toFormattedDateString() | |
protected static $translator; | |
* | |
* Add weeks to the instance. Positive $value travels forward while | |
*/ | |
* Set last errors. | |
return $this->setDate($year, 12, 31)->endOfDay(); | |
static::$weekStartsAt = $day; | |
* be used. | |
* The __set_state handler. | |
/** | |
* | |
self::TUESDAY => 'Tuesday', | |
* | |
return false; | |
return static::translator(); | |
} | |
$unit = $short ? $diffIntervalData['unitShort'] : $diffIntervalData['unit']; | |
public function previousWeekday() | |
$result = call_user_func($func, static::setLocale($locale) ? static::getLocale() : false, static::translator()); | |
* @return bool | |
static::$monthsOverflow = $monthsOverflow; | |
* @return int | |
* | |
* Set the instance's timestamp | |
public function isCurrentMonth($ofSameYear = null) | |
* | |
/** | |
* | |
} | |
* @return static | |
* @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
{ | |
try { | |
* Create a Carbon instance for the lowest supported date. | |
*/ | |
* Remove a minute from the instance using timestamp. | |
/** | |
{ | |
return $this->diffInSeconds($this->copy()->startOfDay()); | |
*/ | |
public function diffInWeekdays($date = null, $absolute = true) | |
*/ | |
* @param \DateTimeZone|string|null $tz | |
} | |
* | |
/////////////////////////////////////////////////////////////////// | |
} | |
$date = $date ?: static::now($this->tz); | |
* Go forward or backward to the next week- or weekend-day. | |
* @param int $value | |
* | |
* @return void | |
* @param int $value | |
} | |
public static function useMonthsOverflow($monthsOverflow = true) | |
* @return static | |
*/ | |
* @param string $locale locale ex. en | |
static::$yearsOverflow = true; | |
} | |
*/ | |
$isNow = empty($time) || $time === 'now'; | |
* | |
public function addYears($value) | |
{ | |
if ($macro instanceof Closure && method_exists($macro, 'bindTo')) { | |
* | |
* Modify to the last occurrence of a given day of the week | |
* /!\ Warning, this is not reliable with PHP < 7.1.4 | |
{ | |
// join the interval parts by a space | |
public static function instance($date) | |
$date = self::createFromFormatAndTimezone($format, $time, $tz); | |
* @param int $value | |
/** | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
if ($translation !== $key) { | |
* @return static | |
const SATURDAY = 6; | |
} | |
* | |
'L' => '(0|1)', | |
*/ | |
* | |
if (is_numeric($object)) { | |
} | |
} | |
* @return string | |
return $this->subYearsNoOverflow($value); | |
return $this->dayOfWeek === static::TUESDAY; | |
*/ | |
*/ | |
( | |
* Add months without overflowing to the instance. Positive $value | |
public function toDayDateTimeString() | |
return $this->toDateString() === static::yesterday($this->getTimezone())->toDateString(); | |
{ | |
*/ | |
* @return string | |
*/ | |
*/ | |
*/ | |
* be used. | |
* @return mixed | |
{ | |
$time = $dateTime->format(static::DEFAULT_TO_STRING_FORMAT).substr($microTime, 1, 7); | |
*/ | |
* | |
*/ | |
* | |
* @param array $parameters | |
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) { | |
* values for $minute and $second will be their now() values. | |
{ | |
$reflexion = new \ReflectionFunction($macro); | |
* Set a Carbon instance (real or mock) to be returned when a "now" | |
} | |
{ | |
*/ | |
/** | |
*/ | |
/** | |
* @param int $value | |
$step = $forward ? 1 : -1; | |
return $this->modify("$this->hour:59:59.999999"); | |
*/ | |
* @return static | |
* | |
/** | |
// Prepend mock datetime only if the format does not contain non escaped unix epoch reset flag. | |
} | |
* Get the difference in seconds using timestamps. | |
/** | |
* @return bool | |
* @param bool $ofSameYear Check if it is the same month in the same year. | |
{ | |
* @return static | |
/** | |
* | |
*/ | |
*/ | |
public function startOfMinute() | |
} | |
* Get the current translator locale | |
*/ | |
* @param array $lastErrors | |
} | |
* | |
* Determines if the instance is in the current month. | |
* | |
{ | |
// | |
* @param string $time | |
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals | |
} | |
* 1 hour from now | |
* | |
* Remove a second from the instance using timestamp. | |
} | |
} | |
} | |
/** | |
/** | |
public static function tomorrow($tz = null) | |
* @return static | |
{ | |
$numOfDaysCount = (int) ($diffIntervalData['value'] - ($count * static::DAYS_PER_WEEK)); | |
return (int) ($this->diffInDays($date, $absolute) / static::DAYS_PER_WEEK); | |
* @param Carbon|null $other | |
* @return static | |
} | |
{ | |
/** | |
/** | |
'S' => '([a-zA-Z]{2})', | |
{ | |
* | |
*/ | |
* | |
'minute' => $this->minute, | |
public function toRfc2822String() | |
/** | |
* | |
if (strpos((string) .1, '.') === false) { | |
return $this->setDate($this->year, 1, 1)->startOfDay(); | |
} | |
return $this->isSameAs('Y', $date); | |
* | |
'N' => '([1-7])', | |
* | |
*/ | |
* @property int $month | |
public function serialize() | |
// E.g. "1975-5-1" (Y-n-j) will still be parsed correctly when "Y-m-d" is supplied as the format. | |
/** | |
* | |
} | |
/** | |
* | |
* @param int $value | |
* @return bool | |
* | |
* | |
* instance is created. The provided instance will be returned | |
* @param int $timestamp | |
return call_user_func(function () use ($carbon) { | |
return $tz !== null | |
} | |
* @param \Carbon\Carbon|string|null $testNow | |
* | |
} | |
} | |
* Add centuries to the instance. Positive $value travels forward while | |
/** | |
{ | |
* Add year with overflow. | |
'I' => '(0|1)', | |
{ | |
/** | |
* Remove year from the instance. | |
public function endOfSecond() | |
* @param int|null $dayOfWeek | |
*/ | |
return $this->addWeekdays($value); | |
return $this->nextOrPreviousDay(true, false); | |
$diffInterval = $this->diff($other); | |
public function firstOfQuarter($dayOfWeek = null) | |
/** | |
* @param \DateTimeZone|string|int|null $object | |
public function isEndOfDay($checkMicroseconds = false) | |
* Modify to start of current hour, minutes and seconds become 0 | |
* Determines if the instance is in the current day. | |
{ | |
* @return bool | |
*/ | |
$this->startOfDay(); | |
} | |
* @return static | |
* | |
/** | |
public static function create($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) | |
* @param int $value | |
* let microseconds to 0 on those PHP versions if false. | |
* | |
*/ | |
* in the current quarter. If no dayOfWeek is provided, modify to the | |
* @return static | |
/** | |
* Format the instance as a readable date | |
* and recurrences). Throw an exception for invalid format, but otherwise return null. | |
} | |
* | |
* | |
$lastMonth = $date->month; | |
return $translation; | |
*/ | |
* @param string|array $other | |
* @param int $year | |
} | |
public function startOfDay() | |
*/ | |
public static function getAvailableLocales() | |
* @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date. | |
*/ | |
* | |
* Get the month overflow behavior. | |
return $date instanceof self ? $date : static::instance($date); | |
* Determines if the instance is greater (after) than or equal to another | |
/** | |
/** | |
* | |
// Get microseconds from microtime() if "now" asked and PHP < 7.1 and PHP 7.1.3 if fallback enabled. | |
$end = $this->resolveCarbon($date); | |
static::setLocale($currentLocale); | |
return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE); | |
* @param \DateTimeZone|string|null $tz | |
if (self::$PHPIntSize === 4) { | |
return $this->addDays(-1 * $value); | |
} | |
/** | |
/** | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
* @property-read string $shortEnglishDayOfWeek the abbreviated day of week in English | |
self::THURSDAY => 'Thursday', | |
/** | |
public function min($date = null) | |
public static function shouldCompareYearWithMonth() | |
{ | |
public function toRssString() | |
public function __toString() | |
public function endOfCentury() | |
* @property-read int $weekNumberInMonth 1 through 5 | |
* @param \DateTimeZone|string|null $tz | |
{ | |
* @property-read string $englishMonth the day of week in English | |
$month = ($this->quarter - 1) * static::MONTHS_PER_QUARTER + 1; | |
/** | |
/////////////////////////////////////////////////////////////////// | |
public function subYearsNoOverflow($value) | |
* @return static | |
/** | |
'formatted' => $this->format(self::DEFAULT_TO_STRING_FORMAT), | |
public static function setHumanDiffOptions($humanDiffOptions) | |
public function isNextQuarter() | |
* @param int $nth | |
* Resets the date to end of the decade and time to 23:59:59 | |
public function addRealMinute($value = 1) | |
return $this->addMinutes($value); | |
public function nextWeekday() | |
// To ensure we're really testing against our desired format, perform an additional regex validation. | |
// Set timezone from mock if custom timezone was neither given directly nor as a part of format. | |
return $this->year === $this->nowWithSameTz()->subYear()->year; | |
*/ | |
} | |
* Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. | |
{ | |
/////////////////////////////////////////////////////////////////// | |
* | |
* @param string $locale locale ex. en | |
*/ | |
$date = $this->copy()->firstOfYear()->modify('+'.$nth.' '.static::$days[$dayOfWeek]); | |
* | |
/** | |
* @return static | |
public function nthOfQuarter($nth, $dayOfWeek) | |
* @throws \InvalidArgumentException | |
* @param bool $ofSameYear Check if it is the same month in the same year. | |
return $result; | |
* Check if the instance is midday. | |
* @param int $value | |
'F' => '([a-zA-Z]{2,})', | |
* | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
* | |
return $this->addRealMinutes(-1 * $value); | |
* negative $value travels into the past. | |
} | |
* Get the difference in months | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
* | |
} | |
} | |
{ | |
* @return bool | |
* @return static | |
public function formatLocalized($format) | |
if ($$field !== null && (!is_int($$field) || $$field !== $instance->$field)) { | |
return static::createFromTimestamp(PHP_INT_MAX); // @codeCoverageIgnore | |
return $this->addMonthsWithOverflow(-1 * $value); | |
* @param int $value | |
* @return bool | |
* @return static | |
* Add a century to the instance | |
* @return $this | |
*/ | |
if (is_string($var)) { | |
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { | |
{ | |
protected static $weekStartsAt = self::MONDAY; | |
{ | |
* | |
self::SATURDAY, | |
/** | |
/** | |
* @return static | |
* @return bool | |
* Add minutes to the instance using timestamp. Positive $value | |
} | |
*/ | |
public static function createMidnightDate($year = null, $month = null, $day = null, $tz = null) | |
* @return bool | |
} | |
* Remove an hour from the instance. | |
* @throws \BadMethodCallException | |
/** | |
} | |
* | |
* @property \DateTimeZone $tz alias of timezone | |
public static function createFromDate($year = null, $month = null, $day = null, $tz = null) | |
* | |
public static function localeHasDiffSyntax($locale) | |
* @param int $value | |
public function jsonSerialize() | |
$translator->trans('ago') !== 'ago' && | |
* Format the instance as ISO8601 | |
} | |
} | |
public function isCurrentSecond() | |
/////////////////////////////////////////////////////////////////// | |
public function subYear($value = 1) | |
/** | |
* Add quarters to the instance. Positive $value travels forward while | |
* | |
{ | |
return $this->nowWithSameTz(); | |
* @property-read bool $local checks if the timezone is local, true if local, false otherwise | |
/** | |
* | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
* @property-read int $weekOfMonth 1 through 5 | |
* | |
} | |
* Remove years from the instance with no month overflow. | |
); | |
// First attempt to create an instance, so that error messages are based on the unmodified format. | |
{ | |
'e' => '([a-zA-Z]{1,5})|([a-zA-Z]*\/[a-zA-Z]*)', | |
return $instance; | |
$interval[] = static::translator()->transChoice($unit, $count, array(':count' => $count)); | |
* @param int $value | |
* | |
break; | |
{ | |
return $this->gt($date); | |
'daysInMonth' => 't', | |
); | |
* Returns a present instance in the same timezone. | |
/** | |
/** | |
* @return bool | |
} | |
return $this->toAtomString(); | |
self::SUNDAY => 'Sunday', | |
} | |
const DAYS_PER_WEEK = 7; | |
* 5 months after | |
* @throws \InvalidArgumentException | |
if (static::$translator === null) { | |
* @param int|null $year | |
case $name === 'weekNumberInMonth': | |
*/ | |
/** | |
return $this->addMonthsNoOverflow(-1 * $value); | |
* | |
* @param int $value | |
($y = $translator->trans('y')) !== 'y' && | |
* than (new Carbon('Monday next week'))->fn(). | |
public function subSeconds($value) | |
} | |
{ | |
return $this->setTimestamp($this->getTimestamp() + $value); | |
* Checks if this day is a Sunday. | |
return $this->format(static::ATOM); | |
'n' => '(1[012]|[1-9])', | |
* @param int $value | |
static::$humanDiffOptions = static::getHumanDiffOptions() & ~$humanDiffOption; | |
*/ | |
{ | |
); | |
* @param string $value | |
* | |
*/ | |
return new static($date->format('Y-m-d H:i:s.u'), $date->getTimezone()); | |
* @return $this | |
* @param bool $checkMicroseconds check time at microseconds precision | |
* Checks if this day is a Monday. | |
* First day of week. | |
'second' => 's', | |
/** | |
public static function hasMacro($name) | |
*/ | |
/** | |
} | |
* @param bool $checkMicroseconds check time at microseconds precision | |
* | |
public function isSameAs($format, $date = null) | |
* first day of the current month. Use the supplied constants | |
return $this->addYears(static::YEARS_PER_CENTURY * $value); | |
{ | |
*/ | |
public function __call($method, $parameters) | |
* | |
* @param int|null $second | |
return $this; | |
if ($var instanceof DateTime || $var instanceof DateTimeInterface) { | |
/** | |
* Create a Carbon instance from just a date. The time portion is set to now. | |
* @property-read int $age does a diffInYears() with default parameters | |
return call_user_func(static::$serializer, $this); | |
public function endOfWeek() | |
} | |
*/ | |
* | |
{ | |
* | |
* | |
$date = $date ? static::instance($date) : static::now($this->tz); | |
* Remove hours from the instance using timestamp. | |
* @return static | |
{ | |
* @return static | |
* to indicate the desired dayOfWeek, ex. static::MONDAY. | |
} | |
* | |
} | |
'second', | |
* 1 hour before | |
*/ | |
/** | |
return $this->day($this->daysInMonth); | |
return $this->quarter === $this->nowWithSameTz()->addQuarter()->quarter; | |
public function addMinute($value = 1) | |
'T' => '([a-zA-Z]{1,5})', | |
$diff->s; | |
* Remove a century from the instance | |
/** | |
$dayOfWeek = $this->dayOfWeek; | |
* | |
* Add minutes to the instance using timestamp. Positive $value travels | |
return static::$testNow; | |
*/ | |
{ | |
*/ | |
* of the current day of the week. Use the supplied constants | |
return $this->setTime($this->hour, $this->minute, 0); | |
*/ | |
* Determines if the instance is in the current hour. | |
* @return bool | |
return (int) ceil($this->month / static::MONTHS_PER_QUARTER); | |
* | |
} | |
* | |
} | |
* last day of the current quarter. Use the supplied constants | |
return $this->dayOfWeek === static::MONDAY; | |
* @param string $name | |
* | |
$start = $end; | |
foreach ((array) $other as $expect) { | |
* | |
* will be thrown. | |
*/ | |
*/ | |
/** | |
'O' => '([\+\-](1[012]|0[0-9])[0134][05])', | |
if ($key !== static::translator()->transChoice($key, $count)) { | |
} | |
*/ | |
public static function localeHasShortUnits($locale) | |
case 'timezone': | |
* | |
* @param int|null $dayOfWeek day of the week default null | |
public function addDays($value) | |
* @var int | |
<?php | |
*/ | |
* Modify to the given occurrence of a given day of the week | |
$y !== $translator->trans('hour') | |
* | |
/** | |
if (($mock = static::getTestNow()) && ($date instanceof DateTime || $date instanceof DateTimeInterface)) { | |
return $this->format(static::W3C); | |
return $this->addCenturies(-1 * $value); | |
* | |
* Add a second to the instance using timestamp. | |
static::$translator = Translator::get(); | |
* @return string | |
->format(static::RFC7231_FORMAT); | |
* | |
self::FRIDAY => 'Friday', | |
* @param string $format The date formats to compare. | |
public function isSameDay($date = null) | |
/** | |
static::$localMacros[$name] = $macro; | |
* @param int $value | |
* | |
* locale using setlocale() http://php.net/setlocale. | |
$key = $unit.'_'.$transId; | |
*/ | |
// createFromFormat() is known to handle edge cases silently. | |
* | |
} | |
* | |
$method = substr($format, 0, 1) === '%' ? 'formatLocalized' : 'format'; | |
* @param string $date | |
if (strtotime($time) === false) { | |
return $this->addRealMinutes($value * static::MINUTES_PER_HOUR); | |
*/ | |
* @return void | |
'A' => '(AM|PM)', | |
/** | |
* | |
*/ | |
// instance then override as required | |
*/ | |
$day = $this->day; | |
{ | |
return $this->format('G:i:s') === static::$midDayAt.':00:00'; | |
* | |
* @return void | |
* | |
/////////////////////////////////////////////////////////////////// | |
public function isLastQuarter() | |
* Modify to the first occurrence of a given day of the week | |
* If no dayOfWeek is provided, modify to the next occurrence | |
* | |
* @var array | |
} | |
* @return mixed | |
* | |
'yearIso' => 'o', | |
* Format the instance as RFC7231 | |
const FRIDAY = 5; | |
* Get the translator instance in use | |
static::$lastErrors = $lastErrors; | |
* @param int $timestamp | |
{ | |
* @return void | |
* @return string | |
*/ | |
* | |
* /!\ Warning, this is not reliable with PHP < 7.1.4 | |
* | |
* @throws \InvalidArgumentException | |
*/ | |
* @param bool $absolute Get the absolute of the difference | |
* @param int|null $hour | |
{ | |
protected static $midDayAt = 12; | |
return static::translator()->trans($transId, array(':time' => $time)); | |
return $this->setDate($this->year, 12, 31)->endOfDay(); | |
if ($isNow && !isset($testInstance) && static::isMicrosecondsFallbackEnabled() && ( | |
$check = $date->format('Y-m'); | |
* @return static | |
$count = (int) ($count / static::DAYS_PER_WEEK); | |
} | |
* | |
} | |
* | |
$instance = static::createFromFormat('!Y-n-j G:i:s', sprintf('%s-%s-%s %s:%02s:%02s', $year, $month, $day, $hour, $minute, $second), $tz); | |
* @return static | |
} | |
$translator->trans('period_recurrences') !== 'period_recurrences' && | |
* @see gte() | |
* | |
return $this->subMonthsNoOverflow($value); | |
* | |
} | |
* @param int|null $month | |
* 5 months before | |
* Please see the testing aids section (specifically static::setTestNow()) | |
// The formats below are combinations of the above formats. | |
* Modify to midday, default to self::$midDayAt | |
return $this->addWeeks(-1 * $value); | |
$instance->addYears($fixYear); | |
protected static $microsecondsFallback = true; | |
* | |
* | |
static::$midDayAt = $hour; | |
* | |
}); | |
*/ | |
$this->month = $value; | |
* @return static | |
* @param int $day | |
} | |
return $this->setTimestamp($value); | |
$message .= "{$expect}, "; | |
return static::now($this->getTimezone()); | |
* negative $value travels into the past. | |
* | |
/** | |
* | |
return $this->addMonths(static::MONTHS_PER_QUARTER * $value); | |
public static function resetToStringFormat() | |
*/ | |
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) { | |
* @property-read string $englishDayOfWeek the day of week in English | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
// 64 bit | |
public static function make($var) | |
* @property int $year | |
{ | |
} | |
const THURSDAY = 4; | |
* | |
/** | |
* @param \DateTimeZone|string|null $tz | |
* @see https://en.wikipedia.org/wiki/ISO_8601#Week_dates | |
* @return static | |
public function nextWeekendDay() | |
* | |
public function subMinutes($value) | |
* @return static | |
* @return static | |
* | |
*/ | |
/** | |
} | |
/** | |
* @return void | |
} | |
* @return bool | |
} | |
{ | |
* @param int $humanDiffOption | |
} | |
* will be 0. | |
return $this->format($format) === $date->format($format); | |
$ofSameYear = is_null($ofSameYear) ? static::shouldCompareYearWithMonth() : $ofSameYear; | |
self::MONDAY => 'Monday', | |
$count = 1; | |
* @param callable $callback | |
* @see ne() | |
{ | |
* @param int|null $dayOfWeek day of the week default null | |
if ($this->shouldOverflowYears()) { | |
const WEDNESDAY = 3; | |
return $this->diffInYears(); | |
* | |
} | |
} | |
return $this->addRealSeconds($value); | |
throw new InvalidArgumentException('Unknown or bad timezone ('.$object.')'); | |
* | |
return $checkMicroseconds | |
* @return string | |
* | |
* | |
* | |
throw new InvalidArgumentException('Day of a week should be greater than or equal to 0 and less than or equal to 6.'); | |
* | |
if (is_string($var) && $first !== 'P' && $first !== 'R' && preg_match('/[a-z0-9]/i', $var)) { | |
* @return static | |
} | |
/** | |
*/ | |
} | |
public function subYearNoOverflow($value = 1) | |
* enabled. false if disabled. | |
$date = $this->resolveCarbon($date); | |
const YEARS_PER_CENTURY = 100; | |
* of the current quarter, then return false and no modifications are made. | |
protected static function translator() | |
return $this; | |
/** | |
/** | |
* @param bool $absolute Get the absolute of the difference | |
*/ | |
{ | |
/** | |
* Format the instance as a string using the set format | |
*/ | |
case 'second': | |
* Remove a year from the instance | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
* | |
* Remove a day from the instance | |
/** | |
*/ | |
} | |
* @return bool true if time match a relative date, false if absolute or invalid time string | |
* Remove a minute from the instance. | |
{ | |
} | |
* @return int | |
return $absolute || !$diff->invert ? $value : -$value; | |
* @param Closure $callback | |
public function addYear($value = 1) | |
*/ | |
* @param int $month | |
foreach ($methods as $method) { | |
{ | |
} | |
}); | |
* | |
public static function shouldOverflowYears() | |
* | |
} | |
'year', | |
'dayOfYear' => 'z', | |
*/ | |
/** | |
$value = $diff->days * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE + | |
} | |
* @param int $value | |
/** | |
* Determines if the instance is a weekend day. | |
* | |
*/ | |
$key = $isFuture ? 'diff_tomorrow' : 'diff_yesterday'; | |
'dayOfWeek' => $this->dayOfWeek, | |
/////////////////////////////////////////////////////////////////// | |
if ($fixYear !== null) { | |
* @param int $value | |
return $this->modify("$this->hour:$this->minute:59.999999"); | |
* | |
* @return bool | |
/** | |
/** | |
$key = 'diff_now'; | |
//shift the time according to the given time zone | |
* @var \Carbon\Carbon | |
$date = $this->resolveCarbon($date); | |
$year = $this->year - $this->year % static::YEARS_PER_DECADE; | |
} | |
} | |
{ | |
$translator->trans('period_start_date') !== 'period_start_date' && | |
{ | |
$temp = $date1; | |
$interval = array(); | |
return $this->addYearsWithOverflow($value); | |
* @param int $value | |
* Get the days of the week | |
if ($equal) { | |
$instance = static::create($year, $month, $day, $hour, $minute, $second, $tz); | |
* Set the instance's day | |
* Modify to the first occurrence of a given day of the week | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
* | |
*/ | |
/** | |
* @param \DateTime|\DateTimeInterface $date | |
'day' => array(0, 31), | |
*/ | |
* Modify to the given occurrence of a given day of the week | |
} | |
if (strpos($object, ':') !== false) { | |
*/ | |
* @param int|null $minute | |
*/ | |
*/ | |
public static function maxValue() | |
/////////////////////////////////////////////////////////////////// | |
} | |
public function diffInHoursFiltered(Closure $callback, $date = null, $absolute = true) | |
static::$translator = $translator; | |
* @param bool $equal Indicates if an equal to comparison should be done | |
private static function createFromFormatAndTimezone($format, $time, $tz) | |
} | |
return $this->dayOfWeek === $dayOfWeek; | |
parent::__construct($time, $timezone); | |
*/ | |
} | |
/** | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
/** | |
* | |
* @return static | |
* @param int $value | |
* Add years to the instance. | |
* negative $value travels into the past. | |
* @return int | |
public function subDay($value = 1) | |
* | |
* @return void | |
{ | |
* @param int $value | |
public function setDateTime($year, $month, $day, $hour, $minute, $second = 0) | |
); | |
return $this->addSeconds($value); | |
* @return static | |
* @var int | |
{ | |
* | |
*/ | |
* @return static | |
* Determines if the instance is within next year. | |
return $this->modify((int) $value.' second'); | |
*/ | |
* | |
* negative $value travels into the past. | |
/** | |
* Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow). | |
* forward while negative $value travels into the past. | |
* | |
* Reset the format used to the default when type juggling a Carbon instance to a string | |
///////////////////////// TESTING AIDS //////////////////////////// | |
* | |
$testInstance->modify($time); | |
{ | |
/** | |
* @return static | |
* Checks if the passed in date is the same exact hour as the instance´s hour. | |
public function next($dayOfWeek = null) | |
* | |
* Create a Carbon instance from just a date. The time portion is set to midnight. | |
{ | |
* @param int $value | |
* @param int $value | |
*/ | |
* | |
/** | |
public function addCentury($value = 1) | |
* | |
* Support is considered enabled if the 4 sentences are translated in the given locale. | |
} | |
} | |
* Remove hours from the instance. | |
'v' => '([0-9]{1,3})', | |
/////////////////////////////////////////////////////////////////// | |
} | |
* | |
foreach ($fields as $field => $range) { | |
* | |
} | |
{ | |
$minute = $minute === null ? 0 : $minute; | |
*/ | |
*/ | |
* @var int | |
return $this->modify((int) $value.' week'); | |
* Customizable PHP_INT_SIZE override. | |
* | |
* Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after). | |
* | |
$diff = count($values); | |
* | |
* @return static | |
* | |
*/ | |
* | |
* {@inheritdoc} | |
); | |
*/ | |
return static::createFromTimestamp(~PHP_INT_MAX); // @codeCoverageIgnore | |
* Last day of week. | |
*/ | |
public function isFriday() | |
* 5 months ago | |
* @param string|Closure $format | |
* @return static | |
} | |
{ | |
if ($dayOfWeek === null) { | |
* | |
return $this->day(1); | |
* | |
} | |
* Checks if the passed in date is the same exact second as the instance´s second. | |
return $this->addMonths(-1 * $value); | |
* @return int | |
} | |
*/ | |
* @param array $days | |
$t = $this->toTimeString(); | |
{ | |
array('value' => $diffInterval->d, 'unit' => 'day', 'unitShort' => 'd'), | |
return $this->addQuarters($value); | |
* Names of days of the week. | |
*/ | |
* @see https://github.com/briannesbitt/Carbon/issues/539 | |
{ | |
*/ | |
* @throws \InvalidArgumentException | |
* | |
* | |
*/ | |
protected static $toStringFormat = self::DEFAULT_TO_STRING_FORMAT; | |
} | |
* @param string $format | |
* | |
public function startOfQuarter() | |
{ | |
* | |
* @param int $value | |
return $this->addYearsNoOverflow($value); | |
/** | |
return $this->addWeekdays(-1 * $value); | |
* Indicates if years should be calculated with overflow. | |
return $this->subRealSeconds($value); | |
static::$utf8 = $utf8; | |
} | |
} | |
return $this->startOfQuarter()->addMonths(static::MONTHS_PER_QUARTER - 1)->endOfMonth(); | |
* When comparing a value in the future to default now: | |
public function addMonthsNoOverflow($value) | |
* @see eq() | |
* Format the instance with the current locale. You can set the current | |
* | |
* | |
} | |
* @param int $value | |
case 'day': | |
/** | |
/** | |
* | |
* | |
* | |
return $this->nextOrPreviousDay(false, false); | |
return static::$utf8 ? utf8_encode($formatted) : $formatted; | |
'Y' => '([1-9][0-9]{0,4})', | |
'year' => 'Y', | |
* @return static | |
* @return static | |
return $this->getOffset() / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR; | |
public static function serializeUsing($callback) | |
* | |
} | |
* | |
$year = $this->year - $this->year % static::YEARS_PER_DECADE + static::YEARS_PER_DECADE - 1; | |
return static::create($this->year, 12, 28, 0, 0, 0, $this->tz)->weekOfYear === 53; | |
{ | |
public function addRealSeconds($value) | |
); | |
/** | |
use DateTimeZone; | |
} | |
/** | |
try { | |
* @return static | |
* @var \Symfony\Component\Translation\TranslatorInterface | |
* Support is considered enabled if either year, day or hour has a short variant translated. | |
* | |
return $this->gte($date); | |
} | |
/** | |
* | |
/** | |
public function subMonthsNoOverflow($value) | |
} | |
return $this->toDateString() === static::tomorrow($this->getTimezone())->toDateString(); | |
/** | |
* | |
* @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date. | |
* then return the result of the closure (or null if the closure was void). | |
{ | |
} | |
* | |
* @param int $humanDiffOption | |
* @return bool | |
* To test if it is the same exact month of the same year, pass in true as the second parameter. | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
$reflectionParameters = $reflexion->getParameters(); | |
* | |
* @param int|null $hour | |
/** | |
/** | |
} | |
* @param int $value | |
{ | |
* Add a weekday to the instance | |
* | |
* Modify to the last occurrence of a given day of the week | |
* @param bool $absolute Get the absolute of the difference | |
} | |
* Set the instance's timezone from a string or object | |
*/ | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
* @param int $value | |
return static::parse($date, $this->getTimezone()); | |
* Add a year to the instance | |
* @return static | |
*/ | |
* | |
static::setLastErrors(parent::getLastErrors()); | |
* Note that this defaults to only comparing the month while ignoring the year. | |
* @var string | |
} | |
* @throws \InvalidArgumentException | |
return $this->getOffset() === $this->copy()->setTimezone(date_default_timezone_get())->getOffset(); | |
* Determines if the instance is in the current year. | |
*/ | |
* @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date. | |
* Positive $value travel forward while | |
{ | |
*/ | |
* @param int $value | |
public function diffInMonths($date = null, $absolute = true) | |
*/ | |
} | |
public function __set($name, $value) | |
* | |
{ | |
/** | |
public function toIso8601String() | |
return $this->isSameYear(); | |
* @return static the current instance used for testing | |
public function addQuarters($value) | |
return $this->subDays($value); | |
* @return bool | |
preg_quote($format, '/'), | |
// @codeCoverageIgnoreStart | |
return $date->isWeekend(); | |
/** | |
/** | |
*/ | |
* | |
* @throws \InvalidArgumentException | |
* @return static | |
return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR); | |
{ | |
} | |
} | |
* @throws \InvalidArgumentException | |
*/ | |
*/ | |
*/ | |
* | |
*/ | |
{ | |
{ | |
} | |
* | |
* (c) Brian Nesbitt <brian@nesbot.com> | |
return $this; | |
* To clear the test instance call this method using the default | |
/** | |
* @param array $array | |
} | |
* Add years to the instance with no overflow of months | |
* Modify to the given occurrence of a given day of the week | |
* Determines if the instance is less (before) or equal to another | |
public function toDateTimeString() | |
/** | |
*/ | |
} | |
// Try to create a DateTime object. Throws an InvalidArgumentException if the provided time string | |
public static function setTestNow($testNow = null) | |
return static::parse('yesterday', $tz); | |
{ | |
* | |
return $this->isSameQuarter(); | |
/** | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
{ | |
private static function setLastErrors(array $lastErrors) | |
* Checks if macro is registered. | |
* | |
public function subHour($value = 1) | |
$interval[] = static::translator()->transChoice($unit, $count, array(':count' => $count)); | |
* Remove an hour from the instance. | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
); | |
* @param \DateTimeZone|string|null $tz | |
return $this->year === $this->nowWithSameTz()->addYear()->year; | |
public function toRfc7231String() | |
public function firstOfMonth($dayOfWeek = null) | |
$this->addDay($step); | |
{ | |
} | |
{ | |
* | |
} | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
*/ | |
$inverse = false; | |
} | |
* @return bool | |
{ | |
* Format regex patterns. | |
* | |
*/ | |
} | |
'shortLocaleDayOfWeek' => '%a', | |
* | |
case $name === 'quarter': | |
public function diffInDays($date = null, $absolute = true) | |
'minute' => array(0, 59), | |
return $this->diffInSeconds($date1) > $this->diffInSeconds($date2) ? $date1 : $date2; | |
} | |
* Determines if the instance is within the last week. | |
* | |
return new static(null, $tz); | |
} | |
{ | |
* Get the month comparison default behavior. | |
* | |
use DateTime; | |
{ | |
/** | |
public function eq($date) | |
} | |
return $this->subCenturies($value); | |
$diffIntervalArray = array( | |
{ | |
* @property-read int $offset the timezone offset in seconds from UTC | |
* @return string|int|bool|\DateTimeZone | |
* | |
} | |
/** | |
{ | |
: $this->format('H:i:s') === '00:00:00'; | |
* @return bool | |
($y = $translator->trans('d')) !== 'd' && | |
$regex = strtr( | |
public function addRealHours($value) | |
/////////////////////////////////////////////////////////////////// | |
{ | |
* @param bool $yearsOverflow | |
public static function getLocale() | |
return $this->isSameSecond(); | |
* @param int|null $dayOfWeek | |
return $this->addMonthsNoOverflow($value); | |
} | |
throw new InvalidDateException($field, $$field); | |
* @return bool | |
// Some languages have special pluralization for past and future tense. | |
* | |
} | |
{ | |
public static function setWeekEndsAt($day) | |
return new static('@'.$timestamp); | |
* @param object $mixin | |
* | |
* @throws \InvalidArgumentException | |
$isFuture = $diffInterval->invert === 1; | |
* @param int $value | |
public static function createFromFormat($format, $time, $tz = null) | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
{ | |
*/ | |
* @param int $dayOfWeek | |
* @return static | |
} | |
* forward while negative $value travels into the past. | |
's' => '([0-5][0-9])', | |
* Create a Carbon instance for today. | |
} | |
* | |
* | |
$this->getTimestamp(); | |
* | |
* A simple API extension for DateTime | |
* @param bool $absolute Get the absolute of the difference | |
public function isPast() | |
const MOCK_DATETIME_FORMAT = 'Y-m-d H:i:s.u'; | |
*/ | |
public static function getTranslator() | |
*/ | |
* @return static | |
* Resets the date to the first day of the decade and the time to 00:00:00 | |
public function addYearNoOverflow($value = 1) | |
{ | |
return $this->startOfDay(); | |
* Add weekdays to the instance. Positive $value travels forward while | |
if ($date instanceof static) { | |
return array( | |
{ | |
* @param bool $absolute Get the absolute of the difference | |
return $this->lt($date) ? $this : $date; | |
} | |
}); | |
return $this->subMonthsWithOverflow($value * static::MONTHS_PER_YEAR); | |
$time .= ':0'; | |
* @param \DateTimeZone|string|null $tz | |
/** | |
} | |
* | |
* @return static | |
*/ | |
* @property-read int $quarter the quarter of this instance, 1 - 4 | |
* | |
* Add a second to the instance. | |
// First let's skip the part that will be ignored by the parser. | |
* | |
* Resets the time to 00:00:00 start of day | |
* Get the month comparison default behavior. | |
* | |
protected static $localMacros = array(); | |
* Format the instance as RFC822 | |
* | |
return $this->addSeconds(-1 * $value); | |
* Determines if the instance is less (before) than another | |
* @return string | |
$key = $isFuture ? 'diff_after_tomorrow' : 'diff_before_yesterday'; | |
* | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 | |
} | |
} | |
case isset($formats[$name]): | |
{ | |
* | |
* @return static | |
/** | |
* Set the last day of week | |
public static function getDays() | |
* @return static | |
} | |
return $this->lt($this->nowWithSameTz()); | |
* @return int | |
}, $date, $absolute); | |
/** | |
* @property-read string $localeDayOfWeek the day of week in current locale LC_TIME | |
{ | |
////////////////////////// COMPARISONS //////////////////////////// | |
* | |
* Get the difference in weeks | |
* @param \DateTimeZone|string|null $tz | |
} | |
/** | |
namespace Carbon; | |
{ | |
/** | |
public function diffForHumans($other = null, $absolute = false, $short = false, $parts = 1) | |
public function isLastMonth() | |
{ | |
return $this >= $date; | |
if ($day > static::SATURDAY || $day < static::SUNDAY) { | |
} elseif (!$other instanceof DateTime && !$other instanceof DateTimeInterface) { | |
/** | |
* @param bool $utf8 | |
* @return int | |
* | |
} | |
* | |
{ | |
* | |
* will be 0. | |
{ | |
/** | |
* Options for diffForHumans(). | |
} | |
* @param int $year | |
public function subHours($value) | |
* @return bool | |
return $this->modify($time); | |
} | |
* | |
*/ | |
$timezone = static::safeCreateDateTimeZone($tz); | |
*/ | |
* @return static | |
* | |
/** | |
* | |
* Remove year from the instance with no month overflow | |
static::$regexFormats | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
*/ | |
{ | |
case $name === 'utc': | |
*/ | |
* | |
* @var array | |
/** | |
return $this->startOfDay()->modify('next '.static::$days[$dayOfWeek]); | |
/////////////////////////////////////////////////////////////////// | |
* | |
* | |
{ | |
* | |
* Remove a quarter from the instance | |
* | |
* When comparing a value in the past to another value: | |
*/ | |
*/ | |
} | |
* Set the current translator locale and indicate if the source locale file exists | |
*/ | |
* | |
* Go backward to the previous weekday. | |
* @return void | |
/** | |
return $this->dayOfWeek === static::WEDNESDAY; | |
* | |
throw new InvalidArgumentException('Day of a week should be greater than or equal to 0 and less than or equal to 6.'); | |
} | |
* @return static | |
* Add years to the instance. Positive $value travel forward while | |
{ | |
return $this->format(static::RFC2822); | |
* @return bool | |
public function setTimeFrom($date) | |
} | |
*/ | |
* Create a Carbon instance for yesterday. | |
/////////////////////// STRING FORMATTING ///////////////////////// | |
* Remove months from the instance | |
* @return static | |
} | |
} | |
use DateTimeInterface; | |
{ | |
* @var bool | |
* @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday | |
'minute', | |
public function isSameQuarter($date = null, $ofSameYear = null) | |
* @param \DateTimeZone|string|null $tz | |
); | |
* @return static | |
{ | |
* Remove a weekday from the instance | |
* Alias for setTimezone() | |
/** | |
'day', | |
{ | |
return $this->setDate($year, 1, 1)->startOfDay(); | |
* Get the difference in minutes using timestamps. | |
if ($day > static::SATURDAY || $day < static::SUNDAY) { | |
$this->startOfDay(); | |
* | |
* @return static | |
static::$compareYearWithMonth = $compareYearWithMonth; | |
* in the current month. If no dayOfWeek is provided, modify to the | |
* @param string $locale locale ex. en | |
* @param \DateTimeZone|string $value | |
* | |
return $inverse && !$absolute ? -$diff : $diff; | |
* @param int $humanDiffOptions | |
} | |
* Checks if the passed in date is the same exact minute as the instance´s minute. | |
* @see https://bugs.php.net/bug.php?id=63863 | |
* Alias for setTimezone() | |
* | |
/** | |
*/ | |
* | |
{ | |
} | |
* | |
const MINUTES_PER_HOUR = 60; | |
return static::$weekStartsAt; | |
} | |
* @param int $value | |
{ | |
*/ | |
* @return static | |
} | |
public static function today($tz = null) | |
public function isSameHour($date = null) | |
/** | |
* Determines if the instance is a long year | |
* - A call to the static now() method, ex. Carbon::now() | |
throw new InvalidDateException($field, $$field); | |
public function subCentury($value = 1) | |
while ($this->dayOfWeek !== static::$weekStartsAt) { | |
* @param int|null $month | |
* @param bool $monthsOverflow | |
* | |
} | |
$ofSameYear = is_null($ofSameYear) ? static::shouldCompareYearWithMonth() : $ofSameYear; | |
$instance = static::instance($date); | |
{ | |
static::$microsecondsFallback = $microsecondsFallback; | |
public static function setWeekStartsAt($day) | |
public function addCenturies($value) | |
*/ | |
// @codeCoverageIgnoreEnd | |
* Resets the date to the first day of the century and the time to 00:00:00 | |
/////////////////////////////////////////////////////////////////// | |
case $name === 'timezoneName' || $name === 'tzName': | |
return $instance; | |
/** | |
* | |
/** | |
* @param int|null $hour | |
* Determines if the instance is in the current month. | |
static::macro($method->name, $method->invoke($mixin)); | |
$expectedCount = count($reflectionParameters); | |
* @param int $dayOfWeek | |
*/ | |
/////////////////////////////////////////////////////////////////// | |
/** | |
* When comparing a value in the future to another value: | |
public function startOfWeek() | |
/** | |
*/ | |
} | |
* @return bool | |
/** | |
* @return void | |
'o' => '([1-9][0-9]{0,4})', | |
switch ($name) { | |
throw new \BadMethodCallException("Method $method does not exist."); | |
* | |
throw new InvalidArgumentException(implode(PHP_EOL, $lastErrors['errors'])); | |
'month' => array(0, 12), | |
/** | |
* @return static | |
public function isLastWeek() | |
public function isLeapYear() | |
* | |
* @param int $value | |
/** | |
* @return bool | |
{ | |
* Determines if the instance is not equal to another | |
public function startOfCentury() | |
/** | |
public function addSecond($value = 1) | |
* @return bool | |
* @return bool | |
$date1 = new DateTime('2000-01-01T00:00:00Z'); | |
} | |
/** | |
public static function getWeekStartsAt() | |
* | |
{ | |
// Regenerate date from the modified format to base result on the mocked instance instead of now. | |
/** | |
return static::instance($var); | |
* @return string | |
/** | |
public function hour($value) | |
public function timestamp($value) | |
* @return bool | |
} | |
*/ | |
* Return a serialized string of the instance. | |
$lastErrors = parent::getLastErrors(); | |
* @property int $yearIso | |
* negative $value travels into the past. | |
* @param bool $forward | |
{ | |
* @return static | |
*/ | |
* | |
/////////////////////////////////////////////////////////////////// | |
* | |
} | |
* | |
public function subCenturies($value) | |
* Get a part of the Carbon object | |
* | |
* @param string $method | |
* | |
{ | |
} | |
* @param int $value | |
* | |
* | |
return $this->gt($date1) && $this->lt($date2); | |
$diff = $this->diff($this->resolveCarbon($date)); | |
* | |
* | |
/** | |
* @return static | |
{ | |
/** | |
* 1 hour after | |
* | |
* | |
* @return static | |
} | |
/** | |
* Get the difference in hours. | |
*/ | |
/** | |
} | |
* @return array|string | |
case $name === 'timezone' || $name === 'tz': | |
/** | |
* @return mixed | |
$fixYear = null; | |
return $instance; | |
* Get weekend days | |
public function subWeekdays($value) | |
* Get the difference in hours using timestamps. | |
*/ | |
version_compare(PHP_VERSION, '7.1.3-dev', '>=') && version_compare(PHP_VERSION, '7.1.4-dev', '<') | |
$value = $this->$method($format); | |
* If $hour is not null then the default values for $minute and $second | |
$tz = @timezone_open($object = (string) $object); | |
/** | |
* @property int $second | |
*/ | |
* | |
* Determines if the instance is within the next week. | |
/** | |
* Get the difference as a CarbonInterval instance | |
*/ | |
*/ | |
* | |
*/ | |
* | |
/** | |
} else { | |
*/ | |
*/ | |
} | |
return $this->subMinutes($value); | |
* @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday) | |
* | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
'y' => '([0-9]{2})', | |
public function toArray() | |
/** | |
/////////////////////////// SERIALIZATION ///////////////////////// | |
return static::$yearsOverflow; | |
{ | |
* @return bool | |
* Set midday/noon hour | |
$this->setDateTime($year, $month, $day, $hour, $minute, $second); | |
public function isLongYear() | |
*/ | |
return $this->format(static::COOKIE); | |
public function isNextWeek() | |
/** | |
* @param int $value | |
public function lt($date) | |
return $this->format(static::RFC822); | |
$tz = $testInstance->getTimezone(); | |
* Determines if the instance is within the last quarter. | |
* @return static | |
return $this->modify((int) $value.' year'); | |
return $this->toDateString() === $this->nowWithSameTz()->toDateString(); | |
* @return static | |
* @return string | |
} | |
// doesn't match the format in any way. | |
return $object; | |
* in the current year. If the calculated occurrence is outside the scope | |
/** | |
public function toCookieString() | |
return $this->gt($date) ? $this : $date; | |
} | |
* @return static | |
/** | |
{ | |
const ONE_DAY_WORDS = 04; | |
'year' => $this->year, | |
/** | |
// Don't return null... avoid Bug #52063 in PHP <5.3.6 | |
return (int) $this->diff($this->resolveCarbon($date), $absolute)->format('%r%y'); | |
{ | |
return $this->subQuarters($value); | |
* @return static | |
/** | |
* Resets the date to the first day of the month and the time to 00:00:00 | |
} | |
* | |
* Checks if this day is a specific day of the week. | |
} | |
* Get a Carbon instance for the current date and time. | |
return $this < $date; | |
} | |
{ | |
$fields = array( | |
{ | |
{ | |
$this->__get($name); | |
{ | |
* | |
* | |
* @return CarbonInterval | |
*/ | |
if ($isNow && static::getHumanDiffOptions() & self::JUST_NOW) { | |
* The day constants. | |
} | |
/** | |
* | |
} | |
public static function localeHasPeriodSyntax($locale) | |
if ($absolute) { | |
/** | |
* negative $value travels into the past. | |
public function endOfQuarter() | |
* | |
public function isCurrentDay() | |
* | |
{ | |
* | |
* @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day. | |
protected static $serializer; | |
* @var bool | |
{ | |
} | |
$testInstance = clone static::getTestNow(); | |
/** | |
$now = static::hasTestNow() ? static::getTestNow() : static::now($tz); | |
* @return static | |
/** | |
* @return $this | |
* If $hour is null it will be set to its now() value and the default | |
return $this->month(1)->firstOfMonth($dayOfWeek); | |
* | |
*/ | |
* @return int | |
* @param int $value | |
*/ | |
* @param bool $absolute Get the absolute of the difference | |
* @param int|null $year | |
throw new InvalidArgumentException(sprintf("Unknown setter '%s'", $name)); | |
* @return static | |
* @param bool $microsecondsFallback | |
if ($object === null) { | |
* @property int $day | |
/** | |
/** | |
* @return static | |
*/ | |
* Checks if the passed in date is in the same month as the instance´s month. | |
*/ | |
{ | |
), explode('-', $now->format('Y-n-j-G-i-s'))); | |
* @property-read string $shortLocaleMonth the abbreviated month in current locale LC_TIME | |
* | |
return $this->addDays($value); | |
$other = static::parse($other); | |
/** | |
public function subRealMinutes($value = 1) | |
* | |
* | |
/** | |
* | |
/** | |
return $this->format('Y-m-d H:i:s'); | |
* | |
{ | |
*/ | |
*/ | |
$formatted = strftime($format, strtotime($this->toDateTimeString())); | |
) || ( | |
* | |
* in the current year. If no dayOfWeek is provided, modify to the | |
return $this->format('L') === '1'; | |
* @return static | |
/** | |
/** | |
{ | |
* Remove minutes from the instance. | |
$fixYear = $year - 9999; | |
'shortLocaleMonth' => '%b', | |
* | |
} | |
* | |
*/ | |
* Format the instance as RFC850 | |
* @var array | |
* Determines if the instance is in the current minute. | |
$this->year = $value; | |
return $this->format(static::RFC850); | |
* The custom Carbon JSON serializer. | |
{ | |
* | |
* @return static | |
) { | |
* Go forward to the next weekend day. | |
* Set the first day of week | |
* @return static | |
* @return bool | |
*/ | |
{ | |
* @param int $hour midday hour | |
* Resets the date to end of the century and time to 23:59:59 | |
* Checks if the (date)time string is in a given format. | |
*/ | |
/** | |
* @return static | |
* @param int $day week start day | |
public function maximum($date = null) | |
{ | |
{ | |
return $this->setDate($year, $month, $day)->setTime($hour, $minute, $second); | |
* @return string | |
{ | |
public function isMidnight() | |
*/ | |
if (!static::hasMacro($method)) { | |
*/ | |
* @param string $name | |
use Carbon\Exceptions\InvalidDateException; | |
* @return bool | |
/////////////////////////////////////////////////////////////////// | |
*/ | |
/** | |
} | |
*/ | |
* Create an instance from a serialized string. | |
unset($diffIntervalArray, $interval); | |
} | |
/** | |
* | |
return $this->isSameAs('Y-m-d H:i', $date); | |
public static function setMidDayAt($hour) | |
$this->subDay(); | |
* @param Closure $callback | |
*/ | |
public function isDayOfWeek($dayOfWeek) | |
/** | |
} | |
{ | |
* | |
const DEFAULT_TO_STRING_FORMAT = 'Y-m-d H:i:s'; | |
* | |
* @return static | |
* @throws \BadMethodCallException|\ReflectionException | |
* | |
'weekOfYear' => 'W', | |
public function diffInYears($date = null, $absolute = true) | |
*/ | |
return $this->subRealMinute($value); | |
*/ | |
* @return bool | |
$instance = @unserialize($value); | |
* @return bool | |
{ | |
* @return static | |
} | |
*/ | |
$second = $second === null ? $defaults['second'] : $second; | |
* | |
* @return static | |
} | |
} | |
* if null given or parse the input if string given. | |
* Resets the date to end of the year and time to 23:59:59 | |
* @return static | |
* | |
public static function useMicrosecondsFallback($microsecondsFallback = true) | |
* Create a Carbon instance from a specific format. | |
/** | |
{ | |
{ | |
* | |
/** | |
* | |
* | |
* @return string | |
$transId = $isNow ? ($isFuture ? 'from_now' : 'ago') : ($isFuture ? 'after' : 'before'); | |
return $this->gte($date1) && $this->lte($date2); | |
* @param \DateTimeZone|string|null $tz | |
/** | |
return $this->lt($date); | |
* @return int | |
/** | |
/** | |
* Set the instance's year | |
$time = static::translator()->transChoice($key, $count, array(':count' => $count)); | |
* | |
{ | |
* @throws \InvalidArgumentException | |
* | |
* travels forward while negative $value travels into the past. | |
/** | |
$start = $this; | |
* | |
* | |
*/ | |
*/ | |
{ | |
*/ | |
{ | |
return $this->addCenturies($value); | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
'day' => 'j', | |
return static::$monthsOverflow; | |
} | |
public function addWeeks($value) | |
* @return bool | |
} | |
*/ | |
* @param int $day | |
$unit = $short ? 'w' : 'week'; | |
/** | |
* | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
return $this->isSameMonth($ofSameYear); | |
{ | |
// 32 bit | |
* Dynamically handle calls to the class. | |
{ | |
$this->hour = $value; | |
return $this->copy() | |
* | |
if (static::shouldOverflowMonths()) { | |
*/ | |
* @param int $value | |
* Format to use for __toString method when type juggling occurs. | |
* @param int $value | |
/** | |
*/ | |
/** | |
/** | |
*/ | |
* @return static | |
* @param string $locale locale ex. en | |
public function lastOfYear($dayOfWeek = null) | |
*/ | |
* | |
} | |
public static function mixin($mixin) | |
* @return static | |
public static function createFromTimestampUTC($timestamp) | |
$this->setTimezone($value); | |
*/ | |
* @param int $value | |
* @param int $value | |
* | |
*/ | |
* Set the hour, day, and time for this instance to that of the passed instance. | |
* Determines if the instance is within the next quarter. | |
/** | |
* Positive $value travel forward while | |
public function addMonths($value) | |
{ | |
} | |
} | |
} | |
/** | |
} | |
* - When a string containing the desired time is passed to Carbon::parse(). | |
} | |
return !$this->eq($date); | |
* Add a week to the instance | |
} | |
* @param int|null $day | |
}); | |
* | |
* Get the closest date from the instance. | |
* last day of the current year. Use the supplied constants | |
} | |
*/ | |
const TUESDAY = 2; | |
return $date->isWeekday(); | |
* | |
protected function resolveCarbon($date = null) | |
$translation = static::translator()->trans($key); | |
*/ | |
return static::parse($var); | |
/** | |
} | |
* | |
public function addMonthNoOverflow($value = 1) | |
{ | |
/** | |
*/ | |
*/ | |
* | |
*/ | |
* | |
*/ | |
} | |
{ | |
* @return static | |
} | |
public function equalTo($date) | |
} | |
} | |
public static function createFromTimestampMs($timestamp, $tz = null) | |
return $locales; | |
} | |
// If the class has a test now set and we are trying to create a now() | |
*/ | |
* @param int $parts displays number of parts in the interval | |
class Carbon extends DateTime implements JsonSerializable | |
/** | |
} | |
* forward while negative $value travels into the past. | |
} | |
*/ | |
* Get the difference in a human readable format in the current locale. | |
public function isWeekend() | |
* Return true if microseconds fallback on PHP < 7.1 and 7.1.3 is | |
} | |
public function startOfDecade() | |
$y !== $translator->trans('day') | |
return $this->modify('00:00:00.000000'); | |
return $this->addYearsWithOverflow($value); | |
/** | |
*/ | |
{ | |
*/ | |
public function subMinute($value = 1) | |
} | |
public function isWednesday() | |
* @return static | |
return $this->addRealMinutes($value); | |
* @param int $value | |
* Create a new Carbon instance. | |
* Calls modify as a workaround for a php bug | |
public function addSeconds($value) | |
$translator->trans('after') !== 'after'; | |
* | |
* | |
*/ | |
{ | |
* | |
*/ | |
public function isSameMonth($date = null, $ofSameYear = null) | |
* @return bool | |
* | |
return CarbonInterval::instance($this->diff($this->resolveCarbon($date), $absolute)); | |
*/ | |
* | |
} | |
public function setTimezone($value) | |
public function timezone($value) | |
$translator->trans('diff_tomorrow') !== 'diff_tomorrow'; | |
* @return static | |
public static function getWeekEndsAt() | |
/** | |
public static function hasTestNow() | |
* @param int $value | |
* @return int | |
$this->modify('last day of previous month'); | |
array('value' => $diffInterval->i, 'unit' => 'minute', 'unitShort' => 'min'), | |
* Modify to the previous occurrence of a given day of the week. | |
* @return static | |
* Get the minimum instance between a given instance (default now) and the current instance. | |
* @param bool $absolute Get the absolute of the difference | |
* @return void | |
* | |
* @return array | |
/** | |
* | |
/** | |
* @return \Symfony\Component\Translation\TranslatorInterface | |
public static function resetYearsOverflow() | |
{ | |
* | |
/** | |
/** | |
*/ | |
return $this->modify((int) $value.' day'); | |
* | |
* | |
public function toRfc850String() | |
public function diffInDaysFiltered(Closure $callback, $date = null, $absolute = true) | |
{ | |
return static::$humanDiffOptions; | |
/** | |
} catch (InvalidArgumentException $e) { | |
return static::createFromFormat('O', $object)->getTimezone(); | |
* | |
* Resets the date to end of the month and time to 23:59:59 | |
return $this->addYears(-1 * $value); | |
$parameters[] = $this; | |
* @return static | |
/** | |
public function toAtomString() | |
/** | |
* | |
* | |
public function startOfHour() | |
* | |
break; | |
protected static $testNow; | |
* | |
return $instance; | |
* | |
} | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
* @return bool | |
throw new InvalidArgumentException(sprintf("Unknown getter '%s'", $name)); | |
{ | |
/** | |
} | |
public function isSameMinute($date = null) | |
* @return mixed | |
* @param int $dayOfWeek | |
* @return static | |
: $this->format('H:i:s') === '23:59:59'; | |
/** | |
* Checks if the passed in date is in the same quarter as the instance quarter (and year if needed). | |
public function addWeekdays($value) | |
*/ | |
if ($expectedCount > $actualCount && $reflectionParameters[$expectedCount - 1]->name === 'self') { | |
*/ | |
* Get the month overflow behavior. | |
* | |
/** | |
* negative $value travel into the past. | |
); | |
*/ | |
* @param int $value | |
return $this->gt($this->nowWithSameTz()); | |
/** | |
*/ | |
public function copy() | |
public function addMinutes($value) | |
->setTimezone($tz); | |
* @param \Carbon\Carbon|null $testNow real or mock Carbon instance | |
{ | |
* | |
public function previousWeekendDay() | |
* @return static | |
{ | |
/** | |
{ | |
list($microTime, $timeStamp) = explode(' ', microtime()); | |
return $this; | |
{ | |
* @param Closure $callback | |
$date->modify('+'.$nth.' '.static::$days[$dayOfWeek]); | |
public static function getLastErrors() | |
return $this->modify('last '.static::$days[$dayOfWeek].' of '.$this->format('F').' '.$this->year); | |
* The number of seconds until 23:59:59. | |
{ | |
* @return static|null | |
} | |
$inverse = true; | |
} | |
* Get the farthest date from the instance. | |
* | |
foreach (glob(__DIR__.'/Lang/*.php') as $file) { | |
/** | |
} | |
$dateTime->setTimestamp($timeStamp); // Use the timestamp returned by microtime as now can happen in the next second | |
* | |
return $this->subHours($value); | |
* Determines if the instance is within the last month. | |
* @param string|int|\DateTimeZone $value | |
} | |
* @return string | |
* Get default array representation | |
if (self::$PHPIntSize === 4) { | |
'H' => '(2[0-3]|[01][0-9])', | |
}); | |
return $this->ne($date); | |
return $this->addMonthsNoOverflow($value * static::MONTHS_PER_YEAR); | |
* @throws InvalidArgumentException | |
*/ | |
$object = $tzName; | |
} | |
*/ | |
* in the current month. If the calculated occurrence is outside the scope | |
* @return static | |
* Get the difference in weekend days using a filter | |
/** | |
* @param string|null $time | |
if ($translation !== $key) { | |
*/ | |
return $this->day === $this->daysInMonth; | |
/////////////////////////////////////////////////////////////////// | |
{ | |
* @return bool | |
{ | |
* | |
} | |
/////////////////////////////////////////////////////////////////// | |
return $this->endOfDay(); | |
* | |
{ | |
* @param int $value | |
* Checks if the passed in date is the same exact day as the instance´s day. | |
public function second($value) | |
} | |
} | |
* @return int | |
public function isSunday() | |
} | |
*/ | |
* | |
*/ | |
* for more on the possibility of this constructor returning a test instance. | |
* @see gt() | |
} | |
} | |
/** | |
return $this->subRealHours($value); | |
return $this->setDate($this->year, $this->month, $this->daysInMonth)->endOfDay(); | |
/** | |
* @param int $value | |
* Checks if this day is a Saturday. | |
* @param bool $absolute Get the absolute of the difference | |
/** | |
* @param int|null $minute | |
}); | |
} | |
public function setDate($year, $month, $day) | |
* Reset the month overflow behavior. | |
*/ | |
* | |
{ | |
* | |
* @return bool | |
* @param int $value | |
* @param string $locale locale ex. en | |
/** | |
* Add seconds to the instance using timestamp. Positive $value travels | |
* @return static | |
public function isLastOfMonth() | |
public function diffInWeekendDays($date = null, $absolute = true) | |
$diff->h * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE + | |
*/ | |
} | |
* | |
* @return int | |
* 5 months from now | |
* @return int | |
$year = $year === null ? $defaults['year'] : $year; | |
* | |
protected static $regexFormats = array( | |
/** | |
} | |
public function subWeekday($value = 1) | |
* Add a day to the instance | |
return parent::setDate($year, $month, $day); | |
* @var string | |
} | |
* Remove a week from the instance | |
* @return bool | |
parent::setTimestamp($value); | |
{ | |
* | |
*/ | |
} | |
public function endOfDay() | |
} | |
* | |
* | |
/** | |
} | |
} | |
* @return bool | |
* | |
/** | |
*/ | |
* | |
*/ | |
* @return static | |
public function gt($date) | |
* @return static | |
* @param int $day | |
} | |
* Get the difference in seconds. | |
*/ | |
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null) | |
} | |
*/ | |
* @return void | |
* | |
* | |
$date->firstOfQuarter()->modify('+'.$nth.' '.static::$days[$dayOfWeek]); | |
/////////////////////////////////////////////////////////////////// | |
if ($date1->gt($date2)) { | |
} | |
if ($count === 2 && static::getHumanDiffOptions() & self::TWO_DAY_WORDS) { | |
* @property int $timestamp seconds since the Unix Epoch | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
* @param bool $short displays short format of time units | |
* Create a new Carbon instance from a specific date and time. | |
$date = $this->resolveCarbon($date); | |
* | |
* Mix another object into the class. | |
} | |
/** | |
* @param bool $ofSameYear Check if it is the same month in the same year. | |
* | |
$isNow = $other === null; | |
'timezone' => $this->timezone, | |
*/ | |
} | |
$tz = $mock->getTimezone(); | |
{ | |
/** | |
*/ | |
* Create a carbon instance from a string. | |
/** | |
* | |
{ | |
} | |
} | |
public static function createFromTime($hour = null, $minute = null, $second = null, $tz = null) | |
* @return int | |
return $this->addSeconds((int) ($this->diffInSeconds($this->resolveCarbon($date), false) / 2)); | |
*/ | |
* @return string | |
* @return static | |
* Set the instance's second | |
* Create a Carbon instance from a timestamp. | |
$this->addDay(); | |
/** | |
'hour' => $this->hour, | |
} | |
* @return void | |
return $this->dayOfWeek === static::SATURDAY; | |
* | |
} | |
* Get the difference in years | |
{ | |
public function setDateFrom($date) | |
* to indicate the desired dayOfWeek, ex. static::MONDAY. | |
public function isFuture() | |
} | |
* @param bool $absolute Get the absolute of the difference | |
$value = $date->getTimestamp() - $this->getTimestamp(); | |
* Determines if the instance is greater (after) than another | |
} | |
* Creates a DateTimeZone from a string, DateTimeZone or integer offset. | |
/////////////////////////////////////////////////////////////////// | |
} | |
*/ | |
if ($diffIntervalData['value'] > 0) { | |
* | |
'c' => '(([1-9][0-9]{0,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 | |
return static::today($tz)->setTimeFromTimeString($time); | |
} | |
/** | |
* @var callable|null | |
if ($diffIntervalData['unit'] === 'day' && $count >= static::DAYS_PER_WEEK) { | |
* @param int $value | |
if ($count === 1 && static::getHumanDiffOptions() & self::ONE_DAY_WORDS) { | |
/** | |
} | |
/** | |
} | |
return static::$weekEndsAt; | |
} | |
/** | |
{ | |
* | |
* @param int $value | |
* @property-read int $daysInMonth number of days in the given month | |
*/ | |
* @return static | |
* @property-read string $shortEnglishMonth the abbreviated day of week in English | |
*/ | |
$diff->i * static::SECONDS_PER_MINUTE + | |
{ | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 | |
} | |
return $this->setTimezone($value); | |
* | |
*/ | |
* Format the instance as RSS | |
* @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday) | |
* | |
{ | |
* @return string | |
/** | |
* to indicate the desired dayOfWeek, ex. static::MONDAY. | |
* | |
*/ | |
/** | |
public function startOfSecond() | |
* @param int|null $minute | |
public function diffInWeeks($date = null, $absolute = true) | |
* @return array | |
* | |
* @return static | |
return $newLocale && | |
'shortEnglishDayOfWeek' => 'D', | |
return $this->quarter === $date->quarter && (!$ofSameYear || $this->isSameYear($date)); | |
} | |
return $this->setTime(self::$midDayAt, 0, 0); | |
* Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. | |
* Get the maximum instance between a given instance (default now) and the current instance. | |
public function isYesterday() | |
/////////////////////////////////////////////////////////////////// | |
case $name === 'dst': | |
* @return static | |
* @return string | |
* Determines if the instance is not equal to another | |
public static function createFromTimeString($time, $tz = null) | |
return $this->addYears($value); | |
* @var string | |
* @return static | |
* Modify to end of current minute, seconds become 59 | |
*/ | |
return $this->modify((int) $value.' minute'); | |
{ | |
/** | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
public static function disableHumanDiffOption($humanDiffOption) | |
public static function getWeekendDays() | |
return new static($time, $tz); | |
*/ | |
/** | |
* @return static | |
} | |
$carbon = $this; | |
return (int) ($this->diffInSeconds($date, $absolute) / static::SECONDS_PER_MINUTE); | |
} | |
* Resets the date to the first day of the quarter and the time to 00:00:00 | |
{ | |
* @return bool | |
* @param bool $absolute Get the absolute of the difference | |
/** | |
{ | |
return $this->max($date); | |
* | |
* in the current year. If no dayOfWeek is provided, modify to the | |
* | |
return $this->setDate($this->year, $this->quarter * static::MONTHS_PER_QUARTER - 2, 1)->firstOfMonth($dayOfWeek); | |
* Add months to the instance. Positive $value travels forward while | |
* | |
* Check if the instance is start of day / midnight. | |
public function subMonth($value = 1) | |
{ | |
* to indicate the desired dayOfWeek, ex. static::MONDAY. | |
} | |
* | |
* Get the difference in days | |
public function subRealSeconds($value) | |
*/ | |
{ | |
* @return static | |
{ | |
return static::$translator; | |
* | |
'w' => '([0-6])', | |
* | |
* @param int|null $day | |
/** | |
* @param bool $absolute Get the absolute of the difference | |
case $name === 'offsetHours': | |
} | |
* | |
public function isNextYear() | |
} | |
{ | |
* Add months to the instance. Positive $value travels forward while | |
return $this->setDate($year, 12, 31)->endOfDay(); | |
*/ | |
*/ | |
if ($$field !== null && (!is_int($$field) || $$field < $range[0] || $$field > $range[1])) { | |
* @param int $value | |
* | |
return static::$weekendDays; | |
/** | |
const MONTHS_PER_YEAR = 12; | |
/** | |
{ | |
* Create a new safe Carbon instance from a specific date and time. | |
* @return mixed | |
* @var string | |
* @param int $value | |
{ | |
* @param bool $weekday | |
public function startOfYear() | |
*/ | |
} | |
* | |
} | |
/** | |
{ | |
* @return int | |
/** | |
* instance is created. | |
* Add microseconds to now on PHP < 7.1 and 7.1.3. true by default. | |
*/ | |
{ | |
'h' => '(1[012]|0[1-9])', | |
'd' => '(3[01]|[12][0-9]|0[1-9])', | |
* @var bool | |
/** | |
public function isCurrentMinute() | |
'localeDayOfWeek' => '%A', | |
const WEEKS_PER_MONTH = 4; | |
* | |
* | |
* | |
*/ | |
* | |
public function isSameSecond($date = null) | |
* | |
$date2 = $temp; | |
'm' => '(1[012]|0[1-9])', | |
* @return bool | |
/** | |
} | |
* | |
* | |
} | |
* Set weekend days | |
* negative $value travel into the past. | |
* | |
* | |
{ | |
if ($year < 0) { | |
const MONTHS_PER_QUARTER = 3; | |
{ | |
case 'minute': | |
} | |
return $this->addWeeks($value); | |
* Go forward to the next weekday. | |
public function isNextMonth() | |
* @var array | |
* of the current month, then return false and no modifications are made. | |
* Convert the instance to UTC and return as Zulu ISO8601 | |
* to indicate the desired dayOfWeek, ex. static::MONDAY. | |
* | |
* @param int $value | |
throw new InvalidArgumentException('Unknown or bad timezone ('.$object.')'); | |
/** | |
* @param \DateTimeZone|string|null $tz | |
/** | |
* Default format to use for __toString method when type juggling occurs. | |
*/ | |
static::expectDateTime($date); | |
* | |
return $this->subMonths($value); | |
'i' => '([0-5][0-9])', | |
*/ | |
$defaults = array_combine(array( | |
* Check if its the birthday. Compares the date/month values of the two dates. | |
throw new InvalidArgumentException('Invalid serialized value.'); | |
* @return bool | |
* Get the maximum instance between a given instance (default now) and the current instance. | |
} | |
return $this->getTimezone()->getName(); | |
* @return static | |
if ($translation !== $key) { | |
/** | |
/** | |
}, $date, $absolute); | |
* @param CarbonInterval $ci An interval to traverse by | |
* @property int $hour | |
public function toRfc1036String() | |
* | |
* @param int $value | |
if ($isNow) { | |
public static $PHPIntSize = PHP_INT_SIZE; | |
/** | |
* Create a Carbon instance from a timestamp in milliseconds. | |
* | |
{ | |
public function lte($date) | |
$year = 9999; | |
public function day($value) | |
* @return bool | |
return $this->quarter === $this->nowWithSameTz()->subQuarter()->quarter; | |
* @return void | |
if (!$date) { | |
* | |
* get midday/noon hour | |
* | |
} | |
return $this->format('M j, Y'); | |
} | |
} | |
* | |
* Determines if the instance is in the past, ie. less (before) than now. | |
* | |
if ($object instanceof DateTimeZone) { | |
* Remove years from the instance. | |
* @return static | |
} | |
return $this->format('H:i:s'); | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 | |
* to indicate the desired dayOfWeek, ex. static::MONDAY. | |
* | |
* | |
* @return static | |
return $this->addMonthsWithOverflow($value); | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
*/ | |
{ | |
* | |
* @return string | |
return (int) ($this->diffInSeconds($date, $absolute) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR); | |
* @return bool | |
* Set the instance's month | |
public function diffInRealHours($date = null, $absolute = true) | |
*/ | |
$year = $date->year; | |
* | |
* Midday/noon hour. | |
return $this; | |
* Determines if the instance is a weekday. | |
$translator->trans('diff_before_yesterday') !== 'diff_before_yesterday' && | |
* @param int $value | |
/** | |
} | |
* @return static | |
* | |
* @param int $value | |
*/ | |
* | |
} | |
* | |
/** | |
} | |
* | |
* | |
* | |
{ | |
{ | |
case $name === 'age': | |
/** | |
$translator->trans('period_end_date') !== 'period_end_date'; | |
* @return bool | |
* | |
{ | |
public function greaterThan($date) | |
{ | |
public static function getMidDayAt() | |
* @param int|null $dayOfWeek day of the week default null | |
* | |
} | |
* Get the difference in hours using a filter closure | |
} | |
*/ | |
*/ | |
{ | |
* | |
* Set the instance's minute | |
} | |
* @param int $value | |
if (!preg_match("/{$nonEscaped}[!|]/", $format)) { | |
* Determines if the instance is within the previous year. | |
*/ | |
* negative $value travel into the past. | |
* @return int | |
* | |
return $this->nextOrPreviousDay(false); | |
/** | |
*/ | |
public function toIso8601ZuluString() | |
} | |
* Dynamically handle calls to the class. | |
* Add a month with no overflow to the instance | |
{ | |
'timestamp' => $this->timestamp, | |
* @return int | |
return $this->eq($date); | |
public function __construct($time = null, $tz = null) | |
* Register a custom macro. | |
* | |
} | |
$locale = setlocale(LC_NUMERIC, '0'); | |
public function addWeek($value = 1) | |
* | |
} | |
{ | |
} | |
* Create a Carbon instance from a time string. The date portion is set to today. | |
} | |
* @param string $format | |
* @return static | |
* | |
return $this->addQuarters(-1 * $value); | |
{ | |
|| | |
* @return static | |
* Returns the list of internally available locales and already loaded custom locales. | |
return $this->format('Y-m-d'); | |
* | |
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format); // @codeCoverageIgnore | |
* | |
* | |
return get_object_vars($carbon); | |
* | |
/** | |
* @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day. | |
{ | |
* If $hour is not null then the default values for $minute and $second | |
* Set if UTF8 will be used for localized date/time | |
* | |
*/ | |
} | |
* | |
/** | |
return in_array($this->dayOfWeek, static::$weekendDays); | |
* Note the timezone parameter was left out of the examples above and | |
} | |
return $this->diffInDaysFiltered(function (Carbon $date) { | |
public function __get($name) | |
return (bool) preg_match('/^'.$regex.'$/', $date); | |
default: | |
} | |
* | |
$message.'DateTime or DateTimeInterface, '. | |
* | |
* first day of the current quarter. Use the supplied constants | |
return $this->subYears($value); | |
* | |
} | |
/** | |
} | |
/** | |
* Set the current locale to the given, execute the passed function, reset the locale to previous one, | |
*/ | |
} | |
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) { | |
if (static::$localMacros[$method] instanceof Closure && method_exists('Closure', 'bind')) { | |
* @param \DateTimeZone|string $value | |
for ($i = $actualCount; $i < $expectedCount - 1; $i++) { | |
* @param string $time | |
return $this->format(static::RFC1123); | |
* Add hours to the instance using timestamp. Positive $value travels | |
static::$humanDiffOptions = static::getHumanDiffOptions() | $humanDiffOption; | |
*/ | |
* Checks if this day is a Thursday. | |
public function toTimeString() | |
/** | |
* @param int $value | |
return $this->setDate($year, 1, 1)->startOfDay(); | |
if (static::hasTestNow() && ($isNow || static::hasRelativeKeywords($time))) { | |
*/ | |
public function subRealSecond($value = 1) | |
* @param mixed $var | |
* negative $value travels into the past. | |
* Add microseconds to now on PHP < 7.1 and 7.1.3 if set to true, | |
return $this->subYearsWithOverflow($value); | |
'year' => array(0, 9999), | |
* @property int $minute | |
return clone $this; | |
/** | |
*/ | |
{ | |
/** | |
* | |
'localeMonth' => '%B', | |
{ | |
* | |
* Check if the instance is end of day. | |
* | |
* | |
} else { | |
{ | |
/** | |
*/ | |
} | |
} | |
* | |
/** | |
} | |
* @param int $value | |
/** | |
} | |
return static::create(9999, 12, 31, 23, 59, 59); | |
/** | |
} | |
* | |
* @return bool | |
*/ | |
{ | |
public function secondsUntilEndOfDay() | |
/** | |
return $this; | |
public static function createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) | |
array('value' => $diffInterval->s, 'unit' => 'second', 'unitShort' => 's'), | |
* @return static | |
* | |
* | |
*/ | |
{ | |
* Format the instance as W3C | |
if ($tzName === false) { | |
* @param int $value | |
*/ | |
// https://bugs.php.net/bug.php?id=72338 | |
return $this->addMinutes(-1 * $value); | |
} | |
* | |
} | |
* | |
return $this->addRealSeconds(-1 * $value); | |
} | |
* | |
* | |
* | |
* | |
public static function isMicrosecondsFallbackEnabled() | |
/////////////////// ADDITIONS AND SUBTRACTIONS //////////////////// | |
* @property-read string $shortLocaleDayOfWeek the abbreviated day of week in current locale LC_TIME | |
{ | |
* @param int $value | |
$unit = $short ? 's' : 'second'; | |
* @param int $value | |
{ | |
public function isBirthday($date = null) | |
/** | |
* | |
// get the count days excluding weeks (might be zero) | |
* @param string $locale locale ex. en | |
* | |
* @param bool $absolute Get the absolute of the difference | |
* @return static | |
* | |
{ | |
* @return bool | |
'hour' => array(0, 24), | |
} | |
{ | |
public function toRfc822String() | |
return $this <= $date; | |
return $this->diffInSeconds($this->copy()->endOfDay()); | |
/** | |
{ | |
{ | |
public function isCurrentYear() | |
{ | |
public static function hasRelativeKeywords($time) | |
* @return bool | |
* Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59 | |
* @var bool | |
* @return static | |
{ | |
return call_user_func_array($macro->bindTo($this, get_class($this)), $parameters); | |
return $this->month === $this->nowWithSameTz()->addMonthNoOverflow()->month; | |
setlocale(LC_NUMERIC, 'C'); | |
* | |
'englishMonth' => 'F', | |
} | |
return $this->isSameAs($ofSameYear ? 'Y-m' : 'm', $date); | |
* | |
* @return string | |
* @param string $name | |
return $this->isStartOfDay(); | |
public function isMonday() | |
{ | |
} | |
const TWO_DAY_WORDS = 010; | |
public static function executeWithLocale($locale, $func) | |
return $this->addRealHours($value); | |
* @return static | |
return static::create(1, 1, 1, 0, 0, 0); | |
* Remove a month with no overflow from the instance | |
* | |
/** | |
* | |
$minute = $minute === null ? $defaults['minute'] : $minute; | |
public static function minValue() | |
public static function shouldOverflowMonths() | |
*/ | |
$locales = array(); | |
* Check if the instance is start of day / midnight. | |
/** | |
* Determines if the instance is less (before) than another | |
* @return static | |
} | |
* The errors that can occur. | |
/** | |
*/ | |
* If any of $year, $month or $day are set to null their now() values will | |
* @param int|null $day | |
* | |
public static function yesterday($tz = null) | |
* | |
use InvalidArgumentException; | |
* @param int|null $dayOfWeek day of the week default null | |
* | |
self::SATURDAY => 'Saturday', | |
* | |
* @return static | |
* | |
*/ | |
*/ | |
* @property-read string $localeMonth the month in current locale LC_TIME | |
* @return static | |
* @return bool | |
* Determines if the instance is greater (after) than or equal to another | |
/** | |
* | |
return $this->getOffset(); | |
return $this->isSameAs('md', $date); | |
* Determines if the instance is greater (after) than another | |
public static function createFromTimestamp($timestamp, $tz = null) | |
public function addHours($value) | |
* @return static | |
if (isset($locale)) { | |
* @return bool | |
public function diffFiltered(CarbonInterval $ci, Closure $callback, $date = null, $absolute = true) | |
* | |
* Resets the date to end of the quarter and time to 23:59:59 | |
* | |
public function lastOfMonth($dayOfWeek = null) | |
*/ | |
* | |
* | |
* @return static | |
public function addRealSecond($value = 1) | |
} | |
*/ | |
return $this->modify('23:59:59.999999'); | |
} | |
* @param int|null $second | |
* | |
/////////////////////// LOCALIZATION ////////////////////////////// | |
* @return bool | |
* | |
'dayOfWeek' => 'w', | |
* @param string|null $time | |
} | |
* Modify to start of current minute, seconds become 0 | |
* @return static | |
{ | |
* Remove quarters from the instance | |
{ | |
return $this->subSeconds($value); | |
*/ | |
}); | |
} | |
* Remove seconds from the instance. | |
} | |
* @return static | |
* Determines if the instance is within the next month. | |
* Format the instance as date | |
/** | |
{ | |
$format = $formats[$name]; | |
* | |
* Support is considered enabled if the 4 sentences are translated in the given locale. | |
/** | |
{ | |
* | |
*/ | |
{ | |
public function previous($dayOfWeek = null) | |
/** | |
/** | |
/** | |
* @return static | |
* | |
* Create a Carbon instance from just a time. The date portion is set to today. | |
$period = new DatePeriod($start, $ci, $end); | |
* @param int $minute | |
* | |
* | |
* Modify to end of current hour, minutes and seconds become 59 | |
$nonIgnored = preg_replace("/^.*{$nonEscaped}!/s", '', $format); | |
protected static $yearsOverflow = true; | |
{ | |
/** | |
* | |
{ | |
*/ | |
return $newLocale && | |
* Remove a second from the instance | |
public function nowWithSameTz() | |
* @see lt() | |
*/ | |
public function subRealHour($value = 1) | |
} | |
* @param int $value | |
return $this->addYearsNoOverflow($value); | |
return $this->modify((int) $value.' hour'); | |
} | |
} | |
{ | |
$translator = static::translator(); | |
* Get the Carbon instance (real or mock) to be returned when a "now" | |
* @param \DateTimeZone|string|null $tz | |
public function addDay($value = 1) | |
return $this->diffInDaysFiltered(function (Carbon $date) { | |
* | |
* | |
* @param \DateTimeZone|string|null $tz | |
* @return int | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
* @param bool $absolute Get the absolute of the difference | |
{ | |
{ | |
} | |
* @return $this | |
public function subWeek($value = 1) | |
public function farthest($date1, $date2) | |
// break the loop after we get the required number of parts in array | |
*/ | |
$translator->trans('diff_yesterday') !== 'diff_yesterday' && | |
$locales[] = substr($file, strrpos($file, '/') + 1, -4); | |
return $date1 != $date2; | |
*/ | |
/** | |
} | |
return $this->subWeekdays($value); | |
* @param int|null $month | |
* Set the translator instance to use | |
/** | |
const MONDAY = 1; | |
* A translator to ... er ... translate stuff. | |
} | |
* | |
{ | |
} | |
{ | |
* | |
return $this->setTime($this->hour, 0, 0); | |
'second' => array(0, 59), | |
* | |
* Create a Carbon instance for the greatest supported date. | |
// See: https://stackoverflow.com/q/14068594/2646927 | |
{ | |
/** | |
$date2 = new DateTime('2001-12-25T00:00:00Z'); | |
/** | |
public function isThursday() | |
* | |
* @return bool | |
const RFC7231_FORMAT = 'D, d M Y H:i:s \G\M\T'; | |
/** | |
/** | |
* | |
'j' => '([123][0-9]|[1-9])', | |
* Determines if the instance is less (before) or equal to another | |
return (int) ceil($this->day / static::DAYS_PER_WEEK); | |
$second = $second === null ? 0 : $second; | |
/** | |
{ | |
{ | |
$translator->trans('period_interval') !== 'period_interval' && | |
* Check if today is the last day of the Month | |
*/ | |
} | |
*/ | |
* @return static | |
} | |
*/ | |
} | |
public static function parse($time = null, $tz = null) | |
* | |
* @return static | |
case $name === 'weekOfMonth': | |
* to true by default. | |
public function minute($value) | |
} | |
{ | |
*/ | |
*/ | |
{ | |
* Modify to end of current minute, seconds become 59 | |
} | |
/** | |
* | |
* Add a quarter to the instance | |
* Initialize the translator instance if necessary. | |
*/ | |
* | |
return isset(static::$localMacros[$name]); | |
* | |
if ($isNow && $unit === 'day') { | |
{ | |
* @param int $value | |
} | |
* @return bool | |
*/ | |
* | |
{ | |
$nonEscaped = '(?<!\\\\)(\\\\{2})*'; | |
{ | |
*/ | |
/* | |
* | |
* @param \Carbon\Carbon|\DateTimeInterface $date | |
} | |
} | |
public function toRfc3339String() | |
} | |
} | |
* @return bool | |
* @return static | |
{ | |
* @param int|null $dayOfWeek | |
($y = $translator->trans('h')) !== 'h' && | |
* parameter of null. | |
{ | |
*/ | |
{ | |
'shortEnglishMonth' => 'M', | |
* Indicates if months should be calculated with overflow. | |
return $this->lte($date); | |
return $this->format(static::RFC3339); | |
* | |
* | |
public static function localeHasDiffTwoDayWords($locale) | |
* @param bool $absolute Get the absolute of the difference | |
* | |
'second' => $this->second, | |
* A test Carbon instance to be returned when now instances are created. | |
{ | |
/** | |
{ | |
*/ | |
public static function __callStatic($method, $parameters) | |
'dayOfWeekIso' => 'N', | |
* specifically under the following conditions: | |
} | |
return $this->modify((int) $value.' month'); | |
* | |
} | |
* @param int $value | |
{ | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
* of the current day of the week. Use the supplied constants | |
public static function __set_state($array) | |
* | |
/////////////////////////////////////////////////////////////////// | |
public function subMonthWithOverflow($value = 1) | |
* Remove days from the instance | |
return $this->isSameAs('Y-m-d', $date); | |
public function ne($date) | |
/** | |
* | |
return $this->diffFiltered(CarbonInterval::hour(), $callback, $date, $absolute); | |
*/ | |
* | |
return $this->month === $this->nowWithSameTz()->subMonthNoOverflow()->month; | |
public function isMidday() | |
} | |
{ | |
* | |
{ | |
} | |
* | |
public function endOfMonth() | |
public function diffInMinutes($date = null, $absolute = true) | |
} | |
return $this; | |
static::$serializer = $callback; | |
public function gte($date) | |
{ | |
} | |
if (count($interval) >= $parts) { | |
* | |
* | |
/////////////////////////////////////////////////////////////////// | |
* | |
* @return void | |
} | |
return static::create(null, null, null, $hour, $minute, $second, $tz); | |
return (int) ceil(($this->day + $this->copy()->startOfMonth()->dayOfWeek - 1) / static::DAYS_PER_WEEK); | |
*/ | |
return call_user_func_array(Closure::bind(static::$localMacros[$method], null, get_called_class()), $parameters); | |
{ | |
* @return bool | |
* | |
* | |
'micro' => $this->micro, | |
* Set the instance's hour | |
*/ | |
return $this->month(static::MONTHS_PER_YEAR)->lastOfMonth($dayOfWeek); | |
*/ | |
* | |
* @return bool | |
/** | |
public function subMonthsWithOverflow($value) | |
} | |
public static function enableHumanDiffOption($humanDiffOption) | |
* Remove a minute from the instance using timestamp. | |
* Throws an exception if the given object is not a DateTime and does not implement DateTimeInterface | |
/** | |
* Add hours to the instance. Positive $value travels forward while | |
} | |
* | |
* | |
return $this->weekOfYear === $this->nowWithSameTz()->subWeek()->weekOfYear; | |
* Set the time by time string | |
return $this->isSameDay(); | |
* | |
{ | |
* @return static | |
{ | |
* Add an hour to the instance using timestamp. | |
*/ | |
{ | |
{ | |
* Format the instance with day, date and time | |
); | |
default: | |
public function isLastYear() | |
/** | |
*/ | |
} | |
* Determines if the instance is equal to another | |
* @param \Carbon\Carbon|\DateTimeInterface $date | |
$this->modify((int) $value.' weekday'); | |
public function endOfMinute() | |
/** | |
public static function macro($name, $macro) | |
{ | |
case 'tz': | |
/** | |
* | |
if ($parts === 1) { | |
/** | |
public function isWeekday() | |
// just workaround on this bug | |
/** | |
} | |
*/ | |
public function subSecond($value = 1) | |
return $this->dayOfWeek === static::FRIDAY; | |
* to indicate the desired dayOfWeek, ex. static::MONDAY. | |
* | |
* | |
{ | |
* When comparing a value in the past to default now: | |
return (int) $this->diff($this->resolveCarbon($date), $absolute)->format('%r%a'); | |
* | |
* Indicates if years should be calculated with overflow. | |
if ($hour === null) { | |
} catch (InvalidArgumentException $e) { | |
* @param int|null $dayOfWeek | |
} | |
'U' => '([0-9]*)', | |
return $this->subMonthsNoOverflow($value * static::MONTHS_PER_YEAR); | |
/** | |
* | |
/** | |
$format = static::MOCK_DATETIME_FORMAT.' '.$format; | |
} while ($weekday ? $this->isWeekend() : $this->isWeekday()); | |
} | |
* @return static | |
{ | |
{ | |
* | |
{ | |
} | |
* @throws InvalidArgumentException | |
*/ | |
/** | |
{ | |
* Checks if this day is a Wednesday. | |
{ | |
* @property-read bool $dst daylight savings time indicator, true if DST, false otherwise | |
* | |
} | |
$time = $mock->format(static::MOCK_DATETIME_FORMAT).' '.$time; | |
* | |
{ | |
/** | |
/** | |
} | |
* | |
} | |
/** | |
public function addMonthWithOverflow($value = 1) | |
'z' => '(36[0-5]|3[0-5][0-9]|[12][0-9]{2}|[1-9]?[0-9])', | |
static::setToStringFormat(static::DEFAULT_TO_STRING_FORMAT); | |
* @see max() | |
return is_numeric($value) ? (int) $value : $value; | |
* @return bool | |
* | |
static::expectDateTime($date, array('null', 'string')); | |
* | |
} | |
do { | |
'englishDayOfWeek' => 'l', | |
* Create a Carbon instance for tomorrow. | |
* | |
* | |
* @param int $value | |
public static function compareYearWithMonth($compareYearWithMonth = true) | |
* | |
'G' => '(2[0-3]|1?[0-9])', | |
* @param string $time | |
/////////////////////////// DIFFERENCES /////////////////////////// | |
*/ | |
* @param string $format Datetime format | |
* @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day. | |
* @param \DateTimeZone|string|null $tz | |
return $this->diffFiltered(CarbonInterval::day(), $callback, $date, $absolute); | |
throw new \BadMethodCallException("Method $method does not exist."); | |
return static::$lastErrors; | |
array('value' => $diffInterval->y, 'unit' => 'year', 'unitShort' => 'y'), | |
$instance::setLastErrors($lastErrors); | |
return false; | |
/** | |
} | |
* Remove a month from the instance | |
* @return static | |
if ($end < $start) { | |
* @return string | |
* Get the first day of week | |
public function toRfc1123String() | |
* @param array $parameters | |
public function addYearsWithOverflow($value) | |
$date2->modify($time); | |
/** | |
* @return static | |
*/ | |
/** | |
* @return string | |
* @return bool | |
const JUST_NOW = 02; | |
* Determines if the instance is equal to another | |
return $time; | |
'dayOfYear' => $this->dayOfYear, | |
* @property-read int $dayOfYear 0 through 365 | |
return $this; | |
} | |
foreach ($diffIntervalArray as $diffIntervalData) { | |
*/ | |
public function subMonths($value) | |
* | |
public function notEqualTo($date) | |
foreach (array_reverse($fields) as $field => $range) { | |
* | |
return $this->setTimeFromTimeString($t); | |
/** | |
* | |
return $this->isSameAs('Y-m-d H:i:s', $date); | |
* Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. | |
* Determines if the instance is in the current second. | |
return static::parse('today', $tz); | |
break; | |
public function addYearWithOverflow($value = 1) | |
return !$this->isWeekend(); | |
$actualCount = count($parameters); | |
} | |
public static function fromSerialized($value) | |
* @return static | |
$time = $testInstance->format(static::MOCK_DATETIME_FORMAT); | |
{ | |
*/ | |
*/ | |
public function isToday() | |
*/ | |
return $this->addMonthsNoOverflow($value); | |
{ | |
public static function setUtf8($utf8) | |
{ | |
* @return bool | |
/** | |
public function isCurrentHour() | |
} | |
* Prepare the object for JSON serialization. | |
} | |
/** | |
{ | |
* This is an alias for the constructor that allows better fluent syntax | |
$translator->trans('diff_after_tomorrow') !== 'diff_after_tomorrow'; | |
* | |
if (!$date instanceof DateTime && !$date instanceof DateTimeInterface) { | |
*/ | |
static::createFromFormat($format, $date); | |
} | |
public function max($date = null) | |
/** | |
* @property-read int $micro | |
* | |
* | |
* has no affect as the mock value will be returned regardless of its value. | |
/** | |
} | |
return $this->isSameMinute(); | |
$translator->trans('before') !== 'before' && | |
* | |
/** | |
throw new InvalidArgumentException( | |
public function subMonthNoOverflow($value = 1) | |
return $this->modify("$this->hour:$this->minute:$this->second.0"); | |
return $this->copy()->setTimezone('UTC')->format('Y-m-d\TH:i:s\Z'); | |
* Returns true if the given locale is internally supported and has short-units support. | |
} | |
{ | |
* @param string $method | |
* @return static | |
{ | |
* | |
$hour = $defaults['hour']; | |
{ | |
*/ | |
public function secondsSinceMidnight() | |
public function average($date = null) | |
if (count($interval) === 0) { | |
} | |
* @param int $month | |
/** | |
* @return static | |
* Format the instance as RFC1123 | |
$time = implode(' ', $interval); | |
* @return static | |
{ | |
* @param int|null $year | |
* Determine if there is a valid test instance set. A valid test instance | |
const SECONDS_PER_MINUTE = 60; | |
* @param int $value | |
* @param bool $absolute removes time difference modifiers ago, after, etc | |
* | |
{ | |
public function addMonthsWithOverflow($value) | |
public function closest($date1, $date2) | |
$translation = static::translator()->trans($key); | |
if ($tz !== null && $tz !== static::getTestNow()->getTimezone()) { | |
/** | |
} | |
* @see min() | |
* @throws \InvalidArgumentException | |
* @return bool | |
} | |
* | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
* @param int|null $year | |
return $this->modify('first '.static::$days[$dayOfWeek].' of '.$this->format('F').' '.$this->year); | |
* | |
*/ | |
* @param string $name | |
* Number of X in Y. | |
{ | |
public function subRealMinute($value = 1) | |
*/ | |
* | |
* | |
* @param int $timestamp | |
} | |
* first day of the current year. Use the supplied constants | |
* | |
return $this->dayOfWeek === static::THURSDAY; | |
* | |
// 64 bit | |
///////////////////////// GETTERS AND SETTERS ///////////////////// | |
public static function resetMonthsOverflow() | |
* If no dayOfWeek is provided, modify to the previous occurrence | |
* | |
{ | |
/////////////////////////////////////////////////////////////////// | |
} | |
*/ | |
*/ | |
* Determines if the instance is today. | |
'g' => '(1[012]|[1-9])', | |
static::$weekendDays = $days; | |
return $this->setDate($this->year, $this->month, 1)->startOfDay(); | |
* | |
{ | |
$date1 = $date2; | |
$tzName = timezone_name_from_abbr(null, $object * 3600, true); | |
* | |
* Format the instance as date and time | |
* | |
* Add days to the instance. Positive $value travels forward while | |
return true; | |
/** | |
'u' => '([0-9]{1,6})', | |
$date = $this->resolveCarbon($date); | |
} | |
* Format the instance as RFC2822 | |
*/ | |
public static function getHumanDiffOptions() | |
* @return static | |
* | |
*/ | |
/////////////////////////////////////////////////////////////////// | |
'Z' => '(-?[1-5]?[0-9]{1,4})', | |
* @param int $value | |
* Get the difference in minutes. | |
return $this > $date; | |
protected static $weekendDays = array( | |
* | |
try { | |
* | |
* Remove months with no overflow from the instance | |
// Check for Windows to find and replace the %e modifier correctly. | |
* If one of the set values is not valid, an \InvalidArgumentException | |
public function midDay() | |
* last day of the current month. Use the supplied constants | |
{ | |
* | |
static::$toStringFormat = $format; | |
? parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz)) | |
*/ | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 | |
/** | |
* Create a Carbon instance from an UTC timestamp. | |
public function addHour($value = 1) | |
* @return static | |
return static::parse('tomorrow', $tz); | |
* JSON serialize all Carbon instances using the given callback. | |
: parent::createFromFormat($format, $time); | |
* Determines if the instance is between two others | |
/////////////////////// WEEK SPECIAL DAYS ///////////////////////// | |
* | |
//////////////////////////// MODIFIERS //////////////////////////// | |
// @codeCoverageIgnoreStart | |
public function endOfDecade() | |
* (It will ignore custom translator dynamic loading.) | |
/** | |
} else { | |
} | |
* | |
/** | |
return serialize($this); | |
* Support is considered enabled if the 3 words are translated in the given locale. | |
$macro = static::$localMacros[$method]; | |
* @return static | |
} | |
if ($day !== $this->day) { | |
if ($numOfDaysCount > 0 && count($interval) < $parts) { | |
'P' => '([\+\-](1[012]|0[0-9]):[0134][05])', | |
if (!static::hasMacro($method)) { | |
* | |
if ($tz !== false) { | |
return $this->format('D, M j, Y g:i A'); | |
* Modify to start of current minute, seconds become 0 | |
} | |
* | |
return $this->isSameAs('Y-m-d H', $date); | |
* | |
public function isSameYear($date = null) | |
*/ | |
* Will UTF8 encoding be used to print localized date/time ? | |
* Format the instance as ATOM | |
/** | |
*/ | |
* | |
public function diffInRealSeconds($date = null, $absolute = true) | |
/** | |
return $this->dayOfWeek === static::SUNDAY; | |
*/ | |
* | |
*/ | |
* @var array | |
{ | |
/** | |
if (static::$serializer) { | |
/** | |
* Add a minute to the instance using timestamp. | |
$fixYear = $year; | |
return $this->format(static::RSS); | |
{ | |
return $this; | |
{ | |
$this->modify((int) $value.' month'); | |
* @return static | |
public function addQuarter($value = 1) | |
* @property-read string $tzName | |
$reflection = new \ReflectionClass($mixin); | |
*/ | |
/** | |
* RFC7231 DateTime format. | |
* @return bool | |
return $this->addHours(-1 * $value); | |
'month', | |
} | |
public function month($value) | |
{ | |
return $this; | |
* @return array | |
{ | |
* Days of weekend. | |
const SUNDAY = 0; | |
* in the current quarter. If no dayOfWeek is provided, modify to the | |
* | |
/** | |
* Indicates if years are compared with month by default so isSameMonth and isSameQuarter have $ofSameYear set | |
$month = $month === null ? $defaults['month'] : $month; | |
* to indicate the desired dayOfWeek, ex. static::MONDAY. | |
* | |
* Checks if this day is a Friday. | |
* @return bool true if there is a test instance, otherwise false | |
} | |
* | |
} elseif ($year > 9999) { | |
return $this->addHours($value); | |
* @var bool | |
/** | |
static::$weekEndsAt = $day; | |
* @return static | |
* @param int $value | |
* | |
{ | |
* Reset the month overflow behavior. | |
* | |
return $this->modify("$this->hour:$this->minute:$this->second.999999"); | |
return static::translator()->getLocale(); | |
protected static $humanDiffOptions = self::NO_ZERO_DIFF; | |
/** | |
*/ | |
public function subQuarters($value) | |
public function addRealHour($value = 1) | |
* @return static | |
return call_user_func_array(static::$localMacros[$method], $parameters); | |
* @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date. | |
* @param object|callable $macro | |
*/ | |
/** | |
/** | |
* | |
/** | |
/** | |
{ | |
static::$yearsOverflow = $yearsOverflow; | |
$this->day = $value; | |
* Modify to the next occurrence of a given day of the week. | |
public function isTomorrow() | |
* | |
} | |
'a' => '(am|pm)', | |
{ | |
$year = 0; | |
* | |
* Sets the current date of the DateTime object to a different date. | |
} | |
} | |
{ | |
* Compares the formatted values of the two dates. | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 | |
* | |
{ | |
return $this->addMonths($value); | |
* @param int $value | |
* Get the difference by the given interval using a filter closure | |
{ | |
return $this->getOffset() === 0; | |
* | |
} | |
* Add a minute to the instance. | |
* @return bool | |
* @return bool | |
*/ | |
/////////////////////////////////////////////////////////////////// | |
return $this->nextOrPreviousDay(); | |
public function addRealMinutes($value) | |
case $name === 'local': | |
static::$testNow = is_string($testNow) ? static::parse($testNow) : $testNow; | |
* @return static | |
* Determines if the instance is yesterday. | |
{ | |
* | |
} | |
/** | |
* Add an hour to the instance. | |
} | |
*/ | |
* @return static | |
public static function localeHasDiffOneDayWords($locale) | |
* as it allows you to do Carbon::parse('Monday next week')->fn() rather | |
/** | |
public function nthOfMonth($nth, $dayOfWeek) | |
* This file is part of the Carbon package. | |
* @param int $value | |
* @return bool | |
} | |
} | |
'B' => '([0-9]{3})', | |
* | |
if (!$instance instanceof static) { | |
$year = $this->year - 1 - ($this->year - 1) % static::YEARS_PER_CENTURY + static::YEARS_PER_CENTURY; | |
return $this->diffInSeconds($date1) < $this->diffInSeconds($date2) ? $date1 : $date2; | |
* Remove a month from the instance | |
/** | |
* | |
*/ | |
* | |
return $translation; | |
* Set the year, month, and date for this instance to that of the passed instance. | |
$parameters[] = $reflectionParameters[$i]->getDefaultValue(); | |
} | |
->setTimezone('GMT') | |
* | |
'hour' => 'G', | |
{ | |
*/ | |
{ | |
{ | |
/** | |
* @return bool | |
* | |
* @return static | |
{ | |
return false; | |
* | |
public function addYearsNoOverflow($value) | |
} | |
* and not in $other. | |
'M' => '([a-zA-Z]{3})', | |
return static::create($year, $month, $day, null, null, null, $tz); | |
public function addWeekday($value = 1) | |
* | |
return ($lastMonth < $date->month || $year !== $date->year) ? false : $this->modify($date); | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
{ | |
* | |
if ($translator instanceof Translator) { | |
* @return static | |
$this->modify('+0 day'); | |
} | |
protected static $weekEndsAt = self::SUNDAY; | |
return $this->getTimezone(); | |
*/ | |
* | |
{ | |
*/ | |
{ | |
'hour', | |
* | |
public static function now($tz = null) | |
{ | |
use DatePeriod; | |
if ($date instanceof DateTime || $date instanceof DateTimeInterface) { | |
$testInstance->setTimezone($tz); | |
{ | |
/** | |
public function isTuesday() | |
* @param string $locale locale ex. en | |
return static::$days; | |
*/ | |
/** | |
*/ | |
*/ | |
} | |
* Get the minimum instance between a given instance (default now) and the current instance. | |
$format = static::$toStringFormat; | |
* | |
* Remove seconds from the instance using timestamp. | |
/** | |
/** | |
*/ | |
public function tz($value) | |
* @return static | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
$count = $numOfDaysCount; | |
* Set the date and time all together | |
* | |
/** | |
/** | |
* Remove years from the instance. | |
/** | |
* Check if an attribute exists on the object | |
} | |
//////////////////////////// CONSTRUCTORS ///////////////////////// | |
*/ | |
*/ | |
* @return string | |
{ | |
{ | |
) | |
} | |
$translation = static::translator()->trans($key); | |
{ | |
*/ | |
* Remove weekdays from the instance | |
* | |
* | |
* Format the instance as COOKIE | |
* Set a part of the Carbon object | |
* Get the difference in days using a filter closure | |
return call_user_func_array($macro, $parameters); | |
/** | |
* @return static | |
{ | |
'micro' => 'u', | |
{ | |
* | |
* Checks if this day is a Tuesday. | |
$$name = $value; | |
} | |
/** | |
protected static $lastErrors; | |
*/ | |
{ | |
(is_object($date) ? get_class($date) : gettype($date)).' given' | |
* Remove months from the instance | |
{ | |
$unit = $short ? 's' : 'second'; | |
* If $hour is null it will be set to its now() value and the default | |
*/ | |
public function endOfYear() | |
if (strpos($time, ':') === false) { | |
* @param \DateTimeZone|string|null $tz | |
*/ | |
* | |
* | |
protected static $utf8 = false; | |
*/ | |
* @return $this | |
$method->setAccessible(true); | |
*/ | |
$year = $this->year - ($this->year - 1) % static::YEARS_PER_CENTURY; | |
} | |
* @return int | |
protected static $compareYearWithMonth = false; | |
/** | |
private function nextOrPreviousDay($weekday = true, $forward = true) | |
{ | |
$date = $this->copy()->day(1)->month($this->quarter * static::MONTHS_PER_QUARTER); | |
* @param int $value | |
*/ | |
return $this == $date; | |
* @return bool | |
/** | |
/** | |
static::expectDateTime($date, 'null'); | |
version_compare(PHP_VERSION, '7.1.0-dev', '<') | |
* | |
public static function useYearsOverflow($yearsOverflow = true) | |
{ | |
/** | |
/** | |
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now') | |
*/ | |
{ | |
* Format for converting mocked time, includes microseconds. | |
* @return bool | |
* @param \Symfony\Component\Translation\TranslatorInterface $translator | |
* @param int $value | |
} | |
{ | |
return static::$compareYearWithMonth; | |
* | |
* @param int $value | |
* If any of $year, $month or $day are set to null their now() values will | |
$locales = array_unique(array_merge($locales, array_keys($translator->getMessages()))); | |
} | |
if ($tz === null && !preg_match("/{$nonEscaped}[eOPT]/", $nonIgnored)) { | |
*/ | |
* Set the default format used when type juggling a Carbon instance to a string | |
return static::instance(parent::__set_state($array)); | |
/** | |
/////////////////////////////// MACRO ///////////////////////////// | |
public function diffAsCarbonInterval($date = null, $absolute = true) | |
{ | |
* | |
* Remove weeks to the instance | |
* @return bool | |
* @return static | |
return $this->addRealSeconds($value * static::SECONDS_PER_MINUTE); | |
array('value' => $diffInterval->m, 'unit' => 'month', 'unitShort' => 'm'), | |
* Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X). | |
* Add seconds to the instance. Positive $value travels forward while | |
* @return bool | |
* @return void | |
{ | |
*/ | |
*/ | |
return $newLocale && | |
* @return static | |
public function setTimeFromTimeString($time) | |
* @return bool | |
public function subRealHours($value) | |
} | |
/** | |
switch (true) { | |
* @return bool | |
*/ | |
*/ | |
} | |
{ | |
{ | |
* Determines if the instance is in the future, ie. greater (after) than now. | |
* @return static | |
{ | |
* | |
$count = static::getHumanDiffOptions() & self::NO_ZERO_DIFF ? 1 : 0; | |
$translator->trans('from_now') !== 'from_now' && | |
/** | |
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) { | |
*/ | |
const WEEKS_PER_YEAR = 52; | |
* @return string | |
// Fix for weekday bug https://bugs.php.net/bug.php?id=54909 | |
public static function getTestNow() | |
{ | |
*/ | |
* | |
$y !== $translator->trans('year') | |
if (is_string($date)) { | |
* | |
} | |
* Format the instance as time | |
* Return the Carbon instance passed through, a now instance in the same timezone | |
\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED | |
? $this->format('H:i:s.u') === '23:59:59.999999' | |
} | |
* | |
* | |
* @var int | |
$dayOfWeek = $this->dayOfWeek; | |
* | |
} | |
* @return \DateTimeZone | |
* | |
* @return static | |
return $this->weekOfYear === $this->nowWithSameTz()->addWeek()->weekOfYear; | |
*/ | |
return $this->format(static::RFC1036); | |
// Work-around for PHP bug https://bugs.php.net/bug.php?id=67127 | |
protected static $monthsOverflow = true; | |
*/ | |
* | |
* @param int $second | |
} | |
/** | |
public function subYears($value) | |
* | |
$parts = min(6, max(1, (int) $parts)); | |
{ | |
return call_user_func($callback, Carbon::instance($date)); | |
$date1->modify($time); | |
/** | |
} | |
/** | |
{ | |
* @param int $value | |
} | |
$count = $diffIntervalData['value']; | |
* | |
* Resets the date to the first day of the year and the time to 00:00:00 | |
} | |
* @return int | |
return $absolute ? abs($value) : $value; | |
* | |
* | |
/** | |
* | |
return static::$microsecondsFallback; | |
* @property \DateTimeZone $timezone the current timezone | |
{ | |
self::SUNDAY, | |
* Determines if the instance is a leap year. | |
* | |
} | |
return $this->addMonthsWithOverflow($value); | |
$translator->trans('diff_now') !== 'diff_now' && | |
} | |
* @param bool $absolute Get the absolute of the difference | |
{ | |
{ | |
{ | |
* Create a Carbon instance from a DateTime one. | |
*/ | |
public function toDateString() | |
$unit = $short ? 'd' : 'day'; | |
*/ | |
} | |
$var = trim($var); | |
$this->setTime($date->hour, $date->minute, $date->second); | |
protected static function expectDateTime($date, $other = array()) | |
/** | |
* | |
return static::translator()->setLocale($locale) !== false; | |
return $newLocale && | |
$interval[] = static::translator()->transChoice($unit, $count, array(':count' => $count)); | |
'timestamp' => 'U', | |
*/ | |
/** | |
return clone $date; | |
list($year, $month, $day, $hour, $minute, $second) = explode('-', $this->format('Y-n-j-G-i-s')); | |
$this->setDate($date->year, $date->month, $date->day); | |
* Determine if a time string will produce a relative date. | |
* | |
* Make a Carbon instance from given variable if possible. | |
* @return void | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
} | |
* | |
* @return string | |
'l' => '([a-zA-Z]{2,})', | |
} | |
* @return array | |
* | |
* @return string | |
{ | |
{ | |
{ | |
case $name === 'offset': | |
/** | |
/** | |
*/ | |
const HOURS_PER_DAY = 24; | |
$values = array_filter(iterator_to_array($period), function ($date) use ($callback) { | |
* | |
$date = static::instance($date); | |
* | |
* | |
* in the current quarter. If the calculated occurrence is outside the scope | |
} | |
* Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00 | |
{ | |
return $newLocale && | |
* | |
public function year($value) | |
public static function setLocale($locale) | |
*/ | |
* Go backward to the previous weekend day. | |
{ | |
* | |
public function between($date1, $date2, $equal = true) | |
} | |
{ | |
{ | |
* @return int | |
/** | |
return static::$midDayAt; | |
* | |
/** | |
return $translation; | |
const YEARS_PER_DECADE = 10; | |
{ | |
* | |
* The registered string macros. | |
public function subYearsWithOverflow($value) | |
/** | |
* @param int $nth | |
public function greaterThanOrEqualTo($date) | |
*/ | |
* Format the instance as RFC1036 | |
* | |
public function subYearWithOverflow($value = 1) | |
} catch (InvalidArgumentException $e) { | |
* @return static | |
* @return static | |
} | |
/** | |
*/ | |
*/ | |
static::$humanDiffOptions = $humanDiffOptions; | |
* @var int | |
* @return static | |
use JsonSerializable; | |
public function firstOfYear($dayOfWeek = null) | |
* | |
return $this->startOfDay()->modify('last '.static::$days[$dayOfWeek]); | |
* negative $value travels into the past. | |
} | |
* Add year with overflow months set to false | |
* Get the last day of week | |
if ($dayOfWeek === null) { | |
$message = 'Expected '; | |
} | |
$end = $this; | |
/** | |
// 32 bit | |
* | |
* 1 hour ago | |
* | |
* | |
static::expectDateTime($date, 'null'); | |
* | |
return static::create($year, $month, $day, 0, 0, 0, $tz); | |
case 'timestamp': | |
if ($dayOfWeek === null) { | |
* | |
*/ | |
return $tz; | |
* @param int|null $month | |
* Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow). | |
} | |
* | |
* @param int $nth | |
public static function setWeekendDays($days) | |
* @return static | |
} | |
* @param string $time | |
} | |
public function isCurrentQuarter() | |
*/ | |
* @param int $hour | |
* @param int $value | |
* @return static | |
* Remove centuries from the instance | |
* @param int $value | |
use Closure; | |
} | |
$interval[] = static::translator()->transChoice($unit, $count, array(':count' => $count)); | |
* | |
public static function hasFormat($date, $format) | |
* @param \DateTimeZone|string|null $tz | |
return $this->addRealHours(-1 * $value); | |
* file that was distributed with this source code. | |
* @throws \Carbon\Exceptions\InvalidDateException|\InvalidArgumentException | |
'r' => '(([a-zA-Z]{3}), ([123][0-9]|[1-9]) ([a-zA-Z]{3}) ([1-9][0-9]{0,4}) (2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9]) [\+\-](1[012]|0[0-9])([0134][05]))', // D, j M Y H:i:s O | |
public function isStartOfDay($checkMicroseconds = false) | |
{ | |
*/ | |
* | |
'W' => '(5[012]|[1-4][0-9]|[1-9])', | |
public function subDays($value) | |
return $this; | |
* negative $value travels into the past. | |
* Get a copy of the instance. | |
$day = $day === null ? $defaults['day'] : $day; | |
} | |
/** | |
public function lessThanOrEqualTo($date) | |
* | |
static $formats = array( | |
case 'month': | |
{ | |
* @return static | |
* | |
*/ | |
* | |
* | |
return $this->format($format instanceof Closure ? $format($this) : $format); | |
public function __isset($name) | |
* @return static | |
* @param int $value | |
while ($this->dayOfWeek !== static::$weekEndsAt) { | |
* | |
$other = $this->nowWithSameTz(); | |
*/ | |
* | |
{ | |
* | |
* | |
* Determines if the instance is tomorrow. | |
} | |
$date = $this->copy()->firstOfMonth(); | |
* | |
public function toW3cString() | |
* | |
*/ | |
// Work-around for a bug fixed in PHP 5.5.10 https://bugs.php.net/bug.php?id=45528 | |
public function diffInHours($date = null, $absolute = true) | |
} | |
{ | |
{ | |
} | |
* @param string $name | |
$this->minute = $value; | |
break; | |
static::$monthsOverflow = true; | |
public static function setToStringFormat($format) | |
return $this->format('I') === '1'; | |
public function addMonth($value = 1) | |
} | |
} | |
*/ | |
$date = self::createFromFormatAndTimezone($format, $time, $tz); | |
*/ | |
* | |
* | |
* | |
public function diffInSeconds($date = null, $absolute = true) | |
* @param int $dayOfWeek | |
case 'year': | |
public function subQuarter($value = 1) | |
/** | |
/** | |
{ | |
} | |
} | |
*/ | |
* | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
*/ | |
/** | |
use Symfony\Component\Translation\TranslatorInterface; | |
} | |
{ | |
* @param int|null $second | |
* | |
* | |
} | |
* Add a month to the instance | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* | |
} | |
} | |
} | |
*/ | |
* | |
* | |
{ | |
* | |
return static::today($tz)->setTimestamp($timestamp); | |
*/ | |
* | |
} | |
* Add a month to the instance | |
} | |
* @param mixed $date | |
* @return static | |
* | |
*/ | |
* Resets the time to 23:59:59 end of day | |
/** | |
* @return int | |
* | |
} | |
public function subWeeks($value) | |
array('value' => $diffInterval->h, 'unit' => 'hour', 'unitShort' => 'h'), | |
{ | |
} | |
protected static $days = array( | |
*/ | |
* | |
public function nthOfYear($nth, $dayOfWeek) | |
*/ | |
* | |
* | |
public function endOfHour() | |
return static::getTestNow() !== null; | |
{ | |
{ | |
* | |
*/ | |
* @return bool | |
* | |
*/ | |
* is anything that is not null. | |
* @throws InvalidArgumentException | |
public static function setTranslator(TranslatorInterface $translator) | |
$this->second = $value; | |
if (static::hasRelativeKeywords($time)) { | |
{ | |
public function isSaturday() | |
* | |
*/ | |
$currentLocale = static::getLocale(); | |
* | |
return $this->setDate($this->year, $this->quarter * static::MONTHS_PER_QUARTER, 1)->lastOfMonth($dayOfWeek); | |
* @return void | |
{ | |
*/ | |
* @property-read string $timezoneName | |
} | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
} | |
* | |
} | |
* Indicates if months should be calculated with overflow. | |
} | |
$dateTime = new DateTime('now', $timezone); | |
{ | |
/** | |
* | |
return $checkMicroseconds | |
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date | |
/** | |
*/ | |
* | |
} | |
{ | |
* @return \Symfony\Component\Translation\TranslatorInterface | |
{ | |
* | |
* | |
return new DateTimeZone(date_default_timezone_get()); | |
return $this->setTimezone($value); | |
return $this->diffInYears($date, $absolute) * static::MONTHS_PER_YEAR + (int) $this->diff($date, $absolute)->format('%r%m'); | |
* travels forward while negative $value travels into the past. | |
* @see lte() | |
} | |
} | |
* @return mixed | |
return $this->subWeeks($value); | |
) || ( | |
* Modify to the last occurrence of a given day of the week | |
} | |
* @param int $value | |
* @return static | |
} | |
} | |
/** | |
* @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date. | |
*/ | |
setlocale(LC_NUMERIC, $locale); | |
{ | |
* @return static | |
/** | |
* Modify the current instance to the average of a given instance (default now) and the current instance. | |
? $this->format('H:i:s.u') === '00:00:00.000000' | |
} | |
* | |
} | |
/** | |
$first = substr($var, 0, 1); | |
* | |
* | |
* @param int $value | |
{ | |
} | |
* | |
} | |
* Modify to the first occurrence of a given day of the week | |
} | |
if ($dayOfWeek === null) { | |
{ | |
/** | |
* | |
* of the current year, then return false and no modifications are made. | |
protected static function safeCreateDateTimeZone($object) | |
* @return static | |
/** | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date | |
case 'hour': | |
} | |
*/ | |
{ | |
*/ | |
* @param bool $absolute Get the absolute of the difference | |
/** | |
* @param int|null $day | |
public function startOfMonth() | |
return $this->min($date); | |
public function minimum($date = null) | |
'D' => '([a-zA-Z]{3})', | |
*/ | |
* | |
{ | |
* | |
*/ | |
return $date->format('Y-m') === $check ? $this->modify($date) : false; | |
} | |
/** | |
public function lastOfQuarter($dayOfWeek = null) | |
* | |
* | |
* | |
'day' => $this->day, | |
*/ | |
*/ | |
* Checks if the passed in date is in the same year as the instance year. | |
// @codeCoverageIgnoreEnd | |
* Support is considered enabled if the 2 words are translated in the given locale. | |
* The number of seconds since midnight. | |
* @return static | |
return $this->year === $date->year ? $this->modify($date) : false; | |
/** | |
'month' => 'n', | |
} | |
* values for $minute and $second will be their now() values. | |
$methods = $reflection->getMethods( | |
* | |
/** | |
self::WEDNESDAY => 'Wednesday', | |
'minute' => 'i', | |
} | |
/** | |
* | |
* Format the instance as RFC3339 | |
*/ | |
/** | |
* @param int $value | |
* Get the difference in weekdays | |
*/ | |
public function diffInRealMinutes($date = null, $absolute = true) | |
* @return bool | |
/** | |
const NO_ZERO_DIFF = 01; | |
* | |
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) { | |
* @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day. | |
* in the current month. If no dayOfWeek is provided, modify to the | |
} | |
* | |
* | |
/** | |
* @return bool | |
* | |
'month' => $this->month, | |
* @param \DateTimeZone|string $value | |
parent::setTimezone(static::safeCreateDateTimeZone($value)); | |
*/ | |
* @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 | |
* @return bool | |
* @return static | |
/** | |
* @property-read int $offsetHours the timezone offset in hours from UTC | |
return static::createFromFormat('U.u', sprintf('%F', $timestamp / 1000)) | |
); | |
} | |
{ | |
public function lessThan($date) | |
/** | |
/** | |
*/ | |
* @return bool | |
return $this->subMonthsWithOverflow($value); | |
return $this->setDate($this->year, $month, 1)->startOfDay(); | |
$date = static::instance($date); | |
* | |
{ | |
* @return string | |
* @param int $value | |
*/ | |
* | |
return $this->isSameHour(); | |
't' => '(2[89]|3[01])', |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment