[Web] Update composer libs

- Removing symfony/deprecation-contracts (v2.4.0)
  - Upgrading ddeboer/imap (1.12.1 => 1.13.1)
  - Upgrading directorytree/ldaprecord (v2.6.3 => v2.10.1)
  - Upgrading illuminate/contracts (v8.53.1 => v9.3.0)
  - Upgrading nesbot/carbon (2.51.1 => 2.57.0)
  - Upgrading phpmailer/phpmailer (v6.5.0 => v6.6.0)
  - Upgrading psr/container (1.1.1 => 2.0.2)
  - Upgrading psr/log (1.1.4 => 3.0.0)
  - Upgrading psr/simple-cache (1.0.1 => 2.0.0)
  - Upgrading robthree/twofactorauth (1.8.0 => 1.8.1)
  - Upgrading symfony/polyfill-ctype (v1.23.0 => v1.24.0)
  - Upgrading symfony/polyfill-mbstring (v1.23.1 => v1.24.0)
  - Upgrading symfony/polyfill-php80 (v1.23.1 => v1.24.0)
  - Upgrading symfony/translation (v5.3.4 => v6.0.5)
  - Upgrading symfony/translation-contracts (v2.4.0 => v3.0.0)
  - Upgrading symfony/var-dumper (v5.3.6 => v6.0.5)
  - Upgrading tightenco/collect (v8.34.0 => v8.83.2)
  - Upgrading twig/twig (v3.3.2 => v3.3.8)
This commit is contained in:
andryyy
2022-03-02 20:08:24 +01:00
parent 24275ffdbf
commit 98bc947d00
940 changed files with 7649 additions and 14226 deletions

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php
use Carbon\Cli\Invoker;
$dir = __DIR__.'/..';
if (!file_exists($dir.'/autoload.php')) {
@@ -18,4 +20,4 @@ if (!file_exists($dir.'/autoload.php')) {
require $dir.'/autoload.php';
exit((new \Carbon\Cli\Invoker())(...$argv) ? 0 : 1);
exit((new Invoker())(...$argv) ? 0 : 1);

View File

@@ -25,21 +25,25 @@
"ext-json": "*",
"symfony/polyfill-mbstring": "^1.0",
"symfony/polyfill-php80": "^1.16",
"symfony/translation": "^3.4 || ^4.0 || ^5.0"
"symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0"
},
"require-dev": {
"doctrine/dbal": "^2.0 || ^3.0",
"doctrine/orm": "^2.7",
"friendsofphp/php-cs-fixer": "^2.14 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.0",
"kylekatarnls/multi-tester": "^2.0",
"phpmd/phpmd": "^2.9",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.54",
"phpstan/phpstan": "^0.12.54 || ^1.0",
"phpunit/phpunit": "^7.5.20 || ^8.5.14",
"squizlabs/php_codesniffer": "^3.4"
},
"config": {
"process-timeout": 0,
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"extra": {
"branch-alias": {
@@ -93,6 +97,7 @@
},
"support": {
"issues": "https://github.com/briannesbitt/Carbon/issues",
"source": "https://github.com/briannesbitt/Carbon"
"source": "https://github.com/briannesbitt/Carbon",
"docs": "https://carbon.nesbot.com/docs"
}
}

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\PHPStan;
if (!class_exists(LazyMacro::class, false)) {
abstract class LazyMacro extends AbstractMacro
{
/**
* {@inheritdoc}
*/
public function getFileName(): ?string
{
return $this->reflectionFunction->getFileName();
}
/**
* {@inheritdoc}
*/
public function getStartLine(): ?int
{
return $this->reflectionFunction->getStartLine();
}
/**
* {@inheritdoc}
*/
public function getEndLine(): ?int
{
return $this->reflectionFunction->getEndLine();
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\PHPStan;
if (!class_exists(LazyMacro::class, false)) {
abstract class LazyMacro extends AbstractMacro
{
/**
* {@inheritdoc}
*
* @return string|false
*/
public function getFileName()
{
return $this->reflectionFunction->getFileName();
}
/**
* {@inheritdoc}
*
* @return int|false
*/
public function getStartLine()
{
return $this->reflectionFunction->getStartLine();
}
/**
* {@inheritdoc}
*
* @return int|false
*/
public function getEndLine()
{
return $this->reflectionFunction->getEndLine();
}
}
}

View File

@@ -0,0 +1,52 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use Symfony\Component\Translation\MessageCatalogueInterface;
if (!class_exists(LazyTranslator::class, false)) {
class LazyTranslator extends AbstractTranslator implements TranslatorStrongTypeInterface
{
public function trans(?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
return $this->translate($id, $parameters, $domain, $locale);
}
public function getFromCatalogue(MessageCatalogueInterface $catalogue, string $id, string $domain = 'messages')
{
$messages = $this->getPrivateProperty($catalogue, 'messages');
if (isset($messages[$domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX][$id])) {
return $messages[$domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX][$id];
}
if (isset($messages[$domain][$id])) {
return $messages[$domain][$id];
}
$fallbackCatalogue = $this->getPrivateProperty($catalogue, 'fallbackCatalogue');
if ($fallbackCatalogue !== null) {
return $this->getFromCatalogue($fallbackCatalogue, $id, $domain);
}
return $id;
}
private function getPrivateProperty($instance, string $field)
{
return (function (string $field) {
return $this->$field;
})->call($instance, $field);
}
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
if (!class_exists(LazyTranslator::class, false)) {
class LazyTranslator extends AbstractTranslator
{
/**
* Returns the translation.
*
* @param string|null $id
* @param array $parameters
* @param string|null $domain
* @param string|null $locale
*
* @return string
*/
public function trans($id, array $parameters = [], $domain = null, $locale = null)
{
return $this->translate($id, $parameters, $domain, $locale);
}
}
}

View File

@@ -3,9 +3,7 @@
[![Latest Stable Version](https://img.shields.io/packagist/v/nesbot/carbon.svg?style=flat-square)](https://packagist.org/packages/nesbot/carbon)
[![Total Downloads](https://img.shields.io/packagist/dt/nesbot/carbon.svg?style=flat-square)](https://packagist.org/packages/nesbot/carbon)
[![GitHub Actions](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fbriannesbitt%2FCarbon%2Fbadge&style=flat-square&label=Build&logo=none)](https://actions-badge.atrox.dev/briannesbitt/Carbon/goto)
[![StyleCI](https://github.styleci.io/repos/5724990/shield?style=flat-square)](https://github.styleci.io/repos/5724990)
[![codecov.io](https://img.shields.io/codecov/c/github/briannesbitt/Carbon.svg?style=flat-square)](https://codecov.io/github/briannesbitt/Carbon?branch=master)
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true&style=flat-square)](https://github.com/phpstan/phpstan)
[![Tidelift](https://tidelift.com/badges/github/briannesbitt/Carbon)](https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme)
An international PHP extension for DateTime. [https://carbon.nesbot.com](https://carbon.nesbot.com)

View File

@@ -0,0 +1,401 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use Closure;
use ReflectionException;
use ReflectionFunction;
use Symfony\Component\Translation;
use Symfony\Component\Translation\Formatter\MessageFormatterInterface;
use Symfony\Component\Translation\Loader\ArrayLoader;
abstract class AbstractTranslator extends Translation\Translator
{
/**
* Translator singletons for each language.
*
* @var array
*/
protected static $singletons = [];
/**
* List of custom localized messages.
*
* @var array
*/
protected $messages = [];
/**
* List of custom directories that contain translation files.
*
* @var string[]
*/
protected $directories = [];
/**
* Set to true while constructing.
*
* @var bool
*/
protected $initializing = false;
/**
* List of locales aliases.
*
* @var string[]
*/
protected $aliases = [
'me' => 'sr_Latn_ME',
'scr' => 'sh',
];
/**
* Return a singleton instance of Translator.
*
* @param string|null $locale optional initial locale ("en" - english by default)
*
* @return static
*/
public static function get($locale = null)
{
$locale = $locale ?: 'en';
$key = static::class === Translator::class ? $locale : static::class.'|'.$locale;
if (!isset(static::$singletons[$key])) {
static::$singletons[$key] = new static($locale);
}
return static::$singletons[$key];
}
public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false)
{
parent::setLocale($locale);
$this->initializing = true;
$this->directories = [__DIR__.'/Lang'];
$this->addLoader('array', new ArrayLoader());
parent::__construct($locale, $formatter, $cacheDir, $debug);
$this->initializing = false;
}
/**
* Returns the list of directories translation files are searched in.
*
* @return array
*/
public function getDirectories(): array
{
return $this->directories;
}
/**
* Set list of directories translation files are searched in.
*
* @param array $directories new directories list
*
* @return $this
*/
public function setDirectories(array $directories)
{
$this->directories = $directories;
return $this;
}
/**
* Add a directory to the list translation files are searched in.
*
* @param string $directory new directory
*
* @return $this
*/
public function addDirectory(string $directory)
{
$this->directories[] = $directory;
return $this;
}
/**
* Remove a directory from the list translation files are searched in.
*
* @param string $directory directory path
*
* @return $this
*/
public function removeDirectory(string $directory)
{
$search = rtrim(strtr($directory, '\\', '/'), '/');
return $this->setDirectories(array_filter($this->getDirectories(), function ($item) use ($search) {
return rtrim(strtr($item, '\\', '/'), '/') !== $search;
}));
}
/**
* Reset messages of a locale (all locale if no locale passed).
* Remove custom messages and reload initial messages from matching
* file in Lang directory.
*
* @param string|null $locale
*
* @return bool
*/
public function resetMessages($locale = null)
{
if ($locale === null) {
$this->messages = [];
return true;
}
foreach ($this->getDirectories() as $directory) {
$data = @include sprintf('%s/%s.php', rtrim($directory, '\\/'), $locale);
if ($data !== false) {
$this->messages[$locale] = $data;
$this->addResource('array', $this->messages[$locale], $locale);
return true;
}
}
return false;
}
/**
* Returns the list of files matching a given locale prefix (or all if empty).
*
* @param string $prefix prefix required to filter result
*
* @return array
*/
public function getLocalesFiles($prefix = '')
{
$files = [];
foreach ($this->getDirectories() as $directory) {
$directory = rtrim($directory, '\\/');
foreach (glob("$directory/$prefix*.php") as $file) {
$files[] = $file;
}
}
return array_unique($files);
}
/**
* Returns the list of internally available locales and already loaded custom locales.
* (It will ignore custom translator dynamic loading.)
*
* @param string $prefix prefix required to filter result
*
* @return array
*/
public function getAvailableLocales($prefix = '')
{
$locales = [];
foreach ($this->getLocalesFiles($prefix) as $file) {
$locales[] = substr($file, strrpos($file, '/') + 1, -4);
}
return array_unique(array_merge($locales, array_keys($this->messages)));
}
protected function translate(?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
if ($domain === null) {
$domain = 'messages';
}
$catalogue = $this->getCatalogue($locale);
$format = $this instanceof TranslatorStrongTypeInterface
? $this->getFromCatalogue($catalogue, (string) $id, $domain) // @codeCoverageIgnore
: $this->getCatalogue($locale)->get((string) $id, $domain);
if ($format instanceof Closure) {
// @codeCoverageIgnoreStart
try {
$count = (new ReflectionFunction($format))->getNumberOfRequiredParameters();
} catch (ReflectionException $exception) {
$count = 0;
}
// @codeCoverageIgnoreEnd
return $format(
...array_values($parameters),
...array_fill(0, max(0, $count - \count($parameters)), null)
);
}
return parent::trans($id, $parameters, $domain, $locale);
}
/**
* Init messages language from matching file in Lang directory.
*
* @param string $locale
*
* @return bool
*/
protected function loadMessagesFromFile($locale)
{
if (isset($this->messages[$locale])) {
return true;
}
return $this->resetMessages($locale);
}
/**
* Set messages of a locale and take file first if present.
*
* @param string $locale
* @param array $messages
*
* @return $this
*/
public function setMessages($locale, $messages)
{
$this->loadMessagesFromFile($locale);
$this->addResource('array', $messages, $locale);
$this->messages[$locale] = array_merge(
$this->messages[$locale] ?? [],
$messages
);
return $this;
}
/**
* Set messages of the current locale and take file first if present.
*
* @param array $messages
*
* @return $this
*/
public function setTranslations($messages)
{
return $this->setMessages($this->getLocale(), $messages);
}
/**
* Get messages of a locale, if none given, return all the
* languages.
*
* @param string|null $locale
*
* @return array
*/
public function getMessages($locale = null)
{
return $locale === null ? $this->messages : $this->messages[$locale];
}
/**
* Set the current translator locale and indicate if the source locale file exists
*
* @param string $locale locale ex. en
*
* @return bool
*/
public function setLocale($locale)
{
$locale = preg_replace_callback('/[-_]([a-z]{2,}|[0-9]{2,})/', function ($matches) {
// _2-letters or YUE is a region, _3+-letters is a variant
$upper = strtoupper($matches[1]);
if ($upper === 'YUE' || $upper === 'ISO' || \strlen($upper) < 3) {
return "_$upper";
}
return '_'.ucfirst($matches[1]);
}, strtolower($locale));
$previousLocale = $this->getLocale();
if ($previousLocale === $locale && isset($this->messages[$locale])) {
return true;
}
unset(static::$singletons[$previousLocale]);
if ($locale === 'auto') {
$completeLocale = setlocale(LC_TIME, '0');
$locale = preg_replace('/^([^_.-]+).*$/', '$1', $completeLocale);
$locales = $this->getAvailableLocales($locale);
$completeLocaleChunks = preg_split('/[_.-]+/', $completeLocale);
$getScore = function ($language) use ($completeLocaleChunks) {
return self::compareChunkLists($completeLocaleChunks, preg_split('/[_.-]+/', $language));
};
usort($locales, function ($first, $second) use ($getScore) {
return $getScore($second) <=> $getScore($first);
});
$locale = $locales[0];
}
if (isset($this->aliases[$locale])) {
$locale = $this->aliases[$locale];
}
// If subtag (ex: en_CA) first load the macro (ex: en) to have a fallback
if (str_contains($locale, '_') &&
$this->loadMessagesFromFile($macroLocale = preg_replace('/^([^_]+).*$/', '$1', $locale))
) {
parent::setLocale($macroLocale);
}
if ($this->loadMessagesFromFile($locale) || $this->initializing) {
parent::setLocale($locale);
return true;
}
return false;
}
/**
* Show locale on var_dump().
*
* @return array
*/
public function __debugInfo()
{
return [
'locale' => $this->getLocale(),
];
}
private static function compareChunkLists($referenceChunks, $chunks)
{
$score = 0;
foreach ($referenceChunks as $index => $chunk) {
if (!isset($chunks[$index])) {
$score++;
continue;
}
if (strtolower($chunks[$index]) === strtolower($chunk)) {
$score += 10;
}
}
return $score;
}
}

View File

@@ -8,9 +8,11 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use Carbon\Traits\Date;
use Carbon\Traits\DeprecatedProperties;
use DateTime;
use DateTimeInterface;
use DateTimeZone;
@@ -18,6 +20,8 @@ use DateTimeZone;
/**
* A simple API extension for DateTime.
*
* @mixin DeprecatedProperties
*
* <autodoc generated by `composer phpdoc`>
*
* @property int $year
@@ -34,10 +38,6 @@ use DateTimeZone;
* @property string $shortEnglishDayOfWeek the abbreviated day of week in English
* @property string $englishMonth the month in English
* @property string $shortEnglishMonth the abbreviated month in English
* @property string $localeDayOfWeek the day of week in current locale LC_TIME
* @property string $shortLocaleDayOfWeek the abbreviated day of week in current locale LC_TIME
* @property string $localeMonth the month in current locale LC_TIME
* @property string $shortLocaleMonth the abbreviated month in current locale LC_TIME
* @property int $milliseconds
* @property int $millisecond
* @property int $milli

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use DateTimeInterface;

View File

@@ -8,9 +8,11 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use Carbon\Traits\Date;
use Carbon\Traits\DeprecatedProperties;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
@@ -18,6 +20,8 @@ use DateTimeZone;
/**
* A simple API extension for DateTimeImmutable.
*
* @mixin DeprecatedProperties
*
* <autodoc generated by `composer phpdoc`>
*
* @property int $year
@@ -34,10 +38,6 @@ use DateTimeZone;
* @property string $shortEnglishDayOfWeek the abbreviated day of week in English
* @property string $englishMonth the month in English
* @property string $shortEnglishMonth the abbreviated month in English
* @property string $localeDayOfWeek the day of week in current locale LC_TIME
* @property string $shortLocaleDayOfWeek the abbreviated day of week in current locale LC_TIME
* @property string $localeMonth the month in current locale LC_TIME
* @property string $shortLocaleMonth the abbreviated month in current locale LC_TIME
* @property int $milliseconds
* @property int $millisecond
* @property int $milli

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use BadMethodCallException;
@@ -27,6 +28,7 @@ use DateTimeZone;
use JsonSerializable;
use ReflectionException;
use ReturnTypeWillChange;
use Symfony\Component\Translation\TranslatorInterface;
use Throwable;
/**
@@ -48,10 +50,6 @@ use Throwable;
* @property string $shortEnglishDayOfWeek the abbreviated day of week in English
* @property string $englishMonth the month in English
* @property string $shortEnglishMonth the abbreviated month in English
* @property string $localeDayOfWeek the day of week in current locale LC_TIME
* @property string $shortLocaleDayOfWeek the abbreviated day of week in current locale LC_TIME
* @property string $localeMonth the month in current locale LC_TIME
* @property string $shortLocaleMonth the abbreviated month in current locale LC_TIME
* @property int $milliseconds
* @property int $millisecond
* @property int $milli
@@ -1270,7 +1268,8 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
/**
* Get the difference as a CarbonInterval instance.
* Return absolute interval (always positive) unless you pass false to the second argument.
* Return relative interval (negative if $absolute flag is not set to true and the given date is before
* current one).
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
@@ -1312,6 +1311,10 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
* - 'short' entry (see below)
* - 'parts' entry (see below)
* - 'options' entry (see below)
* - 'skip' entry, list of units to skip (array of strings or a single string,
* ` it can be the unit name (singular or plural) or its shortcut
* ` (y, m, w, d, h, min, s, ms, µs).
* - 'aUnit' entry, prefer "an hour" over "1 hour" if true
* - 'join' entry determines how to join multiple parts of the string
* ` - if $join is a string, it's used as a joiner glue
* ` - if $join is a callable/closure, it get the list of string and should return a string
@@ -1320,6 +1323,8 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
* ` - if $join is true, it will be guessed from the locale ('list' translation file entry)
* ` - if $join is missing, a space will be used as glue
* - 'other' entry (see above)
* - 'minimumUnit' entry determines the smallest unit of time to display can be long or
* ` short form of the units, e.g. 'hour' or 'h' (default value: s)
* if int passed, it add modifiers:
* Possible values:
* - CarbonInterface::DIFF_ABSOLUTE no modifiers
@@ -1962,6 +1967,10 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
* Format the instance with the current locale. You can set the current
* locale using setlocale() https://php.net/setlocale.
*
* @deprecated It uses OS language package and strftime() which is deprecated since PHP 8.1.
* Use ->isoFormat() instead.
* Deprecated since 2.55.0
*
* @param string $format
*
* @return string
@@ -2148,6 +2157,8 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
/**
* {@inheritdoc}
*
* @return array
*/
#[ReturnTypeWillChange]
public static function getLastErrors();
@@ -2259,6 +2270,13 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
*/
public static function getTimeFormatByPrecision($unitPrecision);
/**
* Returns the timestamp with millisecond precision.
*
* @return int
*/
public function getTimestampMs();
/**
* Get the translation of the current week day name (with context for languages with multiple forms).
*
@@ -3332,6 +3350,8 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
* Calls \DateTime::modify if mutable or \DateTimeImmutable::modify else.
*
* @see https://php.net/manual/en/datetime.modify.php
*
* @return static|false
*/
#[ReturnTypeWillChange]
public function modify($modify);
@@ -3792,7 +3812,7 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
*
* @return $this
*/
public function setLocalTranslator(\Symfony\Component\Translation\TranslatorInterface $translator);
public function setLocalTranslator(TranslatorInterface $translator);
/**
* Set the current translator locale and indicate if the source locale file exists.
@@ -3832,6 +3852,9 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
* Note the timezone parameter was left out of the examples above and
* has no affect as the mock value will be returned regardless of its value.
*
* Only the moment is mocked with setTestNow(), the timezone will still be the one passed
* as parameter of date_default_timezone_get() as a fallback (see setTestNowAndTimezone()).
*
* To clear the test instance call this method using the default
* parameter of null.
*
@@ -3841,6 +3864,27 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
*/
public static function setTestNow($testNow = null);
/**
* Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
*
* It will also align default timezone (e.g. call date_default_timezone_set()) with
* the second argument or if null, with the timezone of the given date object.
*
* To clear the test instance call this method using the default
* parameter of null.
*
* /!\ Use this method for unit tests only.
*
* @param Closure|static|string|false|null $testNow real or mock Carbon instance
*/
public static function setTestNowAndTimezone($testNow = null, $tz = null);
/**
* Resets the current time of the DateTime object to a different time.
*
@@ -3917,7 +3961,7 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
*
* @return void
*/
public static function setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator);
public static function setTranslator(TranslatorInterface $translator);
/**
* Set specified unit to new given value.
@@ -4772,14 +4816,15 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
/**
* Translate using translation string or callback available.
*
* @param string $key
* @param array $parameters
* @param string|int|float|null $number
* @param \Symfony\Component\Translation\TranslatorInterface $translator
* @param string $key
* @param array $parameters
* @param string|int|float|null $number
* @param \Symfony\Component\Translation\TranslatorInterface|null $translator
* @param bool $altNumbers
*
* @return string
*/
public function translate(string $key, array $parameters = [], $number = null, ?\Symfony\Component\Translation\TranslatorInterface $translator = null, bool $altNumbers = false): string;
public function translate(string $key, array $parameters = [], $number = null, ?TranslatorInterface $translator = null, bool $altNumbers = false): string;
/**
* Returns the alternative number for a given integer if available in the current locale.
@@ -4828,7 +4873,7 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
*
* @return string
*/
public static function translateWith(\Symfony\Component\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null): string;
public static function translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null): string;
/**
* Format as ->format() do (using date replacements patterns from https://php.net/manual/en/function.date.php)
@@ -5012,8 +5057,8 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable
*
* /!\ Use this method for unit tests only.
*
* @param Closure|static|string|false|null $testNow real or mock Carbon instance
* @param Closure|null $callback
* @param Closure|static|string|false|null $testNow real or mock Carbon instance
* @param Closure|null $callback
*
* @return mixed
*/

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use Carbon\Exceptions\BadFluentConstructorException;
@@ -25,6 +26,8 @@ use Carbon\Traits\Mixin;
use Carbon\Traits\Options;
use Closure;
use DateInterval;
use DateTimeInterface;
use DateTimeZone;
use Exception;
use ReflectionException;
use ReturnTypeWillChange;
@@ -189,14 +192,14 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
/**
* Interval spec period designators
*/
const PERIOD_PREFIX = 'P';
const PERIOD_YEARS = 'Y';
const PERIOD_MONTHS = 'M';
const PERIOD_DAYS = 'D';
const PERIOD_TIME_PREFIX = 'T';
const PERIOD_HOURS = 'H';
const PERIOD_MINUTES = 'M';
const PERIOD_SECONDS = 'S';
public const PERIOD_PREFIX = 'P';
public const PERIOD_YEARS = 'Y';
public const PERIOD_MONTHS = 'M';
public const PERIOD_DAYS = 'D';
public const PERIOD_TIME_PREFIX = 'T';
public const PERIOD_HOURS = 'H';
public const PERIOD_MINUTES = 'M';
public const PERIOD_SECONDS = 'S';
/**
* A translator to ... er ... translate stuff
@@ -253,6 +256,22 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
protected $tzName;
/**
* Set the instance's timezone from a string or object.
*
* @param \DateTimeZone|string $tzName
*
* @return static
*/
public function setTimezone($tzName)
{
$this->tzName = $tzName;
return $this;
}
/**
* @internal
*
* Set the instance's timezone from a string or object and add/subtract the offset difference.
*
* @param \DateTimeZone|string $tzName
@@ -346,7 +365,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
if ($years instanceof DateInterval) {
parent::__construct(static::getDateIntervalSpec($years));
$this->f = $years->f;
static::copyNegativeUnits($years, $this);
self::copyNegativeUnits($years, $this);
return;
}
@@ -397,7 +416,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
{
$source = self::standardizeUnit($source);
$target = self::standardizeUnit($target);
$factors = static::getFlipCascadeFactors();
$factors = self::getFlipCascadeFactors();
if (isset($factors[$source])) {
[$to, $factor] = $factors[$source];
@@ -412,6 +431,37 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
return null;
}
/**
* Returns the factor for a given source-to-target couple if set,
* else try to find the appropriate constant as the factor, such as Carbon::DAYS_PER_WEEK.
*
* @param string $source
* @param string $target
*
* @return int|null
*/
public static function getFactorWithDefault($source, $target)
{
$factor = self::getFactor($source, $target);
if ($factor) {
return $factor;
}
static $defaults = [
'month' => ['year' => Carbon::MONTHS_PER_YEAR],
'week' => ['month' => Carbon::WEEKS_PER_MONTH],
'day' => ['week' => Carbon::DAYS_PER_WEEK],
'hour' => ['day' => Carbon::HOURS_PER_DAY],
'minute' => ['hour' => Carbon::MINUTES_PER_HOUR],
'second' => ['minute' => Carbon::SECONDS_PER_MINUTE],
'millisecond' => ['second' => Carbon::MILLISECONDS_PER_SECOND],
'microsecond' => ['millisecond' => Carbon::MICROSECONDS_PER_MILLISECOND],
];
return $defaults[$source][$target] ?? null;
}
/**
* Returns current config for days per week.
*
@@ -504,10 +554,10 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
* echo Carboninterval::createFromFormat('H:i', '1:30');
* ```
*
* @param string $format Format of the $interval input string
* @param string $interval Input string to convert into an interval
* @param string $format Format of the $interval input string
* @param string|null $interval Input string to convert into an interval
*
* @throws Exception when the $interval cannot be parsed as an interval.
* @throws \Carbon\Exceptions\ParseErrorException when the $interval cannot be parsed as an interval.
*
* @return static
*/
@@ -848,10 +898,10 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
}
if ($interval instanceof self && is_a($className, self::class, true)) {
static::copyStep($interval, $instance);
self::copyStep($interval, $instance);
}
static::copyNegativeUnits($interval, $instance);
self::copyNegativeUnits($interval, $instance);
return $instance;
}
@@ -1358,7 +1408,11 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
$altNumbers = false;
$aUnit = false;
$minimumUnit = 's';
$skip = [];
extract($this->getForHumansInitialVariables($syntax, $short));
$skip = array_filter((array) $skip, static function ($value) {
return \is_string($value) && $value !== '';
});
if ($syntax === null) {
$syntax = CarbonInterface::DIFF_ABSOLUTE;
@@ -1421,7 +1475,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
':optional-space' => $optionalSpace,
];
return [$syntax, $short, $parts, $options, $join, $aUnit, $altNumbers, $interpolations, $minimumUnit];
return [$syntax, $short, $parts, $options, $join, $aUnit, $altNumbers, $interpolations, $minimumUnit, $skip];
}
protected static function getRoundingMethodFromOptions(int $options): ?string
@@ -1525,6 +1579,9 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
* - 'short' entry (see below)
* - 'parts' entry (see below)
* - 'options' entry (see below)
* - 'skip' entry, list of units to skip (array of strings or a single string,
* ` it can be the unit name (singular or plural) or its shortcut
* ` (y, m, w, d, h, min, s, ms, µs).
* - 'aUnit' entry, prefer "an hour" over "1 hour" if true
* - 'join' entry determines how to join multiple parts of the string
* ` - if $join is a string, it's used as a joiner glue
@@ -1551,11 +1608,12 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
*/
public function forHumans($syntax = null, $short = false, $parts = -1, $options = null)
{
[$syntax, $short, $parts, $options, $join, $aUnit, $altNumbers, $interpolations, $minimumUnit] = $this->getForHumansParameters($syntax, $short, $parts, $options);
[$syntax, $short, $parts, $options, $join, $aUnit, $altNumbers, $interpolations, $minimumUnit, $skip] = $this
->getForHumansParameters($syntax, $short, $parts, $options);
$interval = [];
$syntax = (int) ($syntax === null ? CarbonInterface::DIFF_ABSOLUTE : $syntax);
$syntax = (int) ($syntax ?? CarbonInterface::DIFF_ABSOLUTE);
$absolute = $syntax === CarbonInterface::DIFF_ABSOLUTE;
$relativeToNow = $syntax === CarbonInterface::DIFF_RELATIVE_TO_NOW;
$count = 1;
@@ -1596,8 +1654,14 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
\count($intervalValues->getNonZeroValues()) > $parts &&
($count = \count($keys = array_keys($intervalValues->getValuesSequence()))) > 1
) {
$index = min($count, $previousCount - 1) - 2;
if ($index < 0) {
break;
}
$intervalValues = $this->copy()->roundUnit(
$keys[min($count, $previousCount - 1) - 2],
$keys[$index],
1,
$method
);
@@ -1617,6 +1681,21 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
['value' => $intervalValues->microExcludeMilli, 'unit' => 'microsecond', 'unitShort' => 'µs'],
];
if (!empty($skip)) {
foreach ($diffIntervalArray as $index => &$unitData) {
$nextIndex = $index + 1;
if ($unitData['value'] &&
isset($diffIntervalArray[$nextIndex]) &&
\count(array_intersect([$unitData['unit'], $unitData['unit'].'s', $unitData['unitShort']], $skip))
) {
$diffIntervalArray[$nextIndex]['value'] += $unitData['value'] *
self::getFactorWithDefault($diffIntervalArray[$nextIndex]['unit'], $unitData['unit']);
$unitData['value'] = 0;
}
}
}
$transChoice = function ($short, $unitData) use ($absolute, $handleDeclensions, $translator, $aUnit, $altNumbers, $interpolations) {
$count = $unitData['value'];
@@ -1642,6 +1721,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
};
$fallbackUnit = ['second', 's'];
foreach ($diffIntervalArray as $diffIntervalData) {
if ($diffIntervalData['value'] > 0) {
$unit = $short ? $diffIntervalData['unitShort'] : $diffIntervalData['unit'];
@@ -1763,12 +1843,20 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
/**
* Convert the interval to a CarbonPeriod.
*
* @param array ...$params Start date, [end date or recurrences] and optional settings.
* @param DateTimeInterface|string|int ...$params Start date, [end date or recurrences] and optional settings.
*
* @return CarbonPeriod
*/
public function toPeriod(...$params)
{
if ($this->tzName) {
$tz = \is_string($this->tzName) ? new DateTimeZone($this->tzName) : $this->tzName;
if ($tz instanceof DateTimeZone) {
array_unshift($params, $tz);
}
}
return CarbonPeriod::create($this, ...$params);
}
@@ -1879,8 +1967,8 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
/**
* Add given parameters to the current interval.
*
* @param int $years
* @param int $months
* @param int $years
* @param int $months
* @param int|float $weeks
* @param int|float $days
* @param int|float $hours
@@ -1909,8 +1997,8 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
/**
* Add given parameters to the current interval.
*
* @param int $years
* @param int $months
* @param int $years
* @param int $months
* @param int|float $weeks
* @param int|float $days
* @param int|float $hours
@@ -2145,7 +2233,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
unset($originalData['days']);
$newData = $originalData;
foreach (static::getFlipCascadeFactors() as $source => [$target, $factor]) {
foreach (self::getFlipCascadeFactors() as $source => [$target, $factor]) {
foreach (['source', 'target'] as $key) {
if ($$key === 'dayz') {
$$key = 'daysExcludeWeeks';
@@ -2235,7 +2323,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface
$result = 0;
$cumulativeFactor = 0;
$unitFound = false;
$factors = static::getFlipCascadeFactors();
$factors = self::getFlipCascadeFactors();
$daysPerWeek = static::getDaysPerWeek();
$values = [

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use Carbon\Exceptions\InvalidCastException;
@@ -28,6 +29,7 @@ use DateInterval;
use DatePeriod;
use DateTime;
use DateTimeInterface;
use DateTimeZone;
use InvalidArgumentException;
use Iterator;
use JsonSerializable;
@@ -161,6 +163,8 @@ use RuntimeException;
* @method $this floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision.
* @method $this ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision.
* @method $this ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CarbonPeriod implements Iterator, Countable, JsonSerializable
{
@@ -171,17 +175,23 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
use Options;
/**
* Built-in filters.
* Built-in filter for limit by recurrences.
*
* @var string
* @var callable
*/
public const RECURRENCES_FILTER = [self::class, 'filterRecurrences'];
/**
* Built-in filter for limit to an end.
*
* @var callable
*/
public const END_DATE_FILTER = [self::class, 'filterEndDate'];
/**
* Special value which can be returned by filters to end iteration. Also a filter.
*
* @var string
* @var callable
*/
public const END_ITERATION = [self::class, 'endIteration'];
@@ -474,8 +484,8 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
$end = null;
foreach (explode('/', $iso) as $key => $part) {
if ($key === 0 && preg_match('/^R([0-9]*)$/', $part, $match)) {
$parsed = \strlen($match[1]) ? (int) $match[1] : null;
if ($key === 0 && preg_match('/^R([0-9]*|INF)$/', $part, $match)) {
$parsed = \strlen($match[1]) ? (($match[1] !== 'INF') ? (int) $match[1] : INF) : null;
} elseif ($interval === null && $parsed = CarbonInterval::make($part)) {
$interval = $part;
} elseif ($start === null && $parsed = Carbon::make($part)) {
@@ -639,7 +649,11 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
}
foreach ($arguments as $argument) {
if ($this->dateInterval === null &&
$parsedDate = null;
if ($argument instanceof DateTimeZone) {
$this->setTimezone($argument);
} elseif ($this->dateInterval === null &&
(
\is_string($argument) && preg_match(
'/^(-?\d(\d(?![\/-])|[^\d\/-]([\/-])?)*|P[T0-9].*|(?:\h*\d+(?:\.\d+)?\h*[a-z]+)+)$/i',
@@ -648,13 +662,13 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
$argument instanceof DateInterval ||
$argument instanceof Closure
) &&
$parsed = @CarbonInterval::make($argument)
$parsedInterval = @CarbonInterval::make($argument)
) {
$this->setDateInterval($parsed);
} elseif ($this->startDate === null && $parsed = Carbon::make($argument)) {
$this->setStartDate($parsed);
} elseif ($this->endDate === null && $parsed = Carbon::make($argument)) {
$this->setEndDate($parsed);
$this->setDateInterval($parsedInterval);
} elseif ($this->startDate === null && $parsedDate = $this->makeDateTime($argument)) {
$this->setStartDate($parsedDate);
} elseif ($this->endDate === null && ($parsedDate = $parsedDate ?? $this->makeDateTime($argument))) {
$this->setEndDate($parsedDate);
} elseif ($this->recurrences === null && $this->endDate === null && is_numeric($argument)) {
$this->setRecurrences($argument);
} elseif ($this->options === null && (\is_int($argument) || $argument === null)) {
@@ -1305,6 +1319,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
*
* @return bool
*/
#[ReturnTypeWillChange]
public function valid()
{
return $this->validateCurrentDate() === true;
@@ -1315,6 +1330,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
*
* @return int|null
*/
#[ReturnTypeWillChange]
public function key()
{
return $this->valid()
@@ -1327,6 +1343,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
*
* @return CarbonInterface|null
*/
#[ReturnTypeWillChange]
public function current()
{
return $this->valid()
@@ -1341,6 +1358,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
*
* @return void
*/
#[ReturnTypeWillChange]
public function next()
{
if ($this->current === null) {
@@ -1367,6 +1385,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
*
* @return void
*/
#[ReturnTypeWillChange]
public function rewind()
{
$this->key = 0;
@@ -1540,6 +1559,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
*
* @return int
*/
#[ReturnTypeWillChange]
public function count()
{
return \count($this->toArray());
@@ -1615,14 +1635,14 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
return $this->setStartDate($first, $second);
case 'sinceNow':
return $this->setStartDate(new Carbon, $first);
return $this->setStartDate(new Carbon(), $first);
case 'end':
case 'until':
return $this->setEndDate($first, $second);
case 'untilNow':
return $this->setEndDate(new Carbon, $first);
return $this->setEndDate(new Carbon(), $first);
case 'dates':
case 'between':
@@ -1689,7 +1709,30 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
}
/**
* Set the instance's timezone from a string or object and add/subtract the offset difference.
* Set the instance's timezone from a string or object and apply it to start/end.
*
* @param \DateTimeZone|string $timezone
*
* @return static
*/
public function setTimezone($timezone)
{
$this->tzName = $timezone;
$this->timezone = $timezone;
if ($this->startDate) {
$this->setStartDate($this->startDate->setTimezone($timezone));
}
if ($this->endDate) {
$this->setEndDate($this->endDate->setTimezone($timezone));
}
return $this;
}
/**
* Set the instance's timezone from a string or object and add/subtract the offset difference to start/end.
*
* @param \DateTimeZone|string $timezone
*
@@ -1700,6 +1743,14 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
$this->tzName = $timezone;
$this->timezone = $timezone;
if ($this->startDate) {
$this->setStartDate($this->startDate->shiftTimezone($timezone));
}
if ($this->endDate) {
$this->setEndDate($this->endDate->shiftTimezone($timezone));
}
return $this;
}
@@ -2130,7 +2181,10 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
*/
public function round($precision = null, $function = 'round')
{
return $this->roundWith($precision ?? (string) $this->getDateInterval(), $function);
return $this->roundWith(
$precision ?? $this->getDateInterval()->setLocalTranslator(TranslatorImmutable::get('en'))->forHumans(),
$function
);
}
/**
@@ -2362,11 +2416,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
}
// Check after the first rewind to avoid repeating the initial validation.
if ($this->validationResult !== null) {
return $this->validationResult;
}
return $this->validationResult = $this->checkFilters();
return $this->validationResult ?? ($this->validationResult = $this->checkFilters());
}
/**
@@ -2495,4 +2545,24 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable
{
return $first > $second ? [$second, $first] : [$first, $second];
}
private function makeDateTime($value): ?DateTimeInterface
{
if ($value instanceof DateTimeInterface) {
return $value;
}
if (\is_string($value)) {
$value = trim($value);
if (!preg_match('/^P[0-9T]/', $value) &&
!preg_match('/^R[0-9]/', $value) &&
preg_match('/[a-z0-9]/i', $value)
) {
return Carbon::parse($value, $this->tzName);
}
}
return null;
}
}

View File

@@ -8,12 +8,14 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use Carbon\Exceptions\InvalidCastException;
use Carbon\Exceptions\InvalidTimeZoneException;
use DateTimeInterface;
use DateTimeZone;
use Throwable;
class CarbonTimeZone extends DateTimeZone
{
@@ -198,7 +200,7 @@ class CarbonTimeZone extends DateTimeZone
// @codeCoverageIgnoreStart
try {
$offset = @$this->getOffset($date) ?: 0;
} catch (\Throwable $e) {
} catch (Throwable $e) {
$offset = 0;
}
// @codeCoverageIgnoreEnd

View File

@@ -1,5 +1,14 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Cli;
class Invoker

View File

@@ -1,9 +1,14 @@
<?php
/**
* Thanks to https://github.com/flaushi for his suggestion:
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Doctrine;
use Doctrine\DBAL\Platforms\AbstractPlatform;

View File

@@ -1,9 +1,14 @@
<?php
/**
* Thanks to https://github.com/flaushi for his suggestion:
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Doctrine;
use Doctrine\DBAL\Platforms\AbstractPlatform;
@@ -12,6 +17,8 @@ class CarbonImmutableType extends DateTimeImmutableType implements CarbonDoctrin
{
/**
* {@inheritdoc}
*
* @return string
*/
public function getName()
{
@@ -20,6 +27,8 @@ class CarbonImmutableType extends DateTimeImmutableType implements CarbonDoctrin
/**
* {@inheritdoc}
*
* @return bool
*/
public function requiresSQLCommentHint(AbstractPlatform $platform)
{

View File

@@ -1,9 +1,14 @@
<?php
/**
* Thanks to https://github.com/flaushi for his suggestion:
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Doctrine;
use Doctrine\DBAL\Platforms\AbstractPlatform;
@@ -12,6 +17,8 @@ class CarbonType extends DateTimeType implements CarbonDoctrineType
{
/**
* {@inheritdoc}
*
* @return string
*/
public function getName()
{
@@ -20,6 +27,8 @@ class CarbonType extends DateTimeType implements CarbonDoctrineType
/**
* {@inheritdoc}
*
* @return bool
*/
public function requiresSQLCommentHint(AbstractPlatform $platform)
{

View File

@@ -1,9 +1,14 @@
<?php
/**
* Thanks to https://github.com/flaushi for his suggestion:
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Doctrine;
use Carbon\Carbon;
@@ -26,11 +31,21 @@ trait CarbonTypeConverter
return Carbon::class;
}
/**
* @return string
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
$precision = ($fieldDeclaration['precision'] ?: 10) === 10
? DateTimeDefaultPrecision::get()
: $fieldDeclaration['precision'];
$precision = $fieldDeclaration['precision'] ?: 10;
if ($fieldDeclaration['secondPrecision'] ?? false) {
$precision = 0;
}
if ($precision === 10) {
$precision = DateTimeDefaultPrecision::get();
}
$type = parent::getSQLDeclaration($fieldDeclaration, $platform);
if (!$precision) {

View File

@@ -1,9 +1,14 @@
<?php
/**
* Thanks to https://github.com/flaushi for his suggestion:
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Doctrine;
class DateTimeDefaultPrecision

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use BadMethodCallException as BaseBadMethodCallException;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use BadMethodCallException as BaseBadMethodCallException;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
interface BadMethodCallException extends Exception

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
interface Exception

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
interface InvalidArgumentException extends Exception

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Carbon\CarbonInterface;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
interface RuntimeException extends Exception

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use BadMethodCallException as BaseBadMethodCallException;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use Exception;

View File

@@ -8,9 +8,11 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use Closure;
use DateTimeInterface;
use ReflectionMethod;
/**
@@ -18,208 +20,222 @@ use ReflectionMethod;
*
* <autodoc generated by `composer phpdoc`>
*
* @method bool canBeCreatedFromFormat($date, $format) Checks if the (date)time string is in a given format and valid to create a
* new instance.
* @method Carbon|false create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) Create a new Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* @method Carbon createFromDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to now.
* @method Carbon|false createFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method Carbon|false createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null) Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
* @method Carbon|false createFromLocaleFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific format and a string in a given language.
* @method Carbon|false createFromLocaleIsoFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific ISO format and a string in a given language.
* @method Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null) Create a Carbon instance from just a time. The date portion is set to today.
* @method Carbon createFromTimeString($time, $tz = null) Create a Carbon instance from a time string. The date portion is set to today.
* @method Carbon createFromTimestamp($timestamp, $tz = null) Create a Carbon instance from a timestamp and set the timezone (use default one if not specified).
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createFromTimestampMs($timestamp, $tz = null) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createFromTimestampMsUTC($timestamp) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createFromTimestampUTC($timestamp) Create a Carbon instance from an timestamp keeping the timezone to UTC.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createMidnightDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to midnight.
* @method Carbon|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) Create a new safe Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* If one of the set values is not valid, an InvalidDateException
* will be thrown.
* @method CarbonInterface createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null) Create a new Carbon instance from a specific date and time using strict validation.
* @method Carbon disableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method Carbon enableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method mixed executeWithLocale($locale, $func) Set the current locale to the given, execute the passed function, reset the locale to previous one,
* then return the result of the closure (or null if the closure was void).
* @method Carbon fromSerialized($value) Create an instance from a serialized string.
* @method void genericMacro($macro, $priority = 0) Register a custom macro.
* @method array getAvailableLocales() Returns the list of internally available locales and already loaded custom locales.
* (It will ignore custom translator dynamic loading.)
* @method Language[] getAvailableLocalesInfo() Returns list of Language object for each available locale. This object allow you to get the ISO name, native
* name, region and variant of the locale.
* @method array getDays() Get the days of the week
* @method string|null getFallbackLocale() Get the fallback locale.
* @method array getFormatsToIsoReplacements() List of replacements from date() format to isoFormat().
* @method int getHumanDiffOptions() Return default humanDiff() options (merged flags as integer).
* @method array getIsoUnits() Returns list of locale units for ISO formatting.
* @method Carbon getLastErrors() {@inheritdoc}
* @method string getLocale() Get the current translator locale.
* @method callable|null getMacro($name) Get the raw callable macro registered globally for a given name.
* @method int getMidDayAt() get midday/noon hour
* @method Closure|Carbon getTestNow() Get the Carbon instance (real or mock) to be returned when a "now"
* instance is created.
* @method string getTimeFormatByPrecision($unitPrecision) Return a format from H:i to H:i:s.u according to given unit precision.
* @method string getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null) Returns raw translation message for a given key.
* @method \Symfony\Component\Translation\TranslatorInterface getTranslator() Get the default translator instance in use.
* @method int getWeekEndsAt() Get the last day of week
* @method int getWeekStartsAt() Get the first day of week
* @method array getWeekendDays() Get weekend days
* @method bool hasFormat($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasFormatWithModifiers($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasMacro($name) Checks if macro is registered globally.
* @method bool hasRelativeKeywords($time) Determine if a time string will produce a relative date.
* @method bool hasTestNow() Determine if there is a valid test instance set. A valid test instance
* is anything that is not null.
* @method Carbon instance($date) Create a Carbon instance from a DateTime one.
* @method bool isImmutable() Returns true if the current class/instance is immutable.
* @method bool isModifiableUnit($unit) Returns true if a property can be changed via setter.
* @method bool isMutable() Returns true if the current class/instance is mutable.
* @method bool isStrictModeEnabled() Returns true if the strict mode is globally in use, false else.
* (It can be overridden in specific instances.)
* @method bool localeHasDiffOneDayWords($locale) Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
* Support is considered enabled if the 3 words are translated in the given locale.
* @method bool localeHasDiffSyntax($locale) Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasDiffTwoDayWords($locale) Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
* Support is considered enabled if the 2 words are translated in the given locale.
* @method bool localeHasPeriodSyntax($locale) Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasShortUnits($locale) Returns true if the given locale is internally supported and has short-units support.
* Support is considered enabled if either year, day or hour has a short variant translated.
* @method void macro($name, $macro) Register a custom macro.
* @method Carbon|null make($var) Make a Carbon instance from given variable if possible.
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
* and recurrences). Throw an exception for invalid format, but otherwise return null.
* @method Carbon maxValue() Create a Carbon instance for the greatest supported date.
* @method Carbon minValue() Create a Carbon instance for the lowest supported date.
* @method void mixin($mixin) Mix another object into the class.
* @method Carbon now($tz = null) Get a Carbon instance for the current date and time.
* @method Carbon parse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method Carbon parseFromLocale($time, $locale = null, $tz = null) Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
* @method string pluralUnit(string $unit) Returns standardized plural of a given singular/plural unit name (in English).
* @method Carbon|false rawCreateFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method Carbon rawParse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method Carbon resetMacros() Remove all macros and generic macros.
* @method void resetMonthsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void resetToStringFormat() Reset the format used to the default when type juggling a Carbon instance to a string
* @method void resetYearsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void serializeUsing($callback) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather transform Carbon object before the serialization.
* JSON serialize all Carbon instances using the given callback.
* @method Carbon setFallbackLocale($locale) Set the fallback locale.
* @method Carbon setHumanDiffOptions($humanDiffOptions) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method bool setLocale($locale) Set the current translator locale and indicate if the source locale file exists.
* Pass 'auto' as locale to use closest language from the current LC_TIME locale.
* @method void setMidDayAt($hour) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider mid-day is always 12pm, then if you need to test if it's an other
* hour, test it explicitly:
* $date->format('G') == 13
* or to set explicitly to a given hour:
* $date->setTime(13, 0, 0, 0)
* Set midday/noon hour
* @method Carbon setTestNow($testNow = null) Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
* Note the timezone parameter was left out of the examples above and
* has no affect as the mock value will be returned regardless of its value.
* To clear the test instance call this method using the default
* parameter of null.
* /!\ Use this method for unit tests only.
* @method void setToStringFormat($format) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and
* use other method or custom format passed to format() method if you need to dump an other string
* format.
* Set the default format used when type juggling a Carbon instance to a string
* @method void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator) Set the default translator instance to use.
* @method Carbon setUtf8($utf8) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use UTF-8 language packages on every machine.
* Set if UTF8 will be used for localized date/time.
* @method void setWeekEndsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek
* or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the
* start of week according to current locale selected and implicitly the end of week.
* Set the last day of week
* @method void setWeekStartsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the
* 'first_day_of_week' locale setting to change the start of week according to current locale
* selected and implicitly the end of week.
* Set the first day of week
* @method void setWeekendDays($days) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider week-end is always saturday and sunday, and if you have some custom
* week-end days to handle, give to those days an other name and create a macro for them:
* ```
* Carbon::macro('isDayOff', function ($date) {
* return $date->isSunday() || $date->isMonday();
* });
* Carbon::macro('isNotDayOff', function ($date) {
* return !$date->isDayOff();
* });
* if ($someDate->isDayOff()) ...
* if ($someDate->isNotDayOff()) ...
* // Add 5 not-off days
* $count = 5;
* while ($someDate->isDayOff() || ($count-- > 0)) {
* $someDate->addDay();
* }
* ```
* Set weekend days
* @method bool shouldOverflowMonths() Get the month overflow global behavior (can be overridden in specific instances).
* @method bool shouldOverflowYears() Get the month overflow global behavior (can be overridden in specific instances).
* @method string singularUnit(string $unit) Returns standardized singular of a given singular/plural unit name (in English).
* @method Carbon today($tz = null) Create a Carbon instance for today.
* @method Carbon tomorrow($tz = null) Create a Carbon instance for tomorrow.
* @method string translateTimeString($timeString, $from = null, $to = null, $mode = CarbonInterface::TRANSLATE_ALL) Translate a time string from a locale to an other.
* @method string translateWith(\Symfony\Component\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null) Translate using translation string or callback available.
* @method void useMonthsOverflow($monthsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method Carbon useStrictMode($strictModeEnabled = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method void useYearsOverflow($yearsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method mixed withTestNow($testNow = null, $callback = null) Temporarily sets a static date to be used within the callback.
* Using setTestNow to set the date, executing the callback, then
* clearing the test instance.
* /!\ Use this method for unit tests only.
* @method Carbon yesterday($tz = null) Create a Carbon instance for yesterday.
* @method bool canBeCreatedFromFormat($date, $format) Checks if the (date)time string is in a given format and valid to create a
* new instance.
* @method Carbon|false create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) Create a new Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* @method Carbon createFromDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to now.
* @method Carbon|false createFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method Carbon|false createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null) Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
* @method Carbon|false createFromLocaleFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific format and a string in a given language.
* @method Carbon|false createFromLocaleIsoFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific ISO format and a string in a given language.
* @method Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null) Create a Carbon instance from just a time. The date portion is set to today.
* @method Carbon createFromTimeString($time, $tz = null) Create a Carbon instance from a time string. The date portion is set to today.
* @method Carbon createFromTimestamp($timestamp, $tz = null) Create a Carbon instance from a timestamp and set the timezone (use default one if not specified).
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createFromTimestampMs($timestamp, $tz = null) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createFromTimestampMsUTC($timestamp) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createFromTimestampUTC($timestamp) Create a Carbon instance from an timestamp keeping the timezone to UTC.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method Carbon createMidnightDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to midnight.
* @method Carbon|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) Create a new safe Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* If one of the set values is not valid, an InvalidDateException
* will be thrown.
* @method CarbonInterface createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null) Create a new Carbon instance from a specific date and time using strict validation.
* @method Carbon disableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method Carbon enableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method mixed executeWithLocale($locale, $func) Set the current locale to the given, execute the passed function, reset the locale to previous one,
* then return the result of the closure (or null if the closure was void).
* @method Carbon fromSerialized($value) Create an instance from a serialized string.
* @method void genericMacro($macro, $priority = 0) Register a custom macro.
* @method array getAvailableLocales() Returns the list of internally available locales and already loaded custom locales.
* (It will ignore custom translator dynamic loading.)
* @method Language[] getAvailableLocalesInfo() Returns list of Language object for each available locale. This object allow you to get the ISO name, native
* name, region and variant of the locale.
* @method array getDays() Get the days of the week
* @method string|null getFallbackLocale() Get the fallback locale.
* @method array getFormatsToIsoReplacements() List of replacements from date() format to isoFormat().
* @method int getHumanDiffOptions() Return default humanDiff() options (merged flags as integer).
* @method array getIsoUnits() Returns list of locale units for ISO formatting.
* @method array getLastErrors() {@inheritdoc}
* @method string getLocale() Get the current translator locale.
* @method callable|null getMacro($name) Get the raw callable macro registered globally for a given name.
* @method int getMidDayAt() get midday/noon hour
* @method Closure|Carbon getTestNow() Get the Carbon instance (real or mock) to be returned when a "now"
* instance is created.
* @method string getTimeFormatByPrecision($unitPrecision) Return a format from H:i to H:i:s.u according to given unit precision.
* @method string getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null) Returns raw translation message for a given key.
* @method \Symfony\Component\Translation\TranslatorInterface getTranslator() Get the default translator instance in use.
* @method int getWeekEndsAt() Get the last day of week
* @method int getWeekStartsAt() Get the first day of week
* @method array getWeekendDays() Get weekend days
* @method bool hasFormat($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasFormatWithModifiers($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasMacro($name) Checks if macro is registered globally.
* @method bool hasRelativeKeywords($time) Determine if a time string will produce a relative date.
* @method bool hasTestNow() Determine if there is a valid test instance set. A valid test instance
* is anything that is not null.
* @method Carbon instance($date) Create a Carbon instance from a DateTime one.
* @method bool isImmutable() Returns true if the current class/instance is immutable.
* @method bool isModifiableUnit($unit) Returns true if a property can be changed via setter.
* @method bool isMutable() Returns true if the current class/instance is mutable.
* @method bool isStrictModeEnabled() Returns true if the strict mode is globally in use, false else.
* (It can be overridden in specific instances.)
* @method bool localeHasDiffOneDayWords($locale) Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
* Support is considered enabled if the 3 words are translated in the given locale.
* @method bool localeHasDiffSyntax($locale) Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasDiffTwoDayWords($locale) Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
* Support is considered enabled if the 2 words are translated in the given locale.
* @method bool localeHasPeriodSyntax($locale) Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasShortUnits($locale) Returns true if the given locale is internally supported and has short-units support.
* Support is considered enabled if either year, day or hour has a short variant translated.
* @method void macro($name, $macro) Register a custom macro.
* @method Carbon|null make($var) Make a Carbon instance from given variable if possible.
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
* and recurrences). Throw an exception for invalid format, but otherwise return null.
* @method Carbon maxValue() Create a Carbon instance for the greatest supported date.
* @method Carbon minValue() Create a Carbon instance for the lowest supported date.
* @method void mixin($mixin) Mix another object into the class.
* @method Carbon now($tz = null) Get a Carbon instance for the current date and time.
* @method Carbon parse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method Carbon parseFromLocale($time, $locale = null, $tz = null) Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
* @method string pluralUnit(string $unit) Returns standardized plural of a given singular/plural unit name (in English).
* @method Carbon|false rawCreateFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method Carbon rawParse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method Carbon resetMacros() Remove all macros and generic macros.
* @method void resetMonthsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void resetToStringFormat() Reset the format used to the default when type juggling a Carbon instance to a string
* @method void resetYearsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void serializeUsing($callback) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather transform Carbon object before the serialization.
* JSON serialize all Carbon instances using the given callback.
* @method Carbon setFallbackLocale($locale) Set the fallback locale.
* @method Carbon setHumanDiffOptions($humanDiffOptions) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method bool setLocale($locale) Set the current translator locale and indicate if the source locale file exists.
* Pass 'auto' as locale to use closest language from the current LC_TIME locale.
* @method void setMidDayAt($hour) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider mid-day is always 12pm, then if you need to test if it's an other
* hour, test it explicitly:
* $date->format('G') == 13
* or to set explicitly to a given hour:
* $date->setTime(13, 0, 0, 0)
* Set midday/noon hour
* @method Carbon setTestNow($testNow = null) Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
* Note the timezone parameter was left out of the examples above and
* has no affect as the mock value will be returned regardless of its value.
* Only the moment is mocked with setTestNow(), the timezone will still be the one passed
* as parameter of date_default_timezone_get() as a fallback (see setTestNowAndTimezone()).
* To clear the test instance call this method using the default
* parameter of null.
* /!\ Use this method for unit tests only.
* @method Carbon setTestNowAndTimezone($testNow = null, $tz = null) Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
* It will also align default timezone (e.g. call date_default_timezone_set()) with
* the second argument or if null, with the timezone of the given date object.
* To clear the test instance call this method using the default
* parameter of null.
* /!\ Use this method for unit tests only.
* @method void setToStringFormat($format) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and
* use other method or custom format passed to format() method if you need to dump an other string
* format.
* Set the default format used when type juggling a Carbon instance to a string
* @method void setTranslator(TranslatorInterface $translator) Set the default translator instance to use.
* @method Carbon setUtf8($utf8) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use UTF-8 language packages on every machine.
* Set if UTF8 will be used for localized date/time.
* @method void setWeekEndsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek
* or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the
* start of week according to current locale selected and implicitly the end of week.
* Set the last day of week
* @method void setWeekStartsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the
* 'first_day_of_week' locale setting to change the start of week according to current locale
* selected and implicitly the end of week.
* Set the first day of week
* @method void setWeekendDays($days) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider week-end is always saturday and sunday, and if you have some custom
* week-end days to handle, give to those days an other name and create a macro for them:
* ```
* Carbon::macro('isDayOff', function ($date) {
* return $date->isSunday() || $date->isMonday();
* });
* Carbon::macro('isNotDayOff', function ($date) {
* return !$date->isDayOff();
* });
* if ($someDate->isDayOff()) ...
* if ($someDate->isNotDayOff()) ...
* // Add 5 not-off days
* $count = 5;
* while ($someDate->isDayOff() || ($count-- > 0)) {
* $someDate->addDay();
* }
* ```
* Set weekend days
* @method bool shouldOverflowMonths() Get the month overflow global behavior (can be overridden in specific instances).
* @method bool shouldOverflowYears() Get the month overflow global behavior (can be overridden in specific instances).
* @method string singularUnit(string $unit) Returns standardized singular of a given singular/plural unit name (in English).
* @method Carbon today($tz = null) Create a Carbon instance for today.
* @method Carbon tomorrow($tz = null) Create a Carbon instance for tomorrow.
* @method string translateTimeString($timeString, $from = null, $to = null, $mode = CarbonInterface::TRANSLATE_ALL) Translate a time string from a locale to an other.
* @method string translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null) Translate using translation string or callback available.
* @method void useMonthsOverflow($monthsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method Carbon useStrictMode($strictModeEnabled = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method void useYearsOverflow($yearsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method mixed withTestNow($testNow = null, $callback = null) Temporarily sets a static date to be used within the callback.
* Using setTestNow to set the date, executing the callback, then
* clearing the test instance.
* /!\ Use this method for unit tests only.
* @method Carbon yesterday($tz = null) Create a Carbon instance for yesterday.
*
* </autodoc>
*/
@@ -289,7 +305,13 @@ class Factory
return \in_array($parameter->getName(), ['tz', 'timezone'], true);
});
if (\count($tzParameters)) {
if (isset($arguments[0]) && \in_array($name, ['instance', 'make', 'create', 'parse'], true)) {
if ($arguments[0] instanceof DateTimeInterface) {
$settings['innerTimezone'] = $settings['timezone'];
} elseif (\is_string($arguments[0]) && date_parse($arguments[0])['is_localtime']) {
unset($settings['timezone'], $settings['innerTimezone']);
}
} elseif (\count($tzParameters)) {
array_splice($arguments, key($tzParameters), 0, [$settings['timezone']]);
unset($settings['timezone']);
}

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use Closure;
@@ -17,208 +18,222 @@ use Closure;
*
* <autodoc generated by `composer phpdoc`>
*
* @method bool canBeCreatedFromFormat($date, $format) Checks if the (date)time string is in a given format and valid to create a
* new instance.
* @method CarbonImmutable|false create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) Create a new Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* @method CarbonImmutable createFromDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to now.
* @method CarbonImmutable|false createFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method CarbonImmutable|false createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null) Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
* @method CarbonImmutable|false createFromLocaleFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific format and a string in a given language.
* @method CarbonImmutable|false createFromLocaleIsoFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific ISO format and a string in a given language.
* @method CarbonImmutable createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null) Create a Carbon instance from just a time. The date portion is set to today.
* @method CarbonImmutable createFromTimeString($time, $tz = null) Create a Carbon instance from a time string. The date portion is set to today.
* @method CarbonImmutable createFromTimestamp($timestamp, $tz = null) Create a Carbon instance from a timestamp and set the timezone (use default one if not specified).
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createFromTimestampMs($timestamp, $tz = null) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createFromTimestampMsUTC($timestamp) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createFromTimestampUTC($timestamp) Create a Carbon instance from an timestamp keeping the timezone to UTC.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createMidnightDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to midnight.
* @method CarbonImmutable|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) Create a new safe Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* If one of the set values is not valid, an InvalidDateException
* will be thrown.
* @method CarbonInterface createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null) Create a new Carbon instance from a specific date and time using strict validation.
* @method CarbonImmutable disableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method CarbonImmutable enableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method mixed executeWithLocale($locale, $func) Set the current locale to the given, execute the passed function, reset the locale to previous one,
* then return the result of the closure (or null if the closure was void).
* @method CarbonImmutable fromSerialized($value) Create an instance from a serialized string.
* @method void genericMacro($macro, $priority = 0) Register a custom macro.
* @method array getAvailableLocales() Returns the list of internally available locales and already loaded custom locales.
* (It will ignore custom translator dynamic loading.)
* @method Language[] getAvailableLocalesInfo() Returns list of Language object for each available locale. This object allow you to get the ISO name, native
* name, region and variant of the locale.
* @method array getDays() Get the days of the week
* @method string|null getFallbackLocale() Get the fallback locale.
* @method array getFormatsToIsoReplacements() List of replacements from date() format to isoFormat().
* @method int getHumanDiffOptions() Return default humanDiff() options (merged flags as integer).
* @method array getIsoUnits() Returns list of locale units for ISO formatting.
* @method CarbonImmutable getLastErrors() {@inheritdoc}
* @method string getLocale() Get the current translator locale.
* @method callable|null getMacro($name) Get the raw callable macro registered globally for a given name.
* @method int getMidDayAt() get midday/noon hour
* @method Closure|CarbonImmutable getTestNow() Get the Carbon instance (real or mock) to be returned when a "now"
* instance is created.
* @method string getTimeFormatByPrecision($unitPrecision) Return a format from H:i to H:i:s.u according to given unit precision.
* @method string getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null) Returns raw translation message for a given key.
* @method \Symfony\Component\Translation\TranslatorInterface getTranslator() Get the default translator instance in use.
* @method int getWeekEndsAt() Get the last day of week
* @method int getWeekStartsAt() Get the first day of week
* @method array getWeekendDays() Get weekend days
* @method bool hasFormat($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasFormatWithModifiers($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasMacro($name) Checks if macro is registered globally.
* @method bool hasRelativeKeywords($time) Determine if a time string will produce a relative date.
* @method bool hasTestNow() Determine if there is a valid test instance set. A valid test instance
* is anything that is not null.
* @method CarbonImmutable instance($date) Create a Carbon instance from a DateTime one.
* @method bool isImmutable() Returns true if the current class/instance is immutable.
* @method bool isModifiableUnit($unit) Returns true if a property can be changed via setter.
* @method bool isMutable() Returns true if the current class/instance is mutable.
* @method bool isStrictModeEnabled() Returns true if the strict mode is globally in use, false else.
* (It can be overridden in specific instances.)
* @method bool localeHasDiffOneDayWords($locale) Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
* Support is considered enabled if the 3 words are translated in the given locale.
* @method bool localeHasDiffSyntax($locale) Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasDiffTwoDayWords($locale) Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
* Support is considered enabled if the 2 words are translated in the given locale.
* @method bool localeHasPeriodSyntax($locale) Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasShortUnits($locale) Returns true if the given locale is internally supported and has short-units support.
* Support is considered enabled if either year, day or hour has a short variant translated.
* @method void macro($name, $macro) Register a custom macro.
* @method CarbonImmutable|null make($var) Make a Carbon instance from given variable if possible.
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
* and recurrences). Throw an exception for invalid format, but otherwise return null.
* @method CarbonImmutable maxValue() Create a Carbon instance for the greatest supported date.
* @method CarbonImmutable minValue() Create a Carbon instance for the lowest supported date.
* @method void mixin($mixin) Mix another object into the class.
* @method CarbonImmutable now($tz = null) Get a Carbon instance for the current date and time.
* @method CarbonImmutable parse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method CarbonImmutable parseFromLocale($time, $locale = null, $tz = null) Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
* @method string pluralUnit(string $unit) Returns standardized plural of a given singular/plural unit name (in English).
* @method CarbonImmutable|false rawCreateFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method CarbonImmutable rawParse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method CarbonImmutable resetMacros() Remove all macros and generic macros.
* @method void resetMonthsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void resetToStringFormat() Reset the format used to the default when type juggling a Carbon instance to a string
* @method void resetYearsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void serializeUsing($callback) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather transform Carbon object before the serialization.
* JSON serialize all Carbon instances using the given callback.
* @method CarbonImmutable setFallbackLocale($locale) Set the fallback locale.
* @method CarbonImmutable setHumanDiffOptions($humanDiffOptions) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method bool setLocale($locale) Set the current translator locale and indicate if the source locale file exists.
* Pass 'auto' as locale to use closest language from the current LC_TIME locale.
* @method void setMidDayAt($hour) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider mid-day is always 12pm, then if you need to test if it's an other
* hour, test it explicitly:
* $date->format('G') == 13
* or to set explicitly to a given hour:
* $date->setTime(13, 0, 0, 0)
* Set midday/noon hour
* @method CarbonImmutable setTestNow($testNow = null) Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
* Note the timezone parameter was left out of the examples above and
* has no affect as the mock value will be returned regardless of its value.
* To clear the test instance call this method using the default
* parameter of null.
* /!\ Use this method for unit tests only.
* @method void setToStringFormat($format) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and
* use other method or custom format passed to format() method if you need to dump an other string
* format.
* Set the default format used when type juggling a Carbon instance to a string
* @method void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator) Set the default translator instance to use.
* @method CarbonImmutable setUtf8($utf8) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use UTF-8 language packages on every machine.
* Set if UTF8 will be used for localized date/time.
* @method void setWeekEndsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek
* or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the
* start of week according to current locale selected and implicitly the end of week.
* Set the last day of week
* @method void setWeekStartsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the
* 'first_day_of_week' locale setting to change the start of week according to current locale
* selected and implicitly the end of week.
* Set the first day of week
* @method void setWeekendDays($days) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider week-end is always saturday and sunday, and if you have some custom
* week-end days to handle, give to those days an other name and create a macro for them:
* ```
* Carbon::macro('isDayOff', function ($date) {
* return $date->isSunday() || $date->isMonday();
* });
* Carbon::macro('isNotDayOff', function ($date) {
* return !$date->isDayOff();
* });
* if ($someDate->isDayOff()) ...
* if ($someDate->isNotDayOff()) ...
* // Add 5 not-off days
* $count = 5;
* while ($someDate->isDayOff() || ($count-- > 0)) {
* $someDate->addDay();
* }
* ```
* Set weekend days
* @method bool shouldOverflowMonths() Get the month overflow global behavior (can be overridden in specific instances).
* @method bool shouldOverflowYears() Get the month overflow global behavior (can be overridden in specific instances).
* @method string singularUnit(string $unit) Returns standardized singular of a given singular/plural unit name (in English).
* @method CarbonImmutable today($tz = null) Create a Carbon instance for today.
* @method CarbonImmutable tomorrow($tz = null) Create a Carbon instance for tomorrow.
* @method string translateTimeString($timeString, $from = null, $to = null, $mode = CarbonInterface::TRANSLATE_ALL) Translate a time string from a locale to an other.
* @method string translateWith(\Symfony\Component\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null) Translate using translation string or callback available.
* @method void useMonthsOverflow($monthsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method CarbonImmutable useStrictMode($strictModeEnabled = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method void useYearsOverflow($yearsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method mixed withTestNow($testNow = null, $callback = null) Temporarily sets a static date to be used within the callback.
* Using setTestNow to set the date, executing the callback, then
* clearing the test instance.
* /!\ Use this method for unit tests only.
* @method CarbonImmutable yesterday($tz = null) Create a Carbon instance for yesterday.
* @method bool canBeCreatedFromFormat($date, $format) Checks if the (date)time string is in a given format and valid to create a
* new instance.
* @method CarbonImmutable|false create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) Create a new Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* @method CarbonImmutable createFromDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to now.
* @method CarbonImmutable|false createFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method CarbonImmutable|false createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null) Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
* @method CarbonImmutable|false createFromLocaleFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific format and a string in a given language.
* @method CarbonImmutable|false createFromLocaleIsoFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific ISO format and a string in a given language.
* @method CarbonImmutable createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null) Create a Carbon instance from just a time. The date portion is set to today.
* @method CarbonImmutable createFromTimeString($time, $tz = null) Create a Carbon instance from a time string. The date portion is set to today.
* @method CarbonImmutable createFromTimestamp($timestamp, $tz = null) Create a Carbon instance from a timestamp and set the timezone (use default one if not specified).
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createFromTimestampMs($timestamp, $tz = null) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createFromTimestampMsUTC($timestamp) Create a Carbon instance from a timestamp in milliseconds.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createFromTimestampUTC($timestamp) Create a Carbon instance from an timestamp keeping the timezone to UTC.
* Timestamp input can be given as int, float or a string containing one or more numbers.
* @method CarbonImmutable createMidnightDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to midnight.
* @method CarbonImmutable|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) Create a new safe Carbon instance from a specific date and time.
* If any of $year, $month or $day are set to null their now() values will
* be used.
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
* If one of the set values is not valid, an InvalidDateException
* will be thrown.
* @method CarbonInterface createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null) Create a new Carbon instance from a specific date and time using strict validation.
* @method CarbonImmutable disableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method CarbonImmutable enableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method mixed executeWithLocale($locale, $func) Set the current locale to the given, execute the passed function, reset the locale to previous one,
* then return the result of the closure (or null if the closure was void).
* @method CarbonImmutable fromSerialized($value) Create an instance from a serialized string.
* @method void genericMacro($macro, $priority = 0) Register a custom macro.
* @method array getAvailableLocales() Returns the list of internally available locales and already loaded custom locales.
* (It will ignore custom translator dynamic loading.)
* @method Language[] getAvailableLocalesInfo() Returns list of Language object for each available locale. This object allow you to get the ISO name, native
* name, region and variant of the locale.
* @method array getDays() Get the days of the week
* @method string|null getFallbackLocale() Get the fallback locale.
* @method array getFormatsToIsoReplacements() List of replacements from date() format to isoFormat().
* @method int getHumanDiffOptions() Return default humanDiff() options (merged flags as integer).
* @method array getIsoUnits() Returns list of locale units for ISO formatting.
* @method array getLastErrors() {@inheritdoc}
* @method string getLocale() Get the current translator locale.
* @method callable|null getMacro($name) Get the raw callable macro registered globally for a given name.
* @method int getMidDayAt() get midday/noon hour
* @method Closure|CarbonImmutable getTestNow() Get the Carbon instance (real or mock) to be returned when a "now"
* instance is created.
* @method string getTimeFormatByPrecision($unitPrecision) Return a format from H:i to H:i:s.u according to given unit precision.
* @method string getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null) Returns raw translation message for a given key.
* @method \Symfony\Component\Translation\TranslatorInterface getTranslator() Get the default translator instance in use.
* @method int getWeekEndsAt() Get the last day of week
* @method int getWeekStartsAt() Get the first day of week
* @method array getWeekendDays() Get weekend days
* @method bool hasFormat($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasFormatWithModifiers($date, $format) Checks if the (date)time string is in a given format.
* @method bool hasMacro($name) Checks if macro is registered globally.
* @method bool hasRelativeKeywords($time) Determine if a time string will produce a relative date.
* @method bool hasTestNow() Determine if there is a valid test instance set. A valid test instance
* is anything that is not null.
* @method CarbonImmutable instance($date) Create a Carbon instance from a DateTime one.
* @method bool isImmutable() Returns true if the current class/instance is immutable.
* @method bool isModifiableUnit($unit) Returns true if a property can be changed via setter.
* @method bool isMutable() Returns true if the current class/instance is mutable.
* @method bool isStrictModeEnabled() Returns true if the strict mode is globally in use, false else.
* (It can be overridden in specific instances.)
* @method bool localeHasDiffOneDayWords($locale) Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
* Support is considered enabled if the 3 words are translated in the given locale.
* @method bool localeHasDiffSyntax($locale) Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasDiffTwoDayWords($locale) Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
* Support is considered enabled if the 2 words are translated in the given locale.
* @method bool localeHasPeriodSyntax($locale) Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
* Support is considered enabled if the 4 sentences are translated in the given locale.
* @method bool localeHasShortUnits($locale) Returns true if the given locale is internally supported and has short-units support.
* Support is considered enabled if either year, day or hour has a short variant translated.
* @method void macro($name, $macro) Register a custom macro.
* @method CarbonImmutable|null make($var) Make a Carbon instance from given variable if possible.
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
* and recurrences). Throw an exception for invalid format, but otherwise return null.
* @method CarbonImmutable maxValue() Create a Carbon instance for the greatest supported date.
* @method CarbonImmutable minValue() Create a Carbon instance for the lowest supported date.
* @method void mixin($mixin) Mix another object into the class.
* @method CarbonImmutable now($tz = null) Get a Carbon instance for the current date and time.
* @method CarbonImmutable parse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method CarbonImmutable parseFromLocale($time, $locale = null, $tz = null) Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
* @method string pluralUnit(string $unit) Returns standardized plural of a given singular/plural unit name (in English).
* @method CarbonImmutable|false rawCreateFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
* @method CarbonImmutable rawParse($time = null, $tz = null) Create a carbon instance from a string.
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
* @method CarbonImmutable resetMacros() Remove all macros and generic macros.
* @method void resetMonthsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void resetToStringFormat() Reset the format used to the default when type juggling a Carbon instance to a string
* @method void resetYearsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method void serializeUsing($callback) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather transform Carbon object before the serialization.
* JSON serialize all Carbon instances using the given callback.
* @method CarbonImmutable setFallbackLocale($locale) Set the fallback locale.
* @method CarbonImmutable setHumanDiffOptions($humanDiffOptions) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method bool setLocale($locale) Set the current translator locale and indicate if the source locale file exists.
* Pass 'auto' as locale to use closest language from the current LC_TIME locale.
* @method void setMidDayAt($hour) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider mid-day is always 12pm, then if you need to test if it's an other
* hour, test it explicitly:
* $date->format('G') == 13
* or to set explicitly to a given hour:
* $date->setTime(13, 0, 0, 0)
* Set midday/noon hour
* @method CarbonImmutable setTestNow($testNow = null) Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
* Note the timezone parameter was left out of the examples above and
* has no affect as the mock value will be returned regardless of its value.
* Only the moment is mocked with setTestNow(), the timezone will still be the one passed
* as parameter of date_default_timezone_get() as a fallback (see setTestNowAndTimezone()).
* To clear the test instance call this method using the default
* parameter of null.
* /!\ Use this method for unit tests only.
* @method CarbonImmutable setTestNowAndTimezone($testNow = null, $tz = null) Set a Carbon instance (real or mock) to be returned when a "now"
* instance is created. The provided instance will be returned
* specifically under the following conditions:
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
* - When a string containing the desired time is passed to Carbon::parse().
* It will also align default timezone (e.g. call date_default_timezone_set()) with
* the second argument or if null, with the timezone of the given date object.
* To clear the test instance call this method using the default
* parameter of null.
* /!\ Use this method for unit tests only.
* @method void setToStringFormat($format) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and
* use other method or custom format passed to format() method if you need to dump an other string
* format.
* Set the default format used when type juggling a Carbon instance to a string
* @method void setTranslator(TranslatorInterface $translator) Set the default translator instance to use.
* @method CarbonImmutable setUtf8($utf8) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use UTF-8 language packages on every machine.
* Set if UTF8 will be used for localized date/time.
* @method void setWeekEndsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek
* or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the
* start of week according to current locale selected and implicitly the end of week.
* Set the last day of week
* @method void setWeekStartsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the
* 'first_day_of_week' locale setting to change the start of week according to current locale
* selected and implicitly the end of week.
* Set the first day of week
* @method void setWeekendDays($days) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather consider week-end is always saturday and sunday, and if you have some custom
* week-end days to handle, give to those days an other name and create a macro for them:
* ```
* Carbon::macro('isDayOff', function ($date) {
* return $date->isSunday() || $date->isMonday();
* });
* Carbon::macro('isNotDayOff', function ($date) {
* return !$date->isDayOff();
* });
* if ($someDate->isDayOff()) ...
* if ($someDate->isNotDayOff()) ...
* // Add 5 not-off days
* $count = 5;
* while ($someDate->isDayOff() || ($count-- > 0)) {
* $someDate->addDay();
* }
* ```
* Set weekend days
* @method bool shouldOverflowMonths() Get the month overflow global behavior (can be overridden in specific instances).
* @method bool shouldOverflowYears() Get the month overflow global behavior (can be overridden in specific instances).
* @method string singularUnit(string $unit) Returns standardized singular of a given singular/plural unit name (in English).
* @method CarbonImmutable today($tz = null) Create a Carbon instance for today.
* @method CarbonImmutable tomorrow($tz = null) Create a Carbon instance for tomorrow.
* @method string translateTimeString($timeString, $from = null, $to = null, $mode = CarbonInterface::TRANSLATE_ALL) Translate a time string from a locale to an other.
* @method string translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null) Translate using translation string or callback available.
* @method void useMonthsOverflow($monthsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method CarbonImmutable useStrictMode($strictModeEnabled = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* @method void useYearsOverflow($yearsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
* You should rather use the ->settings() method.
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
* @method mixed withTestNow($testNow = null, $callback = null) Temporarily sets a static date to be used within the callback.
* Using setTestNow to set the date, executing the callback, then
* clearing the test instance.
* /!\ Use this method for unit tests only.
* @method CarbonImmutable yesterday($tz = null) Create a Carbon instance for yesterday.
*
* </autodoc>
*/

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/af.php', [
'meridiem' => ['v', 'n'],
'weekdays' => ['Sondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrydag', 'Saterdag'],

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/af.php';

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['a.g', 'a.k'],
'weekdays' => ['tsuʔntsɨ', 'tsuʔukpà', 'tsuʔughɔe', 'tsuʔutɔ̀mlò', 'tsuʔumè', 'tsuʔughɨ̂m', 'tsuʔndzɨkɔʔɔ'],

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ar.php', [
]);

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ar.php', [
]);

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ar.php', [
]);

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ar.php', [
]);

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ar.php', [
]);

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ar.php', [
]);

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ar.php', [
]);

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ar.php', [
]);

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ar.php', [
]);

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['icheheavo', 'ichamthi'],
'weekdays' => ['Jumapili', 'Jumatatu', 'Jumanne', 'Jumatano', 'Alhamisi', 'Ijumaa', 'Jumamosi'],

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/az.php', [
'weekdays' => ['базар', 'базар ертәси', 'чәршәнбә ахшамы', 'чәршәнбә', 'ҹүмә ахшамы', 'ҹүмә', 'шәнбә'],
'weekdays_short' => ['Б.', 'Б.Е.', 'Ч.А.', 'Ч.', 'Ҹ.А.', 'Ҹ.', 'Ш.'],

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/az.php', [
'meridiem' => ['a', 'p'],
'weekdays' => ['bazar', 'bazar ertəsi', 'çərşənbə axşamı', 'çərşənbə', 'cümə axşamı', 'cümə', 'şənbə'],

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['I bikɛ̂glà', 'I ɓugajɔp'],
'weekdays' => ['ŋgwà nɔ̂y', 'ŋgwà njaŋgumba', 'ŋgwà ûm', 'ŋgwà ŋgê', 'ŋgwà mbɔk', 'ŋgwà kɔɔ', 'ŋgwà jôn'],

View File

@@ -8,9 +8,14 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
// @codeCoverageIgnoreStart
use Carbon\CarbonInterface;
use Symfony\Component\Translation\PluralizationRules;
if (class_exists('Symfony\\Component\\Translation\\PluralizationRules')) {
\Symfony\Component\Translation\PluralizationRules::set(function ($number) {
PluralizationRules::set(function ($number) {
return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
}, 'be');
}
@@ -113,7 +118,7 @@ return [
'nextDay' => '[Заўтра ў] LT',
'nextWeek' => '[У] dddd [ў] LT',
'lastDay' => '[Учора ў] LT',
'lastWeek' => function (\Carbon\CarbonInterface $current) {
'lastWeek' => function (CarbonInterface $current) {
switch ($current->dayOfWeek) {
case 1:
case 2:

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['pamilau', 'pamunyi'],
'weekdays' => ['pa mulungu', 'pa shahuviluha', 'pa hivili', 'pa hidatu', 'pa hitayi', 'pa hihanu', 'pa shahulembela'],

View File

@@ -17,6 +17,9 @@
* - JD Isaacks
* - Glavić
*/
use Carbon\CarbonInterface;
return [
'year' => ':count година|:count години',
'a_year' => 'година|:count години',
@@ -63,7 +66,7 @@ return [
'nextDay' => '[Утре в] LT',
'nextWeek' => 'dddd [в] LT',
'lastDay' => '[Вчера в] LT',
'lastWeek' => function (\Carbon\CarbonInterface $current) {
'lastWeek' => function (CarbonInterface $current) {
switch ($current->dayOfWeek) {
case 0:
case 3:

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/bg.php';

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/bo.php';

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/bo.php', [
'meridiem' => ['སྔ་དྲོ་', 'ཕྱི་དྲོ་'],
'weekdays' => ['གཟའ་ཉི་མ་', 'གཟའ་ཟླ་བ་', 'གཟའ་མིག་དམར་', 'གཟའ་ལྷག་པ་', 'གཟའ་ཕུར་བུ་', 'གཟའ་པ་སངས་', 'གཟའ་སྤེན་པ་'],

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/br.php';

View File

@@ -18,6 +18,9 @@
* - Serhan Apaydın
* - JD Isaacks
*/
use Carbon\CarbonInterface;
return [
'year' => ':count godina|:count godine|:count godina',
'y' => ':count godina|:count godine|:count godina',
@@ -55,7 +58,7 @@ return [
'calendar' => [
'sameDay' => '[danas u] LT',
'nextDay' => '[sutra u] LT',
'nextWeek' => function (\Carbon\CarbonInterface $current) {
'nextWeek' => function (CarbonInterface $current) {
switch ($current->dayOfWeek) {
case 0:
return '[u] [nedjelju] [u] LT';
@@ -68,7 +71,7 @@ return [
}
},
'lastDay' => '[jučer u] LT',
'lastWeek' => function (\Carbon\CarbonInterface $current) {
'lastWeek' => function (CarbonInterface $current) {
switch ($current->dayOfWeek) {
case 0:
case 3:

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/bs.php';

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/bs.php', [
'meridiem' => ['пре подне', 'поподне'],
'weekdays' => ['недјеља', 'понедјељак', 'уторак', 'сриједа', 'четвртак', 'петак', 'субота'],

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/bs.php', [
]);

View File

@@ -21,6 +21,9 @@
* - Xavi
* - qcardona
*/
use Carbon\CarbonInterface;
return [
'year' => ':count any|:count anys',
'a_year' => 'un any|:count anys',
@@ -69,19 +72,19 @@ return [
'LLLL' => 'dddd D MMMM [de] YYYY [a les] H:mm',
],
'calendar' => [
'sameDay' => function (\Carbon\CarbonInterface $current) {
'sameDay' => function (CarbonInterface $current) {
return '[avui a '.($current->hour !== 1 ? 'les' : 'la').'] LT';
},
'nextDay' => function (\Carbon\CarbonInterface $current) {
'nextDay' => function (CarbonInterface $current) {
return '[demà a '.($current->hour !== 1 ? 'les' : 'la').'] LT';
},
'nextWeek' => function (\Carbon\CarbonInterface $current) {
'nextWeek' => function (CarbonInterface $current) {
return 'dddd [a '.($current->hour !== 1 ? 'les' : 'la').'] LT';
},
'lastDay' => function (\Carbon\CarbonInterface $current) {
'lastDay' => function (CarbonInterface $current) {
return '[ahir a '.($current->hour !== 1 ? 'les' : 'la').'] LT';
},
'lastWeek' => function (\Carbon\CarbonInterface $current) {
'lastWeek' => function (CarbonInterface $current) {
return '[el] dddd [passat a '.($current->hour !== 1 ? 'les' : 'la').'] LT';
},
'sameElse' => 'L',

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ca.php', [
]);

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/ca.php';

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ca.php', [
]);

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ca.php', [
]);

View File

@@ -8,5 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ca.php', [
]);

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'weekdays' => ['𑄢𑄧𑄝𑄨𑄝𑄢𑄴', '𑄥𑄧𑄟𑄴𑄝𑄢𑄴', '𑄟𑄧𑄁𑄉𑄧𑄣𑄴𑄝𑄢𑄴', '𑄝𑄪𑄖𑄴𑄝𑄢𑄴', '𑄝𑄳𑄢𑄨𑄥𑄪𑄛𑄴𑄝𑄢𑄴', '𑄥𑄪𑄇𑄴𑄇𑄮𑄢𑄴𑄝𑄢𑄴', '𑄥𑄧𑄚𑄨𑄝𑄢𑄴'],
'weekdays_short' => ['𑄢𑄧𑄝𑄨', '𑄥𑄧𑄟𑄴', '𑄟𑄧𑄁𑄉𑄧𑄣𑄴', '𑄝𑄪𑄖𑄴', '𑄝𑄳𑄢𑄨𑄥𑄪𑄛𑄴', '𑄥𑄪𑄇𑄴𑄇𑄮𑄢𑄴', '𑄥𑄧𑄚𑄨'],

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ccp.php', [
'weekend' => [0, 0],
]);

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'weekdays' => ['Sande', 'Orwokubanza', 'Orwakabiri', 'Orwakashatu', 'Orwakana', 'Orwakataano', 'Orwamukaaga'],
'weekdays_short' => ['SAN', 'ORK', 'OKB', 'OKS', 'OKN', 'OKT', 'OMK'],

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/cs.php';

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'months' => ['M01', 'M02', 'M03', 'M04', 'M05', 'M06', 'M07', 'M08', 'M09', 'M10', 'M11', 'M12'],
'months_short' => ['M01', 'M02', 'M03', 'M04', 'M05', 'M06', 'M07', 'M08', 'M09', 'M10', 'M11', 'M12'],

View File

@@ -32,7 +32,7 @@ return [
'a_second' => '{1}пӗр-ик ҫеккунт|:count ҫеккунт',
'ago' => ':time каялла',
'from_now' => function ($time) {
return $time.(preg_match('/сехет$/', $time) ? 'рен' : (preg_match('/ҫул/', $time) ? 'тан' : 'ран'));
return $time.(preg_match('/сехет$/u', $time) ? 'рен' : (preg_match('/ҫул/u', $time) ? 'тан' : 'ран'));
},
'diff_yesterday' => 'Ӗнер',
'diff_today' => 'Паян',

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/cv.php';

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/cy.php';

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/da.php';

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/da.php', [
'formats' => [
'L' => 'DD/MM/YYYY',

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['Luma lwa K', 'luma lwa p'],
'weekdays' => ['Ituku ja jumwa', 'Kuramuka jimweri', 'Kuramuka kawi', 'Kuramuka kadadu', 'Kuramuka kana', 'Kuramuka kasanu', 'Kifula nguwo'],

View File

@@ -8,4 +8,5 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/de.php';

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['Subbaahi', 'Zaarikay b'],
'weekdays' => ['Alhadi', 'Atinni', 'Atalaata', 'Alarba', 'Alhamisi', 'Alzuma', 'Asibti'],

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['idiɓa', 'ebyámu'],
'weekdays' => ['éti', 'mɔ́sú', 'kwasú', 'mukɔ́sú', 'ŋgisú', 'ɗónɛsú', 'esaɓasú'],

View File

@@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$months = [
'ޖެނުއަރީ',
'ފެބްރުއަރީ',

View File

@@ -3,7 +3,7 @@
/**
* This file is part of the Carbon package.
*
* (c) Ahmed Ali <ajaaibu@gmail.com>
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

Some files were not shown because too many files have changed in this diff Show More