_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q13800
Date.getIsoFormats
train
public function getIsoFormats($locale = null) { return [ 'LT' => $this->getTranslationMessage('formats.LT', $locale, 'h:mm A'), 'LTS' => $this->getTranslationMessage('formats.LTS', $locale, 'h:mm:ss A'), 'L' => $this->getTranslationMessage('formats.L', $locale, 'MM/DD/YYY...
php
{ "resource": "" }
q13801
Date.getCalendarFormats
train
public function getCalendarFormats($locale = null) { return [ 'sameDay' => $this->getTranslationMessage('calendar.sameDay', $locale, '[Today at] LT'), 'nextDay' => $this->getTranslationMessage('calendar.nextDay', $locale, '[Tomorrow at] LT'), 'nextWeek' => $this->getTrans...
php
{ "resource": "" }
q13802
Date.getPaddedUnit
train
public function getPaddedUnit($unit, $length = 2, $padString = '0', $padType = STR_PAD_LEFT) { return ($this->$unit < 0 ? '-' : '').str_pad(abs($this->$unit), $length, $padString, $padType); }
php
{ "resource": "" }
q13803
Date.ordinal
train
public function ordinal(string $key, string $period = null): string { $number = $this->$key; $result = $this->translate('ordinal', [ ':number' => $number, ':period' => $period, ]); return strval($result === 'ordinal' ? $number : $result); }
php
{ "resource": "" }
q13804
Date.meridiem
train
public function meridiem(bool $isLower = false): string { $hour = $this->hour; $index = $hour < 12 ? 0 : 1; if ($isLower) { $key = 'meridiem.'.($index + 2); $result = $this->translate($key); if ($result !== $key) { return $result; ...
php
{ "resource": "" }
q13805
Date.getAltNumber
train
public function getAltNumber(string $key): string { $number = strlen($key) > 1 ? $this->$key : $this->rawFormat('h'); $translateKey = "alt_numbers.$number"; $symbol = $this->translate($translateKey); if ($symbol !== $translateKey) { return $symbol; } if ...
php
{ "resource": "" }
q13806
Date.setUnit
train
public function setUnit($unit, $value = null) { $unit = static::singularUnit($unit); $dateUnits = ['year', 'month', 'day']; if (in_array($unit, $dateUnits)) { return $this->setDate(...array_map(function ($name) use ($unit, $value) { return $name === $unit ? $value...
php
{ "resource": "" }
q13807
Localization.setFallbackLocale
train
public static function setFallbackLocale($locale) { $translator = static::getTranslator(); if (method_exists($translator, 'setFallbackLocales')) { $translator->setFallbackLocales([$locale]); if ($translator instanceof Translator) { $preferredLocale = $transl...
php
{ "resource": "" }
q13808
Localization.localeHasShortUnits
train
public static function localeHasShortUnits($locale) { return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) { return $newLocale && ( ($y = static::translateWith($translator, 'y')) !== 'y' && $y !==...
php
{ "resource": "" }
q13809
Localization.getAvailableLocalesInfo
train
public static function getAvailableLocalesInfo() { $languages = []; foreach (static::getAvailableLocales() as $id) { $languages[$id] = new Language($id); } return $languages; }
php
{ "resource": "" }
q13810
Creator.createFromDate
train
public static function createFromDate($year = null, $month = null, $day = null, $tz = null) { return static::create($year, $month, $day, null, null, null, $tz); }
php
{ "resource": "" }
q13811
Creator.createMidnightDate
train
public static function createMidnightDate($year = null, $month = null, $day = null, $tz = null) { return static::create($year, $month, $day, 0, 0, 0, $tz); }
php
{ "resource": "" }
q13812
Creator.createFromLocaleFormat
train
public static function createFromLocaleFormat($format, $locale, $time, $tz = null) { return static::rawCreateFromFormat($format, static::translateTimeString($time, $locale, 'en'), $tz); }
php
{ "resource": "" }
q13813
Creator.createFromLocaleIsoFormat
train
public static function createFromLocaleIsoFormat($format, $locale, $time, $tz = null) { $time = static::translateTimeString($time, $locale, 'en', CarbonInterface::TRANSLATE_MONTHS | CarbonInterface::TRANSLATE_DAYS | CarbonInterface::TRANSLATE_MERIDIEM); return static::createFromIsoFormat($format, $...
php
{ "resource": "" }
q13814
Creator.make
train
public static function make($var) { if ($var instanceof DateTimeInterface) { return static::instance($var); } $date = null; if (is_string($var)) { $var = trim($var); $first = substr($var, 0, 1); if (is_string($var) && $first !== 'P' ...
php
{ "resource": "" }
q13815
Converter.toArray
train
public function toArray() { return [ 'year' => $this->year, 'month' => $this->month, 'day' => $this->day, 'dayOfWeek' => $this->dayOfWeek, 'dayOfYear' => $this->dayOfYear, 'hour' => $this->hour, 'minute' => $this->minute, ...
php
{ "resource": "" }
q13816
CarbonTimeZone.instance
train
public static function instance($object = null, $objectDump = null) { $tz = $object; if ($tz instanceof static) { return $tz; } if ($tz === null) { return new static(); } if (!$tz instanceof DateTimeZone) { $tz = static::getDateT...
php
{ "resource": "" }
q13817
CarbonTimeZone.getAbbreviatedName
train
public function getAbbreviatedName($dst = false) { $name = $this->getName(); foreach ($this->listAbbreviations() as $abbreviation => $zones) { foreach ($zones as $zone) { if ($zone['timezone_id'] === $name && $zone['dst'] == $dst) { return $abbreviati...
php
{ "resource": "" }
q13818
CarbonTimeZone.toRegionTimeZone
train
public function toRegionTimeZone(DateTimeInterface $date = null) { $tz = $this->toRegionName($date); if ($tz === false) { if (Carbon::isStrictModeEnabled()) { throw new InvalidArgumentException('Unknown timezone for offset '.$this->getOffset($date ?: Carbon::now($this))....
php
{ "resource": "" }
q13819
CarbonPeriod.createFromIso
train
public static function createFromIso($iso, $options = null) { $params = static::parseIso8601($iso); $instance = static::createFromArray($params); if ($options !== null) { $instance->setOptions($options); } return $instance; }
php
{ "resource": "" }
q13820
CarbonPeriod.intervalHasTime
train
protected static function intervalHasTime(DateInterval $interval) { // The array_key_exists and get_object_vars are used as a workaround to check microsecond support. // Both isset and property_exists will fail on PHP 7.0.14 - 7.0.21 due to the following bug: // https://bugs.php.net/bug.php?...
php
{ "resource": "" }
q13821
CarbonPeriod.parseIso8601
train
protected static function parseIso8601($iso) { $result = []; $interval = null; $start = null; $end = null; foreach (explode('/', $iso) as $key => $part) { if ($key === 0 && preg_match('/^R([0-9]*)$/', $part, $match)) { $parsed = strlen($match[1])...
php
{ "resource": "" }
q13822
CarbonPeriod.addMissingParts
train
protected static function addMissingParts($source, $target) { $pattern = '/'.preg_replace('/[0-9]+/', '[0-9]+', preg_quote($target, '/')).'$/'; $result = preg_replace($pattern, $target, $source, 1, $count); return $count ? $result : $target; }
php
{ "resource": "" }
q13823
CarbonPeriod.setDateClass
train
public function setDateClass(string $dateClass) { if (!is_a($dateClass, CarbonInterface::class, true)) { throw new InvalidArgumentException(sprintf( 'Given class does not implement %s: %s', CarbonInterface::class, $dateClass )); } $this->dateClass = $...
php
{ "resource": "" }
q13824
CarbonPeriod.setDateInterval
train
public function setDateInterval($interval) { if (!$interval = CarbonInterval::make($interval)) { throw new InvalidArgumentException('Invalid interval.'); } if ($interval->spec() === 'PT0S') { throw new InvalidArgumentException('Empty interval is not accepted.'); ...
php
{ "resource": "" }
q13825
CarbonPeriod.setDates
train
public function setDates($start, $end) { $this->setStartDate($start); $this->setEndDate($end); return $this; }
php
{ "resource": "" }
q13826
CarbonPeriod.setOptions
train
public function setOptions($options) { if (!is_int($options) && !is_null($options)) { throw new InvalidArgumentException('Invalid options.'); } $this->options = $options ?: 0; $this->handleChangedParameters(); return $this; }
php
{ "resource": "" }
q13827
CarbonPeriod.toggleOptions
train
public function toggleOptions($options, $state = null) { if ($state === null) { $state = ($this->options & $options) !== $options; } return $this->setOptions( $state ? $this->options | $options : $this->options & ~$options ); }
php
{ "resource": "" }
q13828
CarbonPeriod.addFilter
train
public function addFilter($callback, $name = null) { $tuple = $this->createFilterTuple(func_get_args()); $this->filters[] = $tuple; $this->handleChangedParameters(); return $this; }
php
{ "resource": "" }
q13829
CarbonPeriod.prependFilter
train
public function prependFilter($callback, $name = null) { $tuple = $this->createFilterTuple(func_get_args()); array_unshift($this->filters, $tuple); $this->handleChangedParameters(); return $this; }
php
{ "resource": "" }
q13830
CarbonPeriod.createFilterTuple
train
protected function createFilterTuple(array $parameters) { $method = array_shift($parameters); if (!$this->isCarbonPredicateMethod($method)) { return [$method, array_shift($parameters)]; } return [function ($date) use ($method, $parameters) { return call_user...
php
{ "resource": "" }
q13831
CarbonPeriod.removeFilter
train
public function removeFilter($filter) { $key = is_callable($filter) ? 0 : 1; $this->filters = array_values(array_filter( $this->filters, function ($tuple) use ($key, $filter) { return $tuple[$key] !== $filter; } )); $this->updateI...
php
{ "resource": "" }
q13832
CarbonPeriod.hasFilter
train
public function hasFilter($filter) { $key = is_callable($filter) ? 0 : 1; foreach ($this->filters as $tuple) { if ($tuple[$key] === $filter) { return true; } } return false; }
php
{ "resource": "" }
q13833
CarbonPeriod.setFilters
train
public function setFilters(array $filters) { $this->filters = $filters; $this->updateInternalState(); $this->handleChangedParameters(); return $this; }
php
{ "resource": "" }
q13834
CarbonPeriod.resetFilters
train
public function resetFilters() { $this->filters = []; if ($this->endDate !== null) { $this->filters[] = [static::END_DATE_FILTER, null]; } if ($this->recurrences !== null) { $this->filters[] = [static::RECURRENCES_FILTER, null]; } $this->han...
php
{ "resource": "" }
q13835
CarbonPeriod.updateInternalState
train
protected function updateInternalState() { if (!$this->hasFilter(static::END_DATE_FILTER)) { $this->endDate = null; } if (!$this->hasFilter(static::RECURRENCES_FILTER)) { $this->recurrences = null; } }
php
{ "resource": "" }
q13836
CarbonPeriod.setStartDate
train
public function setStartDate($date, $inclusive = null) { if (!$date = call_user_func([$this->dateClass, 'make'], $date)) { throw new InvalidArgumentException('Invalid start date.'); } $this->startDate = $date; if ($inclusive !== null) { $this->toggleOptions(...
php
{ "resource": "" }
q13837
CarbonPeriod.setEndDate
train
public function setEndDate($date, $inclusive = null) { if (!is_null($date) && !$date = call_user_func([$this->dateClass, 'make'], $date)) { throw new InvalidArgumentException('Invalid end date.'); } if (!$date) { return $this->removeFilter(static::END_DATE_FILTER); ...
php
{ "resource": "" }
q13838
CarbonPeriod.filterEndDate
train
protected function filterEndDate($current) { if (!$this->isEndExcluded() && $current == $this->endDate) { return true; } if ($this->dateInterval->invert ? $current > $this->endDate : $current < $this->endDate) { return true; } return static::END_ITER...
php
{ "resource": "" }
q13839
CarbonPeriod.handleChangedParameters
train
protected function handleChangedParameters() { if (($this->getOptions() & static::IMMUTABLE) && $this->dateClass === Carbon::class) { $this->setDateClass(CarbonImmutable::class); } elseif (!($this->getOptions() & static::IMMUTABLE) && $this->dateClass === CarbonImmutable::class) { ...
php
{ "resource": "" }
q13840
CarbonPeriod.validateCurrentDate
train
protected function validateCurrentDate() { if ($this->current === null) { $this->rewind(); } // Check after the first rewind to avoid repeating the initial validation. if ($this->validationResult !== null) { return $this->validationResult; } ...
php
{ "resource": "" }
q13841
CarbonPeriod.checkFilters
train
protected function checkFilters() { $current = $this->prepareForReturn($this->current); foreach ($this->filters as $tuple) { $result = call_user_func( $tuple[0], $current->copy(), $this->key, $this ); ...
php
{ "resource": "" }
q13842
CarbonPeriod.prepareForReturn
train
protected function prepareForReturn(CarbonInterface $date) { $date = call_user_func([$this->dateClass, 'make'], $date); if ($this->timezone) { $date = $date->setTimezone($this->timezone); } return $date; }
php
{ "resource": "" }
q13843
CarbonPeriod.next
train
public function next() { if ($this->current === null) { $this->rewind(); } if ($this->validationResult !== static::END_ITERATION) { $this->key++; $this->incrementCurrentDateUntilValid(); } }
php
{ "resource": "" }
q13844
CarbonPeriod.rewind
train
public function rewind() { $this->key = 0; $this->current = call_user_func([$this->dateClass, 'make'], $this->startDate); $settings = $this->getSettings(); $locale = $this->getLocalTranslator()->getLocale(); if ($locale) { $settings['locale'] = $locale; } ...
php
{ "resource": "" }
q13845
CarbonPeriod.incrementCurrentDateUntilValid
train
protected function incrementCurrentDateUntilValid() { $attempts = 0; do { $this->current = $this->current->add($this->dateInterval); $this->validationResult = null; if (++$attempts > static::NEXT_MAX_ATTEMPTS) { throw new RuntimeException('Could...
php
{ "resource": "" }
q13846
CarbonPeriod.toIso8601String
train
public function toIso8601String() { $parts = []; if ($this->recurrences !== null) { $parts[] = 'R'.$this->recurrences; } $parts[] = $this->startDate->toIso8601String(); $parts[] = $this->dateInterval->spec(); if ($this->endDate !== null) { ...
php
{ "resource": "" }
q13847
CarbonPeriod.toString
train
public function toString() { $translator = call_user_func([$this->dateClass, 'getTranslator']); $parts = []; $format = !$this->startDate->isStartOfDay() || $this->endDate && !$this->endDate->isStartOfDay() ? 'Y-m-d H:i:s' : 'Y-m-d'; if ($this->recurrences !...
php
{ "resource": "" }
q13848
CarbonPeriod.toArray
train
public function toArray() { $state = [ $this->key, $this->current ? $this->current->copy() : null, $this->validationResult, ]; $result = iterator_to_array($this); [ $this->key, $this->current, $this->validation...
php
{ "resource": "" }
q13849
CarbonPeriod.callMacro
train
protected function callMacro($name, $parameters) { $macro = static::$macros[$name]; if ($macro instanceof Closure) { return call_user_func_array($macro->bindTo($this, static::class), $parameters); } return call_user_func_array($macro, $parameters); }
php
{ "resource": "" }
q13850
CarbonInterval.getCascadeFactors
train
public static function getCascadeFactors() { return static::$cascadeFactors ?: [ 'milliseconds' => [Carbon::MICROSECONDS_PER_MILLISECOND, 'microseconds'], 'seconds' => [Carbon::MILLISECONDS_PER_SECOND, 'milliseconds'], 'minutes' => [Carbon::SECONDS_PER_MINUTE, 'seconds'],...
php
{ "resource": "" }
q13851
CarbonInterval.getFactor
train
public static function getFactor($source, $target) { $source = self::standardizeUnit($source); $target = self::standardizeUnit($target); $factors = static::getFlipCascadeFactors(); if (isset($factors[$source])) { [$to, $factor] = $factors[$source]; if ($to ===...
php
{ "resource": "" }
q13852
CarbonInterval.make
train
public static function make($var) { if ($var instanceof DateInterval) { return static::instance($var); } if (!is_string($var)) { return null; } $var = trim($var); if (preg_match('/^P[T0-9]/', $var)) { return new static($var); ...
php
{ "resource": "" }
q13853
CarbonInterval.createFromDateString
train
public static function createFromDateString($time) { $interval = parent::createFromDateString($time); if ($interval instanceof DateInterval && !($interval instanceof static)) { $interval = static::instance($interval); } return static::instance($interval); }
php
{ "resource": "" }
q13854
CarbonInterval.isEmpty
train
public function isEmpty() { return $this->years === 0 && $this->months === 0 && $this->dayz === 0 && !$this->days && $this->hours === 0 && $this->minutes === 0 && $this->seconds === 0 && $this->microseconds === 0; }
php
{ "resource": "" }
q13855
CarbonInterval.sub
train
public function sub($unit, $value = 1) { if (is_numeric($unit)) { $_unit = $value; $value = $unit; $unit = $_unit; unset($_unit); } return $this->add($unit, -floatval($value)); }
php
{ "resource": "" }
q13856
CarbonInterval.times
train
public function times($factor) { if ($factor < 0) { $this->invert = $this->invert ? 0 : 1; $factor = -$factor; } $this->years = (int) round($this->years * $factor); $this->months = (int) round($this->months * $factor); $this->dayz = (int) round($this-...
php
{ "resource": "" }
q13857
CarbonInterval.getDateIntervalSpec
train
public static function getDateIntervalSpec(DateInterval $interval) { $date = array_filter([ static::PERIOD_YEARS => abs($interval->y), static::PERIOD_MONTHS => abs($interval->m), static::PERIOD_DAYS => abs($interval->d), ]); $time = array_filter([ ...
php
{ "resource": "" }
q13858
CarbonInterval.cascade
train
public function cascade() { foreach (static::getFlipCascadeFactors() as $source => [$target, $factor]) { if ($source === 'dayz' && $target === 'weeks') { continue; } $value = $this->$source; $this->$source = $modulo = ($factor + ($value % $fac...
php
{ "resource": "" }
q13859
CarbonInterval.total
train
public function total($unit) { $realUnit = $unit = strtolower($unit); if (in_array($unit, ['days', 'weeks'])) { $realUnit = 'dayz'; } elseif (!in_array($unit, ['microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', 'dayz', 'months', 'years'])) { throw new Inv...
php
{ "resource": "" }
q13860
Language.getNames
train
public function getNames(): array { if (!$this->names) { $this->names = static::all()[$this->code] ?? [ 'isoName' => $this->code, 'nativeName' => $this->code, ]; } return $this->names; }
php
{ "resource": "" }
q13861
Language.getRegionName
train
public function getRegionName(): ?string { return $this->region ? (static::regions()[$this->region] ?? $this->region) : null; }
php
{ "resource": "" }
q13862
Language.getFullIsoName
train
public function getFullIsoName(): string { if (!$this->isoName) { $this->isoName = $this->getNames()['isoName']; } return $this->isoName; }
php
{ "resource": "" }
q13863
Language.getFullNativeName
train
public function getFullNativeName(): string { if (!$this->nativeName) { $this->nativeName = $this->getNames()['nativeName']; } return $this->nativeName; }
php
{ "resource": "" }
q13864
Language.getIsoName
train
public function getIsoName(): string { $name = $this->getFullIsoName(); return trim(strstr($name, ',', true) ?: $name); }
php
{ "resource": "" }
q13865
Language.getNativeName
train
public function getNativeName(): string { $name = $this->getFullNativeName(); return trim(strstr($name, ',', true) ?: $name); }
php
{ "resource": "" }
q13866
Language.getIsoDescription
train
public function getIsoDescription() { $region = $this->getRegionName(); $variant = $this->getVariantName(); return $this->getIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); }
php
{ "resource": "" }
q13867
Language.getNativeDescription
train
public function getNativeDescription() { $region = $this->getRegionName(); $variant = $this->getVariantName(); return $this->getNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); }
php
{ "resource": "" }
q13868
Language.getFullIsoDescription
train
public function getFullIsoDescription() { $region = $this->getRegionName(); $variant = $this->getVariantName(); return $this->getFullIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); }
php
{ "resource": "" }
q13869
Language.getFullNativeDescription
train
public function getFullNativeDescription() { $region = $this->getRegionName(); $variant = $this->getVariantName(); return $this->getFullNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); }
php
{ "resource": "" }
q13870
Translator.get
train
public static function get($locale = null) { $locale = $locale ?: 'en'; if (!isset(static::$singletons[$locale])) { static::$singletons[$locale] = new static($locale ?: 'en'); } return static::$singletons[$locale]; }
php
{ "resource": "" }
q13871
Translator.removeDirectory
train
public function removeDirectory(string $directory) { $search = rtrim(strtr($directory, '\\', '/'), '/'); return $this->setDirectories(array_filter($this->getDirectories(), function ($item) use ($search) { return rtrim(strtr($item, '\\', '/'), '/') !== $search; })); }
php
{ "resource": "" }
q13872
Translator.loadMessagesFromFile
train
protected function loadMessagesFromFile($locale) { if (isset($this->messages[$locale])) { return true; } return $this->resetMessages($locale); }
php
{ "resource": "" }
q13873
Translator.setMessages
train
public function setMessages($locale, $messages) { $this->loadMessagesFromFile($locale); $this->addResource('array', $messages, $locale); $this->messages[$locale] = array_merge( isset($this->messages[$locale]) ? $this->messages[$locale] : [], $messages ); ...
php
{ "resource": "" }
q13874
Translator.getMessages
train
public function getMessages($locale = null) { return $locale === null ? $this->messages : $this->messages[$locale]; }
php
{ "resource": "" }
q13875
Options.getSettings
train
public function getSettings() { $settings = []; $map = [ 'localStrictModeEnabled' => 'strictMode', 'localMonthsOverflow' => 'monthOverflow', 'localYearsOverflow' => 'yearOverflow', 'localHumanDiffOptions' => 'humanDiffOptions', 'localToStri...
php
{ "resource": "" }
q13876
Macro.genericMacro
train
public static function genericMacro($macro, $priority = 0) { if (!isset(static::$globalGenericMacros[$priority])) { static::$globalGenericMacros[$priority] = []; krsort(static::$globalGenericMacros, SORT_NUMERIC); } static::$globalGenericMacros[$priority][] = $macro;...
php
{ "resource": "" }
q13877
Difference.diffInMonths
train
public function diffInMonths($date = null, $absolute = true) { $date = $this->resolveCarbon($date); return $this->diffInYears($date, $absolute) * static::MONTHS_PER_YEAR + (int) $this->diff($date, $absolute)->format('%r%m'); }
php
{ "resource": "" }
q13878
Difference.diffInHoursFiltered
train
public function diffInHoursFiltered(Closure $callback, $date = null, $absolute = true) { return $this->diffFiltered(CarbonInterval::hour(), $callback, $date, $absolute); }
php
{ "resource": "" }
q13879
Difference.diffInWeekdays
train
public function diffInWeekdays($date = null, $absolute = true) { return $this->diffInDaysFiltered(function (CarbonInterface $date) { return $date->isWeekday(); }, $date, $absolute); }
php
{ "resource": "" }
q13880
Difference.diffInWeekendDays
train
public function diffInWeekendDays($date = null, $absolute = true) { return $this->diffInDaysFiltered(function (CarbonInterface $date) { return $date->isWeekend(); }, $date, $absolute); }
php
{ "resource": "" }
q13881
Difference.diffInRealHours
train
public function diffInRealHours($date = null, $absolute = true) { return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR); }
php
{ "resource": "" }
q13882
Difference.diffInRealMinutes
train
public function diffInRealMinutes($date = null, $absolute = true) { return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE); }
php
{ "resource": "" }
q13883
Difference.diffInMicroseconds
train
public function diffInMicroseconds($date = null, $absolute = true) { $diff = $this->diff($this->resolveCarbon($date)); $value = (int) round((((($diff->days * static::HOURS_PER_DAY) + $diff->h) * static::MINUTES_PER_HOUR + $diff->i) * static::SECONDS_PER_MINUTE + (...
php
{ "resource": "" }
q13884
Difference.diffInMilliseconds
train
public function diffInMilliseconds($date = null, $absolute = true) { return (int) ($this->diffInMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND); }
php
{ "resource": "" }
q13885
Difference.diffInRealSeconds
train
public function diffInRealSeconds($date = null, $absolute = true) { /** @var CarbonInterface $date */ $date = $this->resolveCarbon($date); $value = $date->getTimestamp() - $this->getTimestamp(); return $absolute ? abs($value) : $value; }
php
{ "resource": "" }
q13886
Difference.diffInRealMicroseconds
train
public function diffInRealMicroseconds($date = null, $absolute = true) { /** @var CarbonInterface $date */ $date = $this->resolveCarbon($date); $value = ($date->timestamp - $this->timestamp) * static::MICROSECONDS_PER_SECOND + $date->micro - $this->micro; return $absolut...
php
{ "resource": "" }
q13887
Difference.diffInRealMilliseconds
train
public function diffInRealMilliseconds($date = null, $absolute = true) { return (int) ($this->diffInRealMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND); }
php
{ "resource": "" }
q13888
Boundaries.endOfSecond
train
public function endOfSecond() { return $this->setTime($this->hour, $this->minute, $this->second, static::MICROSECONDS_PER_SECOND - 1); }
php
{ "resource": "" }
q13889
Boundaries.startOf
train
public function startOf($unit, ...$params) { $ucfUnit = ucfirst(static::singularUnit($unit)); $method = "startOf$ucfUnit"; if (!method_exists($this, $method)) { throw new InvalidArgumentException("Unknown unit '$unit'"); } return $this->$method(...$params); }
php
{ "resource": "" }
q13890
Units.add
train
public function add($unit, $value = 1, $overflow = null) { if (is_string($unit) && func_num_args() === 1) { $unit = CarbonInterval::make($unit); } if ($unit instanceof DateInterval) { return parent::add($unit); } if (is_numeric($unit)) { ...
php
{ "resource": "" }
q13891
Units.subUnit
train
public function subUnit($unit, $value = 1, $overflow = null) { return $this->addUnit($unit, -$value, $overflow); }
php
{ "resource": "" }
q13892
Rounding.roundUnit
train
public function roundUnit($unit, $precision = 1, $function = 'round') { $metaUnits = [ // @call roundUnit 'millennium' => [static::YEARS_PER_MILLENNIUM, 'year'], // @call roundUnit 'century' => [static::YEARS_PER_CENTURY, 'year'], // @call roundUni...
php
{ "resource": "" }
q13893
Rounding.roundWeek
train
public function roundWeek($weekStartsAt = null) { return $this->closest($this->copy()->floorWeek($weekStartsAt), $this->copy()->ceilWeek($weekStartsAt)); }
php
{ "resource": "" }
q13894
Rounding.ceilWeek
train
public function ceilWeek($weekStartsAt = null) { if ($this->isMutable()) { $startOfWeek = $this->copy()->startOfWeek($weekStartsAt); return $startOfWeek != $this ? $this->startOfWeek($weekStartsAt)->addWeek() : $this; } $startOfWeek =...
php
{ "resource": "" }
q13895
Comparison.isSameUnit
train
public function isSameUnit($unit, $date = null) { $units = [ // @call isSameUnit 'year' => 'Y', // @call isSameUnit 'week' => 'o-W', // @call isSameUnit 'day' => 'Y-m-d', // @call isSameUnit 'hour' => 'Y-m-d H', ...
php
{ "resource": "" }
q13896
Comparison.isDayOfWeek
train
public function isDayOfWeek($dayOfWeek) { if (is_string($dayOfWeek) && defined($constant = static::class.'::'.strtoupper($dayOfWeek))) { $dayOfWeek = constant($constant); } return $this->dayOfWeek === $dayOfWeek; }
php
{ "resource": "" }
q13897
Autoloader.autoload
train
public function autoload($className) { if (0 === strpos($className, $this->prefix)) { $parts = explode('\\', substr($className, $this->prefixLength)); $filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php'; if (is_file($filepath)) { ...
php
{ "resource": "" }
q13898
ReplicationStrategy.isReadOperation
train
public function isReadOperation(CommandInterface $command) { if (isset($this->disallowed[$id = $command->getId()])) { throw new NotSupportedException( "The command '$id' is not allowed in replication mode." ); } if (isset($this->readonly[$id])) { ...
php
{ "resource": "" }
q13899
ReplicationStrategy.isSortReadOnly
train
protected function isSortReadOnly(CommandInterface $command) { $arguments = $command->getArguments(); $argc = count($arguments); if ($argc > 1) { for ($i = 1; $i < $argc; ++$i) { $argument = strtoupper($arguments[$i]); if ($argument === 'STORE') {...
php
{ "resource": "" }