.editorconfig000064400000000301150145555700007222 0ustar00root = true [*] trim_trailing_whitespace = true insert_final_newline = true [*.php] charset = utf-8 indent_style = space indent_size = 4 [composer.json] indent_style = space indent_size = 2 LICENSE000064400000002034150145555700005557 0ustar00Copyright (C) Brian Nesbitt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. composer.json000064400000001065150145555700007277 0ustar00{ "name": "nesbot/carbon", "type": "library", "description": "A simple API extension for DateTime.", "keywords": [ "date", "time", "DateTime" ], "homepage": "http://carbon.nesbot.com", "license": "MIT", "authors": [ { "name": "Brian Nesbitt", "email": "brian@nesbot.com", "homepage": "http://nesbot.com" } ], "require": { "php": ">=5.3.0", "symfony/translation": "~2.6|~3.0" }, "require-dev": { "phpunit/phpunit": "~4.0" }, "autoload": { "psr-0": { "Carbon": "src" } } } readme.md000064400000004250150145555700006333 0ustar00# Carbon [![Latest Stable Version](https://poser.pugx.org/nesbot/carbon/v/stable.png)](https://packagist.org/packages/nesbot/carbon) [![Total Downloads](https://poser.pugx.org/nesbot/carbon/downloads.png)](https://packagist.org/packages/nesbot/carbon) [![Build Status](https://travis-ci.org/briannesbitt/Carbon.svg?branch=master)](https://travis-ci.org/briannesbitt/Carbon) A simple PHP API extension for DateTime. [http://carbon.nesbot.com](http://carbon.nesbot.com) ```php printf("Right now is %s", Carbon::now()->toDateTimeString()); printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver')); //implicit __toString() $tomorrow = Carbon::now()->addDay(); $lastWeek = Carbon::now()->subWeek(); $nextSummerOlympics = Carbon::createFromDate(2012)->addYears(4); $officialDate = Carbon::now()->toRfc2822String(); $howOldAmI = Carbon::createFromDate(1975, 5, 21)->age; $noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London'); $worldWillEnd = Carbon::createFromDate(2012, 12, 21, 'GMT'); // Don't really want to die so mock now Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1)); // comparisons are always done in UTC if (Carbon::now()->gte($worldWillEnd)) { die(); } // Phew! Return to normal behaviour Carbon::setTestNow(); if (Carbon::now()->isWeekend()) { echo 'Party!'; } echo Carbon::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago' // ... but also does 'from now', 'after' and 'before' // rolling up to seconds, minutes, hours, days, months, years $daysSinceEpoch = Carbon::createFromTimeStamp(0)->diffInDays(); ``` ## Installation ### With Composer ``` $ composer require nesbot/carbon ``` ```json { "require": { "nesbot/carbon": "~1.14" } } ``` ```php ### Without Composer Why are you not using [composer](http://getcomposer.org/)? Download [Carbon.php](https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Carbon.php) from the repo and save the file into your project path somewhere. ```php * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Closure; use DateTime; use DateTimeZone; use DatePeriod; use InvalidArgumentException; use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\Loader\ArrayLoader; /** * A simple API extension for DateTime * * @property integer $year * @property integer $yearIso * @property integer $month * @property integer $day * @property integer $hour * @property integer $minute * @property integer $second * @property integer $timestamp seconds since the Unix Epoch * @property DateTimeZone $timezone the current timezone * @property DateTimeZone $tz alias of timezone * @property-read integer $micro * @property-read integer $dayOfWeek 0 (for Sunday) through 6 (for Saturday) * @property-read integer $dayOfYear 0 through 365 * @property-read integer $weekOfMonth 1 through 5 * @property-read integer $weekOfYear ISO-8601 week number of year, weeks starting on Monday * @property-read integer $daysInMonth number of days in the given month * @property-read integer $age does a diffInYears() with default parameters * @property-read integer $quarter the quarter of this instance, 1 - 4 * @property-read integer $offset the timezone offset in seconds from UTC * @property-read integer $offsetHours the timezone offset in hours from UTC * @property-read boolean $dst daylight savings time indicator, true if DST, false otherwise * @property-read boolean $local checks if the timezone is local, true if local, false otherwise * @property-read boolean $utc checks if the timezone is UTC, true if UTC, false otherwise * @property-read string $timezoneName * @property-read string $tzName */ class Carbon extends DateTime { /** * The day constants */ const SUNDAY = 0; const MONDAY = 1; const TUESDAY = 2; const WEDNESDAY = 3; const THURSDAY = 4; const FRIDAY = 5; const SATURDAY = 6; /** * Names of days of the week. * * @var array */ protected static $days = array( self::SUNDAY => 'Sunday', self::MONDAY => 'Monday', self::TUESDAY => 'Tuesday', self::WEDNESDAY => 'Wednesday', self::THURSDAY => 'Thursday', self::FRIDAY => 'Friday', self::SATURDAY => 'Saturday', ); /** * Terms used to detect if a time passed is a relative date for testing purposes * * @var array */ protected static $relativeKeywords = array( 'this', 'next', 'last', 'tomorrow', 'yesterday', '+', '-', 'first', 'last', 'ago', ); /** * Number of X in Y */ const YEARS_PER_CENTURY = 100; const YEARS_PER_DECADE = 10; const MONTHS_PER_YEAR = 12; const WEEKS_PER_YEAR = 52; const DAYS_PER_WEEK = 7; const HOURS_PER_DAY = 24; const MINUTES_PER_HOUR = 60; const SECONDS_PER_MINUTE = 60; /** * Default format to use for __toString method when type juggling occurs. * * @var string */ const DEFAULT_TO_STRING_FORMAT = 'Y-m-d H:i:s'; /** * Format to use for __toString method when type juggling occurs. * * @var string */ protected static $toStringFormat = self::DEFAULT_TO_STRING_FORMAT; /** * First day of week * * @var int */ protected static $weekStartsAt = self::MONDAY; /** * Last day of week * * @var int */ protected static $weekEndsAt = self::SUNDAY; /** * Days of weekend * * @var array */ protected static $weekendDays = array(self::SATURDAY, self::SUNDAY); /** * A test Carbon instance to be returned when now instances are created * * @var Carbon */ protected static $testNow; /** * A translator to ... er ... translate stuff * * @var TranslatorInterface */ protected static $translator; /** * Creates a DateTimeZone from a string or a DateTimeZone * * @param DateTimeZone|string|null $object * * @return DateTimeZone * * @throws InvalidArgumentException */ protected static function safeCreateDateTimeZone($object) { if ($object === null) { // Don't return null... avoid Bug #52063 in PHP <5.3.6 return new DateTimeZone(date_default_timezone_get()); } if ($object instanceof DateTimeZone) { return $object; } $tz = @timezone_open((string) $object); if ($tz === false) { throw new InvalidArgumentException('Unknown or bad timezone ('.$object.')'); } return $tz; } /////////////////////////////////////////////////////////////////// //////////////////////////// CONSTRUCTORS ///////////////////////// /////////////////////////////////////////////////////////////////// /** * Create a new Carbon instance. * * Please see the testing aids section (specifically static::setTestNow()) * for more on the possibility of this constructor returning a test instance. * * @param string $time * @param DateTimeZone|string $tz */ public function __construct($time = null, $tz = null) { // If the class has a test now set and we are trying to create a now() // instance then override as required if (static::hasTestNow() && (empty($time) || $time === 'now' || static::hasRelativeKeywords($time))) { $testInstance = clone static::getTestNow(); if (static::hasRelativeKeywords($time)) { $testInstance->modify($time); } //shift the time according to the given time zone if ($tz !== NULL && $tz != static::getTestNow()->tz) { $testInstance->setTimezone($tz); } else { $tz = $testInstance->tz; } $time = $testInstance->toDateTimeString(); } parent::__construct($time, static::safeCreateDateTimeZone($tz)); } /** * Create a Carbon instance from a DateTime one * * @param DateTime $dt * * @return static */ public static function instance(DateTime $dt) { return new static($dt->format('Y-m-d H:i:s.u'), $dt->getTimeZone()); } /** * 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() * * @param string $time * @param DateTimeZone|string $tz * * @return static */ public static function parse($time = null, $tz = null) { return new static($time, $tz); } /** * Get a Carbon instance for the current date and time * * @param DateTimeZone|string $tz * * @return static */ public static function now($tz = null) { return new static(null, $tz); } /** * Create a Carbon instance for today * * @param DateTimeZone|string $tz * * @return static */ public static function today($tz = null) { return static::now($tz)->startOfDay(); } /** * Create a Carbon instance for tomorrow * * @param DateTimeZone|string $tz * * @return static */ public static function tomorrow($tz = null) { return static::today($tz)->addDay(); } /** * Create a Carbon instance for yesterday * * @param DateTimeZone|string $tz * * @return static */ public static function yesterday($tz = null) { return static::today($tz)->subDay(); } /** * Create a Carbon instance for the greatest supported date. * * @return Carbon */ public static function maxValue() { return static::createFromTimestamp(PHP_INT_MAX); } /** * Create a Carbon instance for the lowest supported date. * * @return Carbon */ public static function minValue() { return static::createFromTimestamp(~PHP_INT_MAX); } /** * 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. * * @param integer $year * @param integer $month * @param integer $day * @param integer $hour * @param integer $minute * @param integer $second * @param DateTimeZone|string $tz * * @return static */ public static function create($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) { $year = ($year === null) ? date('Y') : $year; $month = ($month === null) ? date('n') : $month; $day = ($day === null) ? date('j') : $day; if ($hour === null) { $hour = date('G'); $minute = ($minute === null) ? date('i') : $minute; $second = ($second === null) ? date('s') : $second; } else { $minute = ($minute === null) ? 0 : $minute; $second = ($second === null) ? 0 : $second; } return static::createFromFormat('Y-n-j G:i:s', sprintf('%s-%s-%s %s:%02s:%02s', $year, $month, $day, $hour, $minute, $second), $tz); } /** * Create a Carbon instance from just a date. The time portion is set to now. * * @param integer $year * @param integer $month * @param integer $day * @param DateTimeZone|string $tz * * @return static */ public static function createFromDate($year = null, $month = null, $day = null, $tz = null) { return static::create($year, $month, $day, null, null, null, $tz); } /** * Create a Carbon instance from just a time. The date portion is set to today. * * @param integer $hour * @param integer $minute * @param integer $second * @param DateTimeZone|string $tz * * @return static */ public static function createFromTime($hour = null, $minute = null, $second = null, $tz = null) { return static::create(null, null, null, $hour, $minute, $second, $tz); } /** * Create a Carbon instance from a specific format * * @param string $format * @param string $time * @param DateTimeZone|string $tz * * @return static * * @throws InvalidArgumentException */ public static function createFromFormat($format, $time, $tz = null) { if ($tz !== null) { $dt = parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz)); } else { $dt = parent::createFromFormat($format, $time); } if ($dt instanceof DateTime) { return static::instance($dt); } $errors = static::getLastErrors(); throw new InvalidArgumentException(implode(PHP_EOL, $errors['errors'])); } /** * Create a Carbon instance from a timestamp * * @param integer $timestamp * @param DateTimeZone|string $tz * * @return static */ public static function createFromTimestamp($timestamp, $tz = null) { return static::now($tz)->setTimestamp($timestamp); } /** * Create a Carbon instance from an UTC timestamp * * @param integer $timestamp * * @return static */ public static function createFromTimestampUTC($timestamp) { return new static('@'.$timestamp); } /** * Get a copy of the instance * * @return static */ public function copy() { return static::instance($this); } /////////////////////////////////////////////////////////////////// ///////////////////////// GETTERS AND SETTERS ///////////////////// /////////////////////////////////////////////////////////////////// /** * Get a part of the Carbon object * * @param string $name * * @throws InvalidArgumentException * * @return string|integer|DateTimeZone */ public function __get($name) { switch (true) { case array_key_exists($name, $formats = array( 'year' => 'Y', 'yearIso' => 'o', 'month' => 'n', 'day' => 'j', 'hour' => 'G', 'minute' => 'i', 'second' => 's', 'micro' => 'u', 'dayOfWeek' => 'w', 'dayOfYear' => 'z', 'weekOfYear' => 'W', 'daysInMonth' => 't', 'timestamp' => 'U', )): return (int) $this->format($formats[$name]); case $name === 'weekOfMonth': return (int) ceil($this->day / static::DAYS_PER_WEEK); case $name === 'age': return (int) $this->diffInYears(); case $name === 'quarter': return (int) ceil($this->month / 3); case $name === 'offset': return $this->getOffset(); case $name === 'offsetHours': return $this->getOffset() / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR; case $name === 'dst': return $this->format('I') == '1'; case $name === 'local': return $this->offset == $this->copy()->setTimezone(date_default_timezone_get())->offset; case $name === 'utc': return $this->offset == 0; case $name === 'timezone' || $name === 'tz': return $this->getTimezone(); case $name === 'timezoneName' || $name === 'tzName': return $this->getTimezone()->getName(); default: throw new InvalidArgumentException(sprintf("Unknown getter '%s'", $name)); } } /** * Check if an attribute exists on the object * * @param string $name * * @return boolean */ public function __isset($name) { try { $this->__get($name); } catch (InvalidArgumentException $e) { return false; } return true; } /** * Set a part of the Carbon object * * @param string $name * @param string|integer|DateTimeZone $value * * @throws InvalidArgumentException */ public function __set($name, $value) { switch ($name) { case 'year': $this->setDate($value, $this->month, $this->day); break; case 'month': $this->setDate($this->year, $value, $this->day); break; case 'day': $this->setDate($this->year, $this->month, $value); break; case 'hour': $this->setTime($value, $this->minute, $this->second); break; case 'minute': $this->setTime($this->hour, $value, $this->second); break; case 'second': $this->setTime($this->hour, $this->minute, $value); break; case 'timestamp': parent::setTimestamp($value); break; case 'timezone': case 'tz': $this->setTimezone($value); break; default: throw new InvalidArgumentException(sprintf("Unknown setter '%s'", $name)); } } /** * Set the instance's year * * @param integer $value * * @return static */ public function year($value) { $this->year = $value; return $this; } /** * Set the instance's month * * @param integer $value * * @return static */ public function month($value) { $this->month = $value; return $this; } /** * Set the instance's day * * @param integer $value * * @return static */ public function day($value) { $this->day = $value; return $this; } /** * Set the instance's hour * * @param integer $value * * @return static */ public function hour($value) { $this->hour = $value; return $this; } /** * Set the instance's minute * * @param integer $value * * @return static */ public function minute($value) { $this->minute = $value; return $this; } /** * Set the instance's second * * @param integer $value * * @return static */ public function second($value) { $this->second = $value; return $this; } /** * Set the date and time all together * * @param integer $year * @param integer $month * @param integer $day * @param integer $hour * @param integer $minute * @param integer $second * * @return static */ public function setDateTime($year, $month, $day, $hour, $minute, $second = 0) { return $this->setDate($year, $month, $day)->setTime($hour, $minute, $second); } /** * Set the instance's timestamp * * @param integer $value * * @return static */ public function timestamp($value) { $this->timestamp = $value; return $this; } /** * Alias for setTimezone() * * @param DateTimeZone|string $value * * @return static */ public function timezone($value) { return $this->setTimezone($value); } /** * Alias for setTimezone() * * @param DateTimeZone|string $value * * @return static */ public function tz($value) { return $this->setTimezone($value); } /** * Set the instance's timezone from a string or object * * @param DateTimeZone|string $value * * @return static */ public function setTimezone($value) { parent::setTimezone(static::safeCreateDateTimeZone($value)); return $this; } /////////////////////////////////////////////////////////////////// /////////////////////// WEEK SPECIAL DAYS ///////////////////////// /////////////////////////////////////////////////////////////////// /** * Get the first day of week * * @return int */ public static function getWeekStartsAt() { return static::$weekStartsAt; } /** * Set the first day of week * * @param int */ public static function setWeekStartsAt($day) { static::$weekStartsAt = $day; } /** * Get the last day of week * * @return int */ public static function getWeekEndsAt() { return static::$weekEndsAt; } /** * Set the first day of week * * @param int */ public static function setWeekEndsAt($day) { static::$weekEndsAt = $day; } /** * Get weekend days * * @return array */ public static function getWeekendDays() { return static::$weekendDays; } /** * Set weekend days * * @param array */ public static function setWeekendDays($days) { static::$weekendDays = $days; } /////////////////////////////////////////////////////////////////// ///////////////////////// TESTING AIDS //////////////////////////// /////////////////////////////////////////////////////////////////// /** * 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') * * 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. * * @param Carbon $testNow */ public static function setTestNow(Carbon $testNow = null) { static::$testNow = $testNow; } /** * Get the Carbon instance (real or mock) to be returned when a "now" * instance is created. * * @return static the current instance used for testing */ public static function getTestNow() { return static::$testNow; } /** * Determine if there is a valid test instance set. A valid test instance * is anything that is not null. * * @return boolean true if there is a test instance, otherwise false */ public static function hasTestNow() { return static::getTestNow() !== null; } /** * Determine if there is a relative keyword in the time string, this is to * create dates relative to now for test instances. e.g.: next tuesday * * @param string $time * * @return boolean true if there is a keyword, otherwise false */ public static function hasRelativeKeywords($time) { // skip common format with a '-' in it if (preg_match('/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}/', $time) !== 1) { foreach (static::$relativeKeywords as $keyword) { if (stripos($time, $keyword) !== false) { return true; } } } return false; } /////////////////////////////////////////////////////////////////// /////////////////////// LOCALIZATION ////////////////////////////// /////////////////////////////////////////////////////////////////// /** * Intialize the translator instance if necessary. * * @return TranslatorInterface */ protected static function translator() { if (static::$translator == null) { static::$translator = new Translator('en'); static::$translator->addLoader('array', new ArrayLoader()); static::setLocale('en'); } return static::$translator; } /** * Get the translator instance in use * * @return TranslatorInterface */ public static function getTranslator() { return static::translator(); } /** * Set the translator instance to use * * @param TranslatorInterface $translator */ public static function setTranslator(TranslatorInterface $translator) { static::$translator = $translator; } /** * Get the current translator locale * * @return string */ public static function getLocale() { return static::translator()->getLocale(); } /** * Set the current translator locale * * @param string $locale */ public static function setLocale($locale) { static::translator()->setLocale($locale); // Ensure the locale has been loaded. static::translator()->addResource('array', require __DIR__.'/Lang/'.$locale.'.php', $locale); } /////////////////////////////////////////////////////////////////// /////////////////////// STRING FORMATTING ///////////////////////// /////////////////////////////////////////////////////////////////// /** * Format the instance with the current locale. You can set the current * locale using setlocale() http://php.net/setlocale. * * @param string $format * * @return string */ public function formatLocalized($format) { // Check for Windows to find and replace the %e // modifier correctly if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $format = preg_replace('#(?format(static::$toStringFormat); } /** * Format the instance as date * * @return string */ public function toDateString() { return $this->format('Y-m-d'); } /** * Format the instance as a readable date * * @return string */ public function toFormattedDateString() { return $this->format('M j, Y'); } /** * Format the instance as time * * @return string */ public function toTimeString() { return $this->format('H:i:s'); } /** * Format the instance as date and time * * @return string */ public function toDateTimeString() { return $this->format('Y-m-d H:i:s'); } /** * Format the instance with day, date and time * * @return string */ public function toDayDateTimeString() { return $this->format('D, M j, Y g:i A'); } /** * Format the instance as ATOM * * @return string */ public function toAtomString() { return $this->format(static::ATOM); } /** * Format the instance as COOKIE * * @return string */ public function toCookieString() { return $this->format(static::COOKIE); } /** * Format the instance as ISO8601 * * @return string */ public function toIso8601String() { return $this->format(static::ISO8601); } /** * Format the instance as RFC822 * * @return string */ public function toRfc822String() { return $this->format(static::RFC822); } /** * Format the instance as RFC850 * * @return string */ public function toRfc850String() { return $this->format(static::RFC850); } /** * Format the instance as RFC1036 * * @return string */ public function toRfc1036String() { return $this->format(static::RFC1036); } /** * Format the instance as RFC1123 * * @return string */ public function toRfc1123String() { return $this->format(static::RFC1123); } /** * Format the instance as RFC2822 * * @return string */ public function toRfc2822String() { return $this->format(static::RFC2822); } /** * Format the instance as RFC3339 * * @return string */ public function toRfc3339String() { return $this->format(static::RFC3339); } /** * Format the instance as RSS * * @return string */ public function toRssString() { return $this->format(static::RSS); } /** * Format the instance as W3C * * @return string */ public function toW3cString() { return $this->format(static::W3C); } /////////////////////////////////////////////////////////////////// ////////////////////////// COMPARISONS //////////////////////////// /////////////////////////////////////////////////////////////////// /** * Determines if the instance is equal to another * * @param Carbon $dt * * @return boolean */ public function eq(Carbon $dt) { return $this == $dt; } /** * Determines if the instance is not equal to another * * @param Carbon $dt * * @return boolean */ public function ne(Carbon $dt) { return !$this->eq($dt); } /** * Determines if the instance is greater (after) than another * * @param Carbon $dt * * @return boolean */ public function gt(Carbon $dt) { return $this > $dt; } /** * Determines if the instance is greater (after) than or equal to another * * @param Carbon $dt * * @return boolean */ public function gte(Carbon $dt) { return $this >= $dt; } /** * Determines if the instance is less (before) than another * * @param Carbon $dt * * @return boolean */ public function lt(Carbon $dt) { return $this < $dt; } /** * Determines if the instance is less (before) or equal to another * * @param Carbon $dt * * @return boolean */ public function lte(Carbon $dt) { return $this <= $dt; } /** * Determines if the instance is between two others * * @param Carbon $dt1 * @param Carbon $dt2 * @param boolean $equal Indicates if a > and < comparison should be used or <= or >= * * @return boolean */ public function between(Carbon $dt1, Carbon $dt2, $equal = true) { if ($dt1->gt($dt2)) { $temp = $dt1; $dt1 = $dt2; $dt2 = $temp; } if ($equal) { return $this->gte($dt1) && $this->lte($dt2); } else { return $this->gt($dt1) && $this->lt($dt2); } } /** * Get the minimum instance between a given instance (default now) and the current instance. * * @param Carbon $dt * * @return static */ public function min(Carbon $dt = null) { $dt = ($dt === null) ? static::now($this->tz) : $dt; return $this->lt($dt) ? $this : $dt; } /** * Get the maximum instance between a given instance (default now) and the current instance. * * @param Carbon $dt * * @return static */ public function max(Carbon $dt = null) { $dt = ($dt === null) ? static::now($this->tz) : $dt; return $this->gt($dt) ? $this : $dt; } /** * Determines if the instance is a weekday * * @return boolean */ public function isWeekday() { return !$this->isWeekend(); } /** * Determines if the instance is a weekend day * * @return boolean */ public function isWeekend() { return in_array($this->dayOfWeek, self::$weekendDays); } /** * Determines if the instance is yesterday * * @return boolean */ public function isYesterday() { return $this->toDateString() === static::yesterday($this->tz)->toDateString(); } /** * Determines if the instance is today * * @return boolean */ public function isToday() { return $this->toDateString() === static::now($this->tz)->toDateString(); } /** * Determines if the instance is tomorrow * * @return boolean */ public function isTomorrow() { return $this->toDateString() === static::tomorrow($this->tz)->toDateString(); } /** * Determines if the instance is in the future, ie. greater (after) than now * * @return boolean */ public function isFuture() { return $this->gt(static::now($this->tz)); } /** * Determines if the instance is in the past, ie. less (before) than now * * @return boolean */ public function isPast() { return $this->lt(static::now($this->tz)); } /** * Determines if the instance is a leap year * * @return boolean */ public function isLeapYear() { return $this->format('L') == '1'; } /** * Checks if the passed in date is the same day as the instance current day. * * @param Carbon $dt * @return boolean */ public function isSameDay(Carbon $dt) { return $this->toDateString() === $dt->toDateString(); } /** * Checks if this day is a Sunday. * * @return boolean */ public function isSunday() { return $this->dayOfWeek === static::SUNDAY; } /** * Checks if this day is a Monday. * * @return boolean */ public function isMonday() { return $this->dayOfWeek === static::MONDAY; } /** * Checks if this day is a Tuesday. * * @return boolean */ public function isTuesday() { return $this->dayOfWeek === static::TUESDAY; } /** * Checks if this day is a Wednesday. * * @return boolean */ public function isWednesday() { return $this->dayOfWeek === static::WEDNESDAY; } /** * Checks if this day is a Thursday. * * @return boolean */ public function isThursday() { return $this->dayOfWeek === static::THURSDAY; } /** * Checks if this day is a Friday. * * @return boolean */ public function isFriday() { return $this->dayOfWeek === static::FRIDAY; } /** * Checks if this day is a Saturday. * * @return boolean */ public function isSaturday() { return $this->dayOfWeek === static::SATURDAY; } /////////////////////////////////////////////////////////////////// /////////////////// ADDITIONS AND SUBTRACTIONS //////////////////// /////////////////////////////////////////////////////////////////// /** * Add years to the instance. Positive $value travel forward while * negative $value travel into the past. * * @param integer $value * * @return static */ public function addYears($value) { return $this->modify((int) $value.' year'); } /** * Add a year to the instance * * @param integer $value * * @return static */ public function addYear($value = 1) { return $this->addYears($value); } /** * Remove a year from the instance * * @param integer $value * * @return static */ public function subYear($value = 1) { return $this->subYears($value); } /** * Remove years from the instance. * * @param integer $value * * @return static */ public function subYears($value) { return $this->addYears(-1 * $value); } /** * Add months to the instance. Positive $value travels forward while * negative $value travels into the past. * * @param integer $value * * @return static */ public function addMonths($value) { return $this->modify((int) $value.' month'); } /** * Add a month to the instance * * @param integer $value * * @return static */ public function addMonth($value = 1) { return $this->addMonths($value); } /** * Remove a month from the instance * * @param integer $value * * @return static */ public function subMonth($value = 1) { return $this->subMonths($value); } /** * Remove months from the instance * * @param integer $value * * @return static */ public function subMonths($value) { return $this->addMonths(-1 * $value); } /** * Add months without overflowing to the instance. Positive $value * travels forward while negative $value travels into the past. * * @param integer $value * * @return static */ public function addMonthsNoOverflow($value) { $date = $this->copy()->addMonths($value); if ($date->day != $this->day) { $date->day(1)->subMonth()->day($date->daysInMonth); } return $date; } /** * Add a month with no overflow to the instance * * @param integer $value * * @return static */ public function addMonthNoOverflow($value = 1) { return $this->addMonthsNoOverflow($value); } /** * Remove a month with no overflow from the instance * * @param integer $value * * @return static */ public function subMonthNoOverflow($value = 1) { return $this->subMonthsNoOverflow($value); } /** * Remove months with no overflow from the instance * * @param integer $value * * @return static */ public function subMonthsNoOverflow($value) { return $this->addMonthsNoOverflow(-1 * $value); } /** * Add days to the instance. Positive $value travels forward while * negative $value travels into the past. * * @param integer $value * * @return static */ public function addDays($value) { return $this->modify((int) $value.' day'); } /** * Add a day to the instance * * @param integer $value * * @return static */ public function addDay($value = 1) { return $this->addDays($value); } /** * Remove a day from the instance * * @param integer $value * * @return static */ public function subDay($value = 1) { return $this->subDays($value); } /** * Remove days from the instance * * @param integer $value * * @return static */ public function subDays($value) { return $this->addDays(-1 * $value); } /** * Add weekdays to the instance. Positive $value travels forward while * negative $value travels into the past. * * @param integer $value * * @return static */ public function addWeekdays($value) { return $this->modify((int) $value.' weekday'); } /** * Add a weekday to the instance * * @param integer $value * * @return static */ public function addWeekday($value = 1) { return $this->addWeekdays($value); } /** * Remove a weekday from the instance * * @param integer $value * * @return static */ public function subWeekday($value = 1) { return $this->subWeekdays($value); } /** * Remove weekdays from the instance * * @param integer $value * * @return static */ public function subWeekdays($value) { return $this->addWeekdays(-1 * $value); } /** * Add weeks to the instance. Positive $value travels forward while * negative $value travels into the past. * * @param integer $value * * @return static */ public function addWeeks($value) { return $this->modify((int) $value.' week'); } /** * Add a week to the instance * * @param integer $value * * @return static */ public function addWeek($value = 1) { return $this->addWeeks($value); } /** * Remove a week from the instance * * @param integer $value * * @return static */ public function subWeek($value = 1) { return $this->subWeeks($value); } /** * Remove weeks to the instance * * @param integer $value * * @return static */ public function subWeeks($value) { return $this->addWeeks(-1 * $value); } /** * Add hours to the instance. Positive $value travels forward while * negative $value travels into the past. * * @param integer $value * * @return static */ public function addHours($value) { return $this->modify((int) $value.' hour'); } /** * Add an hour to the instance * * @param integer $value * * @return static */ public function addHour($value = 1) { return $this->addHours($value); } /** * Remove an hour from the instance * * @param integer $value * * @return static */ public function subHour($value = 1) { return $this->subHours($value); } /** * Remove hours from the instance * * @param integer $value * * @return static */ public function subHours($value) { return $this->addHours(-1 * $value); } /** * Add minutes to the instance. Positive $value travels forward while * negative $value travels into the past. * * @param integer $value * * @return static */ public function addMinutes($value) { return $this->modify((int) $value.' minute'); } /** * Add a minute to the instance * * @param integer $value * * @return static */ public function addMinute($value = 1) { return $this->addMinutes($value); } /** * Remove a minute from the instance * * @param integer $value * * @return static */ public function subMinute($value = 1) { return $this->subMinutes($value); } /** * Remove minutes from the instance * * @param integer $value * * @return static */ public function subMinutes($value) { return $this->addMinutes(-1 * $value); } /** * Add seconds to the instance. Positive $value travels forward while * negative $value travels into the past. * * @param integer $value * * @return static */ public function addSeconds($value) { return $this->modify((int) $value.' second'); } /** * Add a second to the instance * * @param integer $value * * @return static */ public function addSecond($value = 1) { return $this->addSeconds($value); } /** * Remove a second from the instance * * @param integer $value * * @return static */ public function subSecond($value = 1) { return $this->subSeconds($value); } /** * Remove seconds from the instance * * @param integer $value * * @return static */ public function subSeconds($value) { return $this->addSeconds(-1 * $value); } /////////////////////////////////////////////////////////////////// /////////////////////////// DIFFERENCES /////////////////////////// /////////////////////////////////////////////////////////////////// /** * Get the difference in years * * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return integer */ public function diffInYears(Carbon $dt = null, $abs = true) { $dt = ($dt === null) ? static::now($this->tz) : $dt; return (int) $this->diff($dt, $abs)->format('%r%y'); } /** * Get the difference in months * * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return integer */ public function diffInMonths(Carbon $dt = null, $abs = true) { $dt = ($dt === null) ? static::now($this->tz) : $dt; return $this->diffInYears($dt, $abs) * static::MONTHS_PER_YEAR + (int) $this->diff($dt, $abs)->format('%r%m'); } /** * Get the difference in weeks * * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return integer */ public function diffInWeeks(Carbon $dt = null, $abs = true) { return (int) ($this->diffInDays($dt, $abs) / static::DAYS_PER_WEEK); } /** * Get the difference in days * * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return integer */ public function diffInDays(Carbon $dt = null, $abs = true) { $dt = ($dt === null) ? static::now($this->tz) : $dt; return (int) $this->diff($dt, $abs)->format('%r%a'); } /** * Get the difference in days using a filter closure * * @param Closure $callback * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return int */ public function diffInDaysFiltered(Closure $callback, Carbon $dt = null, $abs = true) { return $this->diffFiltered(CarbonInterval::day(), $callback, $dt, $abs); } /** * Get the difference in hours using a filter closure * * @param Closure $callback * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return int */ public function diffInHoursFiltered(Closure $callback, Carbon $dt = null, $abs = true) { return $this->diffFiltered(CarbonInterval::hour(), $callback, $dt, $abs); } /** * Get the difference by the given interval using a filter closure * * @param CarbonInterval $ci An interval to traverse by * @param Closure $callback * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return int */ public function diffFiltered(CarbonInterval $ci, Closure $callback, Carbon $dt = null, $abs = true) { $start = $this; $end = ($dt === null) ? static::now($this->tz) : $dt; $inverse = false; if ($end < $start) { $start = $end; $end = $this; $inverse = true; } $period = new DatePeriod($start, $ci, $end); $vals = array_filter(iterator_to_array($period), function (DateTime $date) use ($callback) { return call_user_func($callback, Carbon::instance($date)); }); $diff = count($vals); return $inverse && !$abs ? -$diff : $diff; } /** * Get the difference in weekdays * * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return int */ public function diffInWeekdays(Carbon $dt = null, $abs = true) { return $this->diffInDaysFiltered(function (Carbon $date) { return $date->isWeekday(); }, $dt, $abs); } /** * Get the difference in weekend days using a filter * * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return int */ public function diffInWeekendDays(Carbon $dt = null, $abs = true) { return $this->diffInDaysFiltered(function (Carbon $date) { return $date->isWeekend(); }, $dt, $abs); } /** * Get the difference in hours * * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return integer */ public function diffInHours(Carbon $dt = null, $abs = true) { return (int) ($this->diffInSeconds($dt, $abs) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR); } /** * Get the difference in minutes * * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return integer */ public function diffInMinutes(Carbon $dt = null, $abs = true) { return (int) ($this->diffInSeconds($dt, $abs) / static::SECONDS_PER_MINUTE); } /** * Get the difference in seconds * * @param Carbon $dt * @param boolean $abs Get the absolute of the difference * * @return integer */ public function diffInSeconds(Carbon $dt = null, $abs = true) { $dt = ($dt === null) ? static::now($this->tz) : $dt; $value = $dt->getTimestamp() - $this->getTimestamp(); return $abs ? abs($value) : $value; } /** * The number of seconds since midnight. * * @return integer */ public function secondsSinceMidnight() { return $this->diffInSeconds($this->copy()->startOfDay()); } /** * The number of seconds until 23:23:59. * * @return integer */ public function secondsUntilEndOfDay() { return $this->diffInSeconds($this->copy()->endOfDay()); } /** * Get the difference in a human readable format in the current locale. * * When comparing a value in the past to default now: * 1 hour ago * 5 months ago * * When comparing a value in the future to default now: * 1 hour from now * 5 months from now * * When comparing a value in the past to another value: * 1 hour before * 5 months before * * When comparing a value in the future to another value: * 1 hour after * 5 months after * * @param Carbon $other * @param bool $absolute removes time difference modifiers ago, after, etc * * @return string */ public function diffForHumans(Carbon $other = null, $absolute = false) { $isNow = $other === null; if ($isNow) { $other = static::now($this->tz); } $diffInterval = $this->diff($other); switch (true) { case ($diffInterval->y > 0): $unit = 'year'; $count = $diffInterval->y; break; case ($diffInterval->m > 0): $unit = 'month'; $count = $diffInterval->m; break; case ($diffInterval->d > 0): $unit = 'day'; $count = $diffInterval->d; if ($count >= self::DAYS_PER_WEEK) { $unit = 'week'; $count = (int) ($count / self::DAYS_PER_WEEK); } break; case ($diffInterval->h > 0): $unit = 'hour'; $count = $diffInterval->h; break; case ($diffInterval->i > 0): $unit = 'minute'; $count = $diffInterval->i; break; default: $count = $diffInterval->s; $unit = 'second'; break; } if ($count == 0) { $count = 1; } $time = static::translator()->transChoice($unit, $count, array(':count' => $count)); if ($absolute) { return $time; } $isFuture = $diffInterval->invert === 1; $transId = $isNow ? ($isFuture ? 'from_now' : 'ago') : ($isFuture ? 'after' : 'before'); // Some langs have special pluralization for past and future tense. $tryKeyExists = $unit.'_'.$transId; if ($tryKeyExists !== static::translator()->transChoice($tryKeyExists, $count)) { $time = static::translator()->transChoice($tryKeyExists, $count, array(':count' => $count)); } return static::translator()->trans($transId, array(':time' => $time)); } /////////////////////////////////////////////////////////////////// //////////////////////////// MODIFIERS //////////////////////////// /////////////////////////////////////////////////////////////////// /** * Resets the time to 00:00:00 * * @return static */ public function startOfDay() { return $this->hour(0)->minute(0)->second(0); } /** * Resets the time to 23:59:59 * * @return static */ public function endOfDay() { return $this->hour(23)->minute(59)->second(59); } /** * Resets the date to the first day of the month and the time to 00:00:00 * * @return static */ public function startOfMonth() { return $this->startOfDay()->day(1); } /** * Resets the date to end of the month and time to 23:59:59 * * @return static */ public function endOfMonth() { return $this->day($this->daysInMonth)->endOfDay(); } /** * Resets the date to the first day of the year and the time to 00:00:00 * * @return static */ public function startOfYear() { return $this->month(1)->startOfMonth(); } /** * Resets the date to end of the year and time to 23:59:59 * * @return static */ public function endOfYear() { return $this->month(static::MONTHS_PER_YEAR)->endOfMonth(); } /** * Resets the date to the first day of the decade and the time to 00:00:00 * * @return static */ public function startOfDecade() { return $this->startOfYear()->year($this->year - $this->year % static::YEARS_PER_DECADE); } /** * Resets the date to end of the decade and time to 23:59:59 * * @return static */ public function endOfDecade() { return $this->endOfYear()->year($this->year - $this->year % static::YEARS_PER_DECADE + static::YEARS_PER_DECADE - 1); } /** * Resets the date to the first day of the century and the time to 00:00:00 * * @return static */ public function startOfCentury() { return $this->startOfYear()->year($this->year - $this->year % static::YEARS_PER_CENTURY); } /** * Resets the date to end of the century and time to 23:59:59 * * @return static */ public function endOfCentury() { return $this->endOfYear()->year($this->year - $this->year % static::YEARS_PER_CENTURY + static::YEARS_PER_CENTURY - 1); } /** * Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00 * * @return static */ public function startOfWeek() { if ($this->dayOfWeek != static::$weekStartsAt) { $this->previous(static::$weekStartsAt); } return $this->startOfDay(); } /** * Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59 * * @return static */ public function endOfWeek() { if ($this->dayOfWeek != static::$weekEndsAt) { $this->next(static::$weekEndsAt); } return $this->endOfDay(); } /** * Modify to the next occurence of a given day of the week. * If no dayOfWeek is provided, modify to the next occurence * of the current day of the week. Use the supplied consts * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $dayOfWeek * * @return mixed */ public function next($dayOfWeek = null) { if ($dayOfWeek === null) { $dayOfWeek = $this->dayOfWeek; } return $this->startOfDay()->modify('next '.static::$days[$dayOfWeek]); } /** * Modify to the previous occurence of a given day of the week. * If no dayOfWeek is provided, modify to the previous occurence * of the current day of the week. Use the supplied consts * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $dayOfWeek * * @return mixed */ public function previous($dayOfWeek = null) { if ($dayOfWeek === null) { $dayOfWeek = $this->dayOfWeek; } return $this->startOfDay()->modify('last '.static::$days[$dayOfWeek]); } /** * Modify to the first occurence of a given day of the week * in the current month. If no dayOfWeek is provided, modify to the * first day of the current month. Use the supplied consts * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $dayOfWeek * * @return mixed */ public function firstOfMonth($dayOfWeek = null) { $this->startOfDay(); if ($dayOfWeek === null) { return $this->day(1); } return $this->modify('first '.static::$days[$dayOfWeek].' of '.$this->format('F').' '.$this->year); } /** * Modify to the last occurence of a given day of the week * in the current month. If no dayOfWeek is provided, modify to the * last day of the current month. Use the supplied consts * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $dayOfWeek * * @return mixed */ public function lastOfMonth($dayOfWeek = null) { $this->startOfDay(); if ($dayOfWeek === null) { return $this->day($this->daysInMonth); } return $this->modify('last '.static::$days[$dayOfWeek].' of '.$this->format('F').' '.$this->year); } /** * Modify to the given occurence of a given day of the week * in the current month. If the calculated occurence is outside the scope * of the current month, then return false and no modifications are made. * Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $nth * @param int $dayOfWeek * * @return mixed */ public function nthOfMonth($nth, $dayOfWeek) { $dt = $this->copy()->firstOfMonth(); $check = $dt->format('Y-m'); $dt->modify('+'.$nth.' '.static::$days[$dayOfWeek]); return ($dt->format('Y-m') === $check) ? $this->modify($dt) : false; } /** * Modify to the first occurence of a given day of the week * in the current quarter. If no dayOfWeek is provided, modify to the * first day of the current quarter. Use the supplied consts * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $dayOfWeek * * @return mixed */ public function firstOfQuarter($dayOfWeek = null) { return $this->day(1)->month($this->quarter * 3 - 2)->firstOfMonth($dayOfWeek); } /** * Modify to the last occurence of a given day of the week * in the current quarter. If no dayOfWeek is provided, modify to the * last day of the current quarter. Use the supplied consts * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $dayOfWeek * * @return mixed */ public function lastOfQuarter($dayOfWeek = null) { return $this->day(1)->month($this->quarter * 3)->lastOfMonth($dayOfWeek); } /** * Modify to the given occurence of a given day of the week * in the current quarter. If the calculated occurence is outside the scope * of the current quarter, then return false and no modifications are made. * Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $nth * @param int $dayOfWeek * * @return mixed */ public function nthOfQuarter($nth, $dayOfWeek) { $dt = $this->copy()->day(1)->month($this->quarter * 3); $last_month = $dt->month; $year = $dt->year; $dt->firstOfQuarter()->modify('+'.$nth.' '.static::$days[$dayOfWeek]); return ($last_month < $dt->month || $year !== $dt->year) ? false : $this->modify($dt); } /** * Modify to the first occurence of a given day of the week * in the current year. If no dayOfWeek is provided, modify to the * first day of the current year. Use the supplied consts * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $dayOfWeek * * @return mixed */ public function firstOfYear($dayOfWeek = null) { return $this->month(1)->firstOfMonth($dayOfWeek); } /** * Modify to the last occurence of a given day of the week * in the current year. If no dayOfWeek is provided, modify to the * last day of the current year. Use the supplied consts * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $dayOfWeek * * @return mixed */ public function lastOfYear($dayOfWeek = null) { return $this->month(static::MONTHS_PER_YEAR)->lastOfMonth($dayOfWeek); } /** * Modify to the given occurence of a given day of the week * in the current year. If the calculated occurence is outside the scope * of the current year, then return false and no modifications are made. * Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $nth * @param int $dayOfWeek * * @return mixed */ public function nthOfYear($nth, $dayOfWeek) { $dt = $this->copy()->firstOfYear()->modify('+'.$nth.' '.static::$days[$dayOfWeek]); return $this->year == $dt->year ? $this->modify($dt) : false; } /** * Modify the current instance to the average of a given instance (default now) and the current instance. * * @param Carbon $dt * * @return static */ public function average(Carbon $dt = null) { $dt = ($dt === null) ? static::now($this->tz) : $dt; return $this->addSeconds((int) ($this->diffInSeconds($dt, false) / 2)); } /** * Check if its the birthday. Compares the date/month values of the two dates. * * @param Carbon $dt * * @return boolean */ public function isBirthday(Carbon $dt) { return $this->format('md') === $dt->format('md'); } } src/Carbon/CarbonInterval.php000064400000037563150145555700012206 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use DateInterval; use InvalidArgumentException; use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\Loader\ArrayLoader; /** * A simple API extension for DateInterval. * The implemenation provides helpers to handle weeks but only days are saved. * Weeks are calculated based on the total days of the current instance. * * @property integer $years Total years of the current interval. * @property integer $months Total months of the current interval. * @property integer $weeks Total weeks of the current interval calculated from the days. * @property integer $dayz Total days of the current interval (weeks * 7 + days). * @property integer $hours Total hours of the current interval. * @property integer $minutes Total minutes of the current interval. * @property integer $seconds Total seconds of the current interval. * * @property-read integer $dayzExcludeWeeks Total days remaining in the final week of the current instance (days % 7). * @property-read integer $daysExcludeWeeks alias of dayzExcludeWeeks * * @method static CarbonInterval years($years = 1) Create instance specifying a number of years. * @method static CarbonInterval year($years = 1) Alias for years() * @method static CarbonInterval months($months = 1) Create instance specifying a number of months. * @method static CarbonInterval month($months = 1) Alias for months() * @method static CarbonInterval weeks($weeks = 1) Create instance specifying a number of weeks. * @method static CarbonInterval week($weeks = 1) Alias for weeks() * @method static CarbonInterval days($days = 1) Create instance specifying a number of days. * @method static CarbonInterval dayz($days = 1) Alias for days() * @method static CarbonInterval day($days = 1) Alias for days() * @method static CarbonInterval hours($hours = 1) Create instance specifying a number of hours. * @method static CarbonInterval hour($hours = 1) Alias for hours() * @method static CarbonInterval minutes($minutes = 1) Create instance specifying a number of minutes. * @method static CarbonInterval minute($minutes = 1) Alias for minutes() * @method static CarbonInterval seconds($seconds = 1) Create instance specifying a number of seconds. * @method static CarbonInterval second($seconds = 1) Alias for seconds() * * @method CarbonInterval years() years($years = 1) Set the years portion of the current interval. * @method CarbonInterval year() year($years = 1) Alias for years(). * @method CarbonInterval months() months($months = 1) Set the months portion of the current interval. * @method CarbonInterval month() month($months = 1) Alias for months(). * @method CarbonInterval weeks() weeks($weeks = 1) Set the weeks portion of the current interval. Will overwrite dayz value. * @method CarbonInterval week() week($weeks = 1) Alias for weeks(). * @method CarbonInterval days() days($days = 1) Set the days portion of the current interval. * @method CarbonInterval dayz() dayz($days = 1) Alias for days(). * @method CarbonInterval day() day($days = 1) Alias for days(). * @method CarbonInterval hours() hours($hours = 1) Set the hours portion of the current interval. * @method CarbonInterval hour() hour($hours = 1) Alias for hours(). * @method CarbonInterval minutes() minutes($minutes = 1) Set the minutes portion of the current interval. * @method CarbonInterval minute() minute($minutes = 1) Alias for minutes(). * @method CarbonInterval seconds() seconds($seconds = 1) Set the seconds portion of the current interval. * @method CarbonInterval second() second($seconds = 1) Alias for seconds(). */ class CarbonInterval extends DateInterval { /** * 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'; /** * A translator to ... er ... translate stuff * * @var TranslatorInterface */ protected static $translator; /** * Before PHP 5.4.20/5.5.4 instead of FALSE days will be set to -99999 when the interval instance * was created by DateTime:diff(). */ const PHP_DAYS_FALSE = -99999; /** * Determine if the interval was created via DateTime:diff() or not. * * @param DateInterval $interval * * @return boolean */ private static function wasCreatedFromDiff(DateInterval $interval) { return ($interval->days !== false && $interval->days !== static::PHP_DAYS_FALSE); } /////////////////////////////////////////////////////////////////// //////////////////////////// CONSTRUCTORS ///////////////////////// /////////////////////////////////////////////////////////////////// /** * Create a new CarbonInterval instance. * * @param integer $years * @param integer $months * @param integer $weeks * @param integer $days * @param integer $hours * @param integer $minutes * @param integer $seconds */ public function __construct($years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null) { $spec = static::PERIOD_PREFIX; $spec .= $years > 0 ? $years.static::PERIOD_YEARS : ''; $spec .= $months > 0 ? $months.static::PERIOD_MONTHS : ''; $specDays = 0; $specDays += $weeks > 0 ? $weeks * Carbon::DAYS_PER_WEEK : 0; $specDays += $days > 0 ? $days : 0; $spec .= ($specDays > 0) ? $specDays.static::PERIOD_DAYS : ''; if ($hours > 0 || $minutes > 0 || $seconds > 0) { $spec .= static::PERIOD_TIME_PREFIX; $spec .= $hours > 0 ? $hours.static::PERIOD_HOURS : ''; $spec .= $minutes > 0 ? $minutes.static::PERIOD_MINUTES : ''; $spec .= $seconds > 0 ? $seconds.static::PERIOD_SECONDS : ''; } parent::__construct($spec); } /** * Create a new CarbonInterval instance from specific values. * This is an alias for the constructor that allows better fluent * syntax as it allows you to do CarbonInterval::create(1)->fn() rather than * (new CarbonInterval(1))->fn(). * * @param integer $years * @param integer $months * @param integer $weeks * @param integer $days * @param integer $hours * @param integer $minutes * @param integer $seconds * * @return static */ public static function create($years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null) { return new static($years, $months, $weeks, $days, $hours, $minutes, $seconds); } /** * Provide static helpers to create instances. Allows CarbonInterval::years(3). * * Note: This is done using the magic method to allow static and instance methods to * have the same names. * * @param string $name * @param array $args * * @return static */ public static function __callStatic($name, $args) { $arg = count($args) == 0 ? 1 : $args[0]; switch ($name) { case 'years': case 'year': return new static($arg); case 'months': case 'month': return new static(null, $arg); case 'weeks': case 'week': return new static(null, null, $arg); case 'days': case 'dayz': case 'day': return new static(null, null, null, $arg); case 'hours': case 'hour': return new static(null, null, null, null, $arg); case 'minutes': case 'minute': return new static(null, null, null, null, null, $arg); case 'seconds': case 'second': return new static(null, null, null, null, null, null, $arg); } } /** * Create a CarbonInterval instance from a DateInterval one. Can not instance * DateInterval objects created from DateTime::diff() as you can't externally * set the $days field. * * @param DateInterval $di * * @throws InvalidArgumentException * * @return static */ public static function instance(DateInterval $di) { if (static::wasCreatedFromDiff($di)) { throw new InvalidArgumentException("Can not instance a DateInterval object created from DateTime::diff()."); } $instance = new static($di->y, $di->m, 0, $di->d, $di->h, $di->i, $di->s); $instance->invert = $di->invert; $instance->days = $di->days; return $instance; } /////////////////////////////////////////////////////////////////// /////////////////////// LOCALIZATION ////////////////////////////// /////////////////////////////////////////////////////////////////// /** * Intialize the translator instance if necessary. * * @return TranslatorInterface */ protected static function translator() { if (static::$translator == null) { static::$translator = new Translator('en'); static::$translator->addLoader('array', new ArrayLoader()); static::setLocale('en'); } return static::$translator; } /** * Get the translator instance in use * * @return TranslatorInterface */ public static function getTranslator() { return static::translator(); } /** * Set the translator instance to use * * @param TranslatorInterface $translator */ public static function setTranslator(TranslatorInterface $translator) { static::$translator = $translator; } /** * Get the current translator locale * * @return string */ public static function getLocale() { return static::translator()->getLocale(); } /** * Set the current translator locale * * @param string $locale */ public static function setLocale($locale) { static::translator()->setLocale($locale); // Ensure the locale has been loaded. static::translator()->addResource('array', require __DIR__.'/Lang/'.$locale.'.php', $locale); } /////////////////////////////////////////////////////////////////// ///////////////////////// GETTERS AND SETTERS ///////////////////// /////////////////////////////////////////////////////////////////// /** * Get a part of the CarbonInterval object * * @param string $name * * @throws InvalidArgumentException * * @return integer */ public function __get($name) { switch ($name) { case 'years': return $this->y; case 'months': return $this->m; case 'dayz': return $this->d; case 'hours': return $this->h; case 'minutes': return $this->i; case 'seconds': return $this->s; case 'weeks': return (int)floor($this->d / Carbon::DAYS_PER_WEEK); case 'daysExcludeWeeks': case 'dayzExcludeWeeks': return $this->d % Carbon::DAYS_PER_WEEK; default: throw new InvalidArgumentException(sprintf("Unknown getter '%s'", $name)); } } /** * Set a part of the CarbonInterval object * * @param string $name * @param integer $val * * @throws InvalidArgumentException */ public function __set($name, $val) { switch ($name) { case 'years': $this->y = $val; break; case 'months': $this->m = $val; break; case 'weeks': $this->d = $val * Carbon::DAYS_PER_WEEK; break; case 'dayz': $this->d = $val; break; case 'hours': $this->h = $val; break; case 'minutes': $this->i = $val; break; case 'seconds': $this->s = $val; break; } } /** * Allow setting of weeks and days to be cumulative. * * @param int $weeks Number of weeks to set * @param int $days Number of days to set * * @return static */ public function weeksAndDays($weeks, $days) { $this->dayz = ($weeks * Carbon::DAYS_PER_WEEK) + $days; return $this; } /** * Allow fluent calls on the setters... CarbonInterval::years(3)->months(5)->day(). * * Note: This is done using the magic method to allow static and instance methods to * have the same names. * * @param string $name * @param array $args * * @return static */ public function __call($name, $args) { $arg = count($args) == 0 ? 1 : $args[0]; switch ($name) { case 'years': case 'year': $this->years = $arg; break; case 'months': case 'month': $this->months = $arg; break; case 'weeks': case 'week': $this->dayz = $arg * Carbon::DAYS_PER_WEEK; break; case 'days': case 'dayz': case 'day': $this->dayz = $arg; break; case 'hours': case 'hour': $this->hours = $arg; break; case 'minutes': case 'minute': $this->minutes = $arg; break; case 'seconds': case 'second': $this->seconds = $arg; break; } return $this; } /** * Get the current interval in a human readable format in the current locale. * * @return string */ public function forHumans() { $periods = array( 'year' => $this->years, 'month' => $this->months, 'week' => $this->weeks, 'day' => $this->daysExcludeWeeks, 'hour' => $this->hours, 'minute' => $this->minutes, 'second' => $this->seconds, ); $parts = array(); foreach ($periods as $unit => $count) { if ($count > 0) { array_push($parts, static::translator()->transChoice($unit, $count, array(':count' => $count))); } } return implode(' ', $parts); } /** * Format the instance as a string using the forHumans() function. * * @return string */ public function __toString() { return $this->forHumans(); } /** * Add the passed interval to the current instance * * @param DateInterval $interval * * @return static */ public function add(DateInterval $interval) { $sign = ($interval->invert === 1) ? -1 : 1; if (static::wasCreatedFromDiff($interval)) { $this->dayz = $this->dayz + ($interval->days * $sign); } else { $this->years = $this->years + ($interval->y * $sign); $this->months = $this->months + ($interval->m * $sign); $this->dayz = $this->dayz + ($interval->d * $sign); $this->hours = $this->hours + ($interval->h * $sign); $this->minutes = $this->minutes + ($interval->i * $sign); $this->seconds = $this->seconds + ($interval->s * $sign); } return $this; } } src/Carbon/Lang/ar.php000064400000002503150145555700010542 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/ar/date.php */ return array( 'year' => '{0}سنة|{1}سنة|{2}سنتين|[3,10]:count سنوات|[11,Inf] سنة', 'month' => '{0}شهر|{1}شهر|{2}شهرين|[3,10]:count أشهر|[11,Inf] شهر', 'week' => '{0}أسبوع|{1}أسبوع|{2}أسبوعين|[3,10]:count أسابيع|[11,Inf] أسبوع', 'day' => '{0}يوم|{1}يوم|{2}يومين|[3,10]:count أيام|[11,Inf] يوم', 'hour' => '{0}ساعة|{1}ساعة|{2}ساعتين|[3,10]:count ساعات|[11,Inf] ساعة', 'minute' => '{0}دقيقة|{1}دقيقة|{2}دقيقتين|[3,10]:count دقائق|[11,Inf]:count دقيقة', 'second' => '{0}ثانية|{1}ثانية|{2}ثانيتين|[3,10]:count ثوان|[11,Inf] ثانية', 'ago' => 'منذ :time', 'from_now' => 'من الآن :time', 'after' => 'بعد :time', 'before' => 'قبل :time', ); src/Carbon/Lang/az.php000064400000001560150145555700010554 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/The-Hasanov/laravel-date/blob/1006f37c431178b5c7219d02c93579c9690ae546/src/Lang/az.php */ return array( 'year' => ':count il', 'month' => ':count ay', 'week' => ':count həftə', 'day' => ':count gün', 'hour' => ':count saat', 'minute' => ':count dəqiqə', 'second' => ':count saniyə', 'ago' => ':time öncə', 'from_now' => ':time sonra', 'after' => ':time sonra', 'before' => ':time öncə' ); src/Carbon/Lang/bg.php000064400000001762150145555700010536 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/bg/date.php */ return array( 'year' => '1 година|:count години', 'month' => '1 месец|:count месеца', 'week' => '1 седмица|:count седмици', 'day' => '1 ден|:count дни', 'hour' => '1 час|:count часа', 'minute' => '1 минута|:count минути', 'second' => '1 секунда|:count секунди', 'ago' => 'преди :time', 'from_now' => ':time от сега', 'after' => 'след :time', 'before' => 'преди :time', ); src/Carbon/Lang/bn.php000064400000002067150145555700010544 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/eu/date.php */ return array( 'year' => '১ বছর|:count বছর', 'month' => '১ মাস|:count মাস', 'week' => '১ সপ্তাহ|:count সপ্তাহ', 'day' => '১ দিন|:count দিন', 'hour' => '১ ঘন্টা|:count ঘন্টা', 'minute' => '১ মিনিট|:count মিনিট', 'second' => '১ সেকেন্ড|:count সেকেন্ড', 'ago' => ':time পূর্বে', 'from_now' => 'এখন থেকে :time', 'after' => ':time পরে', 'before' => ':time আগে', ); src/Carbon/Lang/ca.php000064400000001612150145555700010523 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/ca/date.php */ return array( 'year' => '1 any|:count anys', 'month' => '1 mes|:count mesos', 'week' => '1 setmana|:count setmanes', 'day' => '1 dia|:count díes', 'hour' => '1 hora|:count hores', 'minute' => '1 minut|:count minuts', 'second' => '1 segon|:count segons', 'ago' => 'Fa :time', 'from_now' => 'Dins de :time', 'after' => ':time després', 'before' => ':time abans', ); src/Carbon/Lang/cs.php000064400000001764150145555700010555 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/cs/date.php */ return array( 'year' => '1 rok|:count roky|:count let', 'month' => '1 měsíc|:count měsíce|:count měsíců', 'week' => '1 týden|:count týdny|:count týdnů', 'day' => '1 den|:count dny|:count dní', 'hour' => '1 hodinu|:count hodiny|:count hodin', 'minute' => '1 minutu|:count minuty|:count minut', 'second' => '1 sekundu|:count sekundy|:count sekund', 'ago' => 'před :time', 'from_now' => 'za :time', 'after' => ':time později', 'before' => ':time předtím', ); src/Carbon/Lang/da.php000064400000001441150145555700010524 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => '1 år|:count år', 'month' => '1 måned|:count måneder', 'week' => '1 uge|:count uger', 'day' => '1 dag|:count dage', 'hour' => '1 time|:count timer', 'minute' => '1 minut|:count minutter', 'second' => '1 sekund|:count sekunder', 'ago' => ':time siden', 'from_now' => 'om :time', 'after' => ':time efter', 'before' => ':time før', ); src/Carbon/Lang/de.php000064400000002360150145555700010531 0ustar00 * * This file is released under the terms of CC0. * CC0 is even more permissive than the MIT license, allowing you to use the code in * any manner you want, without any copyright headers, notices, or other attribution. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => '1 Jahr|:count Jahre', 'month' => '1 Monat|:count Monate', 'week' => '1 Woche|:count Wochen', 'day' => '1 Tag|:count Tage', 'hour' => '1 Stunde|:count Stunden', 'minute' => '1 Minute|:count Minuten', 'second' => '1 Sekunde|:count Sekunden', 'ago' => 'vor :time', 'from_now' => 'in :time', 'after' => ':time später', 'before' => ':time zuvor', 'year_from_now' => '1 Jahr|:count Jahren', 'month_from_now' => '1 Monat|:count Monaten', 'week_from_now' => '1 Woche|:count Wochen', 'day_from_now' => '1 Tag|:count Tagen', 'year_ago' => '1 Jahr|:count Jahren', 'month_ago' => '1 Monat|:count Monaten', 'week_ago' => '1 Woche|:count Wochen', 'day_ago' => '1 Tag|:count Tagen', ); src/Carbon/Lang/el.php000064400000002023150145555700010535 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/el/date.php */ return array( 'year' => '1 χρόνος|:count χρόνια', 'month' => '1 μήνας|:count μήνες', 'week' => '1 εβδομάδα|:count εβδομάδες', 'day' => '1 μέρα|:count μέρες', 'hour' => '1 ώρα|:count ώρες', 'minute' => '1 λεπτό|:count λεπτά', 'second' => '1 δευτερόλεπτο|:count δευτερόλεπτα', 'ago' => 'πρίν απο :time', 'from_now' => 'σε :time απο τώρα', 'after' => ':time μετά', 'before' => ':time πρίν' ); src/Carbon/Lang/en.php000064400000001450150145555700010542 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => '1 year|:count years', 'month' => '1 month|:count months', 'week' => '1 week|:count weeks', 'day' => '1 day|:count days', 'hour' => '1 hour|:count hours', 'minute' => '1 minute|:count minutes', 'second' => '1 second|:count seconds', 'ago' => ':time ago', 'from_now' => ':time from now', 'after' => ':time after', 'before' => ':time before', ); src/Carbon/Lang/eo.php000064400000001625150145555700010547 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/eo/date.php */ return array( 'year' => '1 jaro|:count jaroj', 'month' => '1 monato|:count monatoj', 'week' => '1 semajno|:count semajnoj', 'day' => '1 tago|:count tagoj', 'hour' => '1 horo|:count horoj', 'minute' => '1 minuto|:count minutoj', 'second' => '1 sekundo|:count sekundoj', 'ago' => 'antaŭ :time', 'from_now' => 'je :time', 'after' => ':time poste', 'before' => ':time antaŭe' ); src/Carbon/Lang/es.php000064400000001461150145555700010551 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => '1 año|:count años', 'month' => '1 mes|:count meses', 'week' => '1 semana|:count semanas', 'day' => '1 día|:count días', 'hour' => '1 hora|:count horas', 'minute' => '1 minuto|:count minutos', 'second' => '1 segundo|:count segundos', 'ago' => 'hace :time', 'from_now' => 'dentro de :time', 'after' => ':time antes', 'before' => ':time después', ); src/Carbon/Lang/eu.php000064400000001616150145555700010555 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/eu/date.php */ return array( 'year' => 'Urte 1|:count urte', 'month' => 'Hile 1|:count hile', 'week' => 'Aste 1|:count aste', 'day' => 'Egun 1|:count egun', 'hour' => 'Ordu 1|:count ordu', 'minute' => 'Minutu 1|:count minutu', 'second' => 'Segundu 1|:count segundu', 'ago' => 'Orain dela :time', 'from_now' => ':time barru', 'after' => ':time geroago', 'before' => ':time lehenago' ); src/Carbon/Lang/fa.php000064400000001415150145555700010527 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => ':count سال', 'month' => ':count ماه', 'week' => ':count هفته', 'day' => ':count روز', 'hour' => ':count ساعت', 'minute' => ':count دقیقه', 'second' => ':count ثانیه', 'ago' => ':time پیش', 'from_now' => ':time بعد', 'after' => ':time پیش از', 'before' => ':time پس از', ); src/Carbon/Lang/fi.php000064400000001672150145555700010544 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/fi/date.php */ return array( 'year' => '1 vuosi|:count vuotta', 'month' => '1 kuukausi|:count kuukautta', 'week' => '1 viikko|:count viikkoa', 'day' => '1 päivä|:count päivää', 'hour' => '1 tunti|:count tuntia', 'minute' => '1 minuutti|:count minuuttia', 'second' => '1 sekunti|:count sekuntia', 'ago' => ':time sitten', 'from_now' => ':time tästä hetkestä', 'after' => ':time sen jälkeen', 'before' => ':time ennen' ); src/Carbon/Lang/fo.php000064400000001463150145555700010550 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => '1 ár|:count ár', 'month' => '1 mánaður|:count mánaðir', 'week' => '1 vika|:count vikur', 'day' => '1 dag|:count dagar', 'hour' => '1 tími|:count tímar', 'minute' => '1 minutt|:count minuttir', 'second' => '1 sekund|:count sekundir', 'ago' => ':time síðan', 'from_now' => 'um :time', 'after' => ':time aftaná', 'before' => ':time áðrenn', ); src/Carbon/Lang/fr.php000064400000001445150145555700010553 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => '1 an|:count ans', 'month' => ':count mois', 'week' => '1 semaine|:count semaines', 'day' => '1 jour|:count jours', 'hour' => '1 heure|:count heures', 'minute' => '1 minute|:count minutes', 'second' => '1 seconde|:count secondes', 'ago' => 'il y a :time', 'from_now' => 'dans :time', 'after' => ':time après', 'before' => ':time avant', ); src/Carbon/Lang/he.php000064400000001665150145555700010544 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => 'שנה|{2}שנתיים|:count שנים', 'month' => 'חודש|{2}חודשיים|:count חודשים', 'week' => 'שבוע|{2}שבועיים|:count שבועות', 'day' => 'יום|{2}יומיים|:count ימים', 'hour' => 'שעה|{2}שעתיים|:count שעות', 'minute' => 'דקה|{2}דקותיים|:count דקות', 'second' => 'שניה|:count שניות', 'ago' => 'לפני :time', 'from_now' => 'בעוד :time', 'after' => 'אחרי :time', 'before' => 'לפני :time', ); src/Carbon/Lang/hr.php000064400000002016150145555700010550 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/hr/date.php */ return array( 'year' => ':count godinu|:count godine|:count godina', 'month' => ':count mjesec|:count mjeseca|:count mjeseci', 'week' => ':count tjedan|:count tjedna|:count tjedana', 'day' => ':count dan|:count dana|:count dana', 'hour' => ':count sat|:count sata|:count sati', 'minute' => ':count minutu|:count minute |:count minuta', 'second' => ':count sekundu|:count sekunde|:count sekundi', 'ago' => 'prije :time', 'from_now' => 'za :time', 'after' => 'za :time', 'before' => 'prije :time' ); src/Carbon/Lang/hu.php000064400000001700150145555700010552 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/hu/date.php */ return array( 'year' => '1 évvel|:count évvel', 'month' => '1 hónappal|:count hónappal', 'week' => '1 héttel|:count héttel', 'day' => '1 nappal|:count nappal', 'hour' => '1 órával|:count órával', 'minute' => '1 perccel|:count perccel', 'second' => '1 másodperccel|:count másodperccel', 'ago' => ':time korábban', 'from_now' => ':time később', 'after' => ':time később', 'before' => ':time korábban' ); src/Carbon/Lang/id.php000064400000001536150145555700010541 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/id/date.php */ return array( 'year' => ':count tahun', 'month' => ':count bulan', 'week' => ':count minggu', 'day' => ':count hari', 'hour' => ':count jam', 'minute' => ':count menit', 'second' => ':count detik', 'ago' => ':time yang lalu', 'from_now' => ':time dari sekarang', 'after' => ':time setelah', 'before' => ':time sebelum' ); src/Carbon/Lang/it.php000064400000001455150145555700010561 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => '1 anno|:count anni', 'month' => '1 mese|:count mesi', 'week' => '1 settimana|:count settimane', 'day' => '1 giorno|:count giorni', 'hour' => '1 ora|:count ore', 'minute' => '1 minuto|:count minuti', 'second' => '1 secondo|:count secondi', 'ago' => ':time fa', 'from_now' => ':time da adesso', 'after' => ':time dopo', 'before' => ':time prima', ); src/Carbon/Lang/ja.php000064400000001511150145555700010530 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/ja/date.php */ return array( 'year' => ':count 年', 'month' => ':count ヶ月', 'week' => ':count 週間', 'day' => ':count 日', 'hour' => ':count 時間', 'minute' => ':count 分', 'second' => ':count 秒', 'ago' => ':time 前', 'from_now' => '今から :time', 'after' => ':time 後', 'before' => ':time 前' ); src/Carbon/Lang/ko.php000064400000001504150145555700010551 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/cs/date.php */ return array( 'year' => ':count 년', 'month' => ':count 개월', 'week' => ':count 주일', 'day' => ':count 일', 'hour' => ':count 시간', 'minute' => ':count 분', 'second' => ':count 초', 'ago' => ':time 전', 'from_now' => ':time 후', 'after' => ':time 뒤', 'before' => ':time 앞', ); src/Carbon/Lang/lt.php000064400000001663150145555700010565 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => '1 metus|:count metus|:count metų', 'month' => '1 menesį|:count menesius|:count menesių', 'week' => '1 savaitę|:count savaites|:count savaičių', 'day' => '1 dieną|:count dienas|:count dienų', 'hour' => '1 valandą|:count valandas|:count valandų', 'minute' => '1 minutę|:count minutes|:count minučių', 'second' => '1 sekundę|:count sekundes|:count sekundžių', 'ago' => 'prieš :time', 'from_now' => 'už :time', 'after' => 'po :time', 'before' => ':time nuo dabar', );src/Carbon/Lang/lv.php000064400000003536150145555700010570 0ustar00 '0 gadiem|:count gada|:count gadiem', 'month' => '0 mēnešiem|:count mēneša|:count mēnešiem', 'week' => '0 nedēļām|:count nedēļas|:count nedēļām', 'day' => '0 dienām|:count dienas|:count dienām', 'hour' => '0 stundām|:count stundas|:count stundām', 'minute' => '0 minūtēm|:count minūtes|:count minūtēm', 'second' => '0 sekundēm|:count sekundes|:count sekundēm', 'ago' => 'pirms :time', 'from_now' => 'pēc :time', 'after' => ':time vēlāk', 'before' => ':time pirms', 'year_after' => '0 gadus|:count gadu|:count gadus', 'month_after' => '0 mēnešus|:count mēnesi|:count mēnešus', 'week_after' => '0 nedēļas|:count nedēļu|:count nedēļas', 'day_after' => '0 dienas|:count dienu|:count dienas', 'hour_after' => '0 stundas|:count stundu|:count stundas', 'minute_after' => '0 minūtes|:count minūti|:count minūtes', 'second_after' => '0 sekundes|:count sekundi|:count sekundes', 'year_before' => '0 gadus|:count gadu|:count gadus', 'month_before' => '0 mēnešus|:count mēnesi|:count mēnešus', 'week_before' => '0 nedēļas|:count nedēļu|:count nedēļas', 'day_before' => '0 dienas|:count dienu|:count dienas', 'hour_before' => '0 stundas|:count stundu|:count stundas', 'minute_before' => '0 minūtes|:count minūti|:count minūtes', 'second_before' => '0 sekundes|:count sekundi|:count sekundes', ); src/Carbon/Lang/ms.php000064400000001370150145555700010560 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => ':count tahun', 'month' => ':count bulan', 'week' => ':count minggu', 'day' => ':count hari', 'hour' => ':count jam', 'minute' => ':count minit', 'second' => ':count saat', 'ago' => ':time yang lalu', 'from_now' => ':time dari sekarang', 'after' => ':time selepas', 'before' => ':time sebelum', ); src/Carbon/Lang/nl.php000064400000001441150145555700010551 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => '1 jaar|:count jaren', 'month' => '1 maand|:count maanden', 'week' => '1 week|:count weken', 'day' => '1 dag|:count dagen', 'hour' => ':count uur', 'minute' => '1 minuut|:count minuten', 'second' => '1 seconde|:count seconden', 'ago' => ':time geleden', 'from_now' => 'over :time', 'after' => ':time later', 'before' => ':time eerder', ); src/Carbon/Lang/no.php000064400000001606150145555700010557 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/no/date.php */ return array( 'year' => '1 år|:count år', 'month' => '1 måned|:count måneder', 'week' => '1 uke|:count uker', 'day' => '1 dag|:count dager', 'hour' => '1 time|:count timer', 'minute' => '1 minutt|:count minutter', 'second' => '1 sekund|:count sekunder', 'ago' => ':time siden', 'from_now' => 'om :time', 'after' => ':time etter', 'before' => ':time før' ); src/Carbon/Lang/pl.php000064400000001771150145555700010561 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/pl/date.php */ return array( 'year' => '1 rok|:count lata|:count lat', 'month' => '1 miesiąc|:count miesiące|:count miesięcy', 'week' => '1 tydzień|:count tygodnie|:count tygodni', 'day' => '1 dzień|:count dni|:count dni', 'hour' => '1 godzina|:count godziny|:count godzin', 'minute' => '1 minuta|:count minuty|:count minut', 'second' => '1 sekunda|:count sekundy|:count sekund', 'ago' => ':time temu', 'from_now' => ':time od teraz', 'after' => ':time przed', 'before' => ':time po' ); src/Carbon/Lang/pt.php000064400000001612150145555700010563 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/pt/date.php */ return array( 'year' => '1 ano|:count anos', 'month' => '1 mês|:count meses', 'week' => '1 semana|:count semanas', 'day' => '1 dia|:count dias', 'hour' => '1 hora|:count horas', 'minute' => '1 minuto|:count minutos', 'second' => '1 segundo|:count segundos', 'ago' => ':time atrás', 'from_now' => 'em :time', 'after' => ':time depois', 'before' => ':time antes' ); src/Carbon/Lang/pt_BR.php000064400000001451150145555700011147 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => '1 ano|:count anos', 'month' => '1 mês|:count meses', 'week' => '1 semana|:count semanas', 'day' => '1 dia|:count dias', 'hour' => '1 hora|:count horas', 'minute' => '1 minuto|:count minutos', 'second' => '1 segundo|:count segundos', 'ago' => 'há :time', 'from_now' => 'dentro de :time', 'after' => ':time depois', 'before' => ':time antes', ); src/Carbon/Lang/ro.php000064400000001761150145555700010565 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/ro/date.php */ return array( 'year' => 'un an|:count ani|:count ani', 'month' => 'o lună|:count luni|:count luni', 'week' => 'o săptămână|:count săptămâni|:count săptămâni', 'day' => 'o zi|:count zile|:count zile', 'hour' => 'o oră|:count ore|:count ore', 'minute' => 'un minut|:count minute|:count minute', 'second' => 'o secundă|:count secunde|:count secunde', 'ago' => 'acum :time', 'from_now' => ':time de acum', 'after' => 'peste :time', 'before' => 'acum :time' ); src/Carbon/Lang/ru.php000064400000002177150145555700010575 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/ru/date.php */ return array( 'year' => ':count год|:count года|:count лет', 'month' => ':count месяц|:count месяца|:count месяцев', 'week' => ':count неделю|:count недели|:count недель', 'day' => ':count день|:count дня|:count дней', 'hour' => ':count час|:count часа|:count часов', 'minute' => ':count минуту|:count минуты|:count минут', 'second' => ':count секунду|:count секунды|:count секунд', 'ago' => ':time назад', 'from_now' => 'через :time', 'after' => ':time после', 'before' => ':time до' ); src/Carbon/Lang/sk.php000064400000001757150145555700010567 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/sk/date.php */ return array( 'year' => 'rok|:count roky|:count rokov', 'month' => 'mesiac|:count mesiace|:count mesiacov', 'week' => 'týždeň|:count týždne|:count týždňov', 'day' => 'deň|:count dni|:count dní', 'hour' => 'hodinu|:count hodiny|:count hodín', 'minute' => 'minútu|:count minúty|:count minút', 'second' => 'sekundu|:count sekundy|:count sekúnd', 'ago' => 'pred :time', 'from_now' => 'za :time', 'after' => ':time neskôr', 'before' => ':time predtým' ); src/Carbon/Lang/sl.php000064400000003102150145555700010552 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/sl/date.php */ return array( 'year' => ':count leto|:count leti|:count leta|:count let', 'month' => ':count mesec|:count meseca|:count mesece|:count mesecev', 'week' => ':count teden|:count tedna|:count tedne|:count tednov', 'day' => ':count dan|:count dni|:count dni|:count dni', 'hour' => ':count uro|:count uri|:count ure|:count ur', 'minute' => ':count minuto|:count minuti|:count minute|:count minut', 'second' => ':count sekundo|:count sekundi|:count sekunde|:count sekund', 'year_ago' => ':count letom|:count leti|:count leti|:count leti', 'month_ago' => ':count mesecem|:count meseci|:count meseci|:count meseci', 'week_ago' => ':count tednom|:count tednoma|:count tedni|:count tedni', 'day_ago' => ':count dnem|:count dnevoma|:count dnevi|:count dnevi', 'hour_ago' => ':count uro|:count urama|:count urami|:count urami', 'minute_ago'=> ':count minuto|:count minutama|:count minutami|:count minutami', 'second_ago'=> ':count sekundo|:count sekundama|:count sekundami|:count sekundami', 'ago' => 'pred :time', 'from_now' => 'čez :time', 'after' => 'čez :time', 'before' => 'pred :time' ); src/Carbon/Lang/sr.php000064400000002017150145555700010564 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/sr/date.php */ return array( 'year' => ':count godina|:count godine|:count godina', 'month' => ':count mesec|:count meseca|:count meseci', 'week' => ':count nedelja|:count nedelje|:count nedelja', 'day' => ':count dan|:count dana|:count dana', 'hour' => ':count sat|:count sata|:count sati', 'minute' => ':count minut|:count minuta |:count minuta', 'second' => ':count sekund|:count sekunde|:count sekunde', 'ago' => 'pre :time', 'from_now' => ':time od sada', 'after' => 'nakon :time', 'before' => 'pre :time' ); src/Carbon/Lang/sv.php000064400000001613150145555700010571 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/sv/date.php */ return array( 'year' => '1 år|:count år', 'month' => '1 månad|:count månader', 'week' => '1 vecka|:count veckor', 'day' => '1 dag|:count dagar', 'hour' => '1 timme|:count timmar', 'minute' => '1 minut|:count minuter', 'second' => '1 sekund|:count sekunder', 'ago' => ':time sedan', 'from_now' => 'om :time', 'after' => ':time efter', 'before' => ':time före' ); src/Carbon/Lang/th.php000064400000002132150145555700010551 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/th/date.php */ return array( 'year' => '1 ปี|:count ปี', 'month' => '1 เดือน|:count เดือน', 'week' => '1 สัปดาห์|:count สัปดาห์', 'day' => '1 วัน|:count วัน', 'hour' => '1 ชั่วโมง|:count ชั่วโมง', 'minute' => '1 นาที|:count นาที', 'second' => '1 วินาที|:count วินาที', 'ago' => ':time sitten', 'ago' => ':time ที่แล้ว', 'from_now' => ':time จากนี้', 'after' => 'หลัง:time', 'before' => 'ก่อน:time' ); src/Carbon/Lang/tr.php000064400000001362150145555700010567 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => ':count yıl', 'month' => ':count ay', 'week' => ':count hafta', 'day' => ':count gün', 'hour' => ':count saat', 'minute' => ':count dakika', 'second' => ':count saniye', 'ago' => ':time önce', 'from_now' => ':time andan itibaren', 'after' => ':time sonra', 'before' => ':time önce', ); src/Carbon/Lang/uk.php000064400000002225150145555700010560 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/uk/date.php */ return array( 'year' => ':count рік|:count роки|:count років', 'month' => ':count місяць|:count місяці|:count місяців', 'week' => ':count тиждень|:count тижні|:count тижнів', 'day' => ':count день|:count дні|:count днів', 'hour' => ':count година|:count години|:count годин', 'minute' => ':count хвилину|:count хвилини|:count хвилин', 'second' => ':count секунду|:count секунди|:count секунд', 'ago' => ':time назад', 'from_now' => 'через :time', 'after' => ':time після', 'before' => ':time до' ); src/Carbon/Lang/uz.php000064400000001617150145555700010603 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ return array( 'year' => ':count yil|:count yil|:count yil', 'month' => ':count oy|:count oy|:count oylar', 'week' => ':count hafta|:count hafta|:count hafta', 'day' => ':count kun|:count kun|:count kun', 'hour' => ':count soat|:count soat|:count soat', 'minute' => ':count minut|:count minut|:count minut', 'second' => ':count sekund|:count sekund|:count sekund', 'ago' => ':time avval', 'from_now' => 'keyin :time', 'after' => ':time keyin', 'before' => ':time gacha' ); src/Carbon/Lang/vi.php000064400000001537150145555700010564 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/vi/date.php */ return array( 'year' => ':count năm', 'month' => ':count tháng', 'week' => ':count tuần', 'day' => ':count ngày', 'hour' => ':count giờ', 'minute' => ':count phút', 'second' => ':count giây', 'ago' => ':time trước', 'from_now' => ':time từ bây giờ', 'after' => ':time sau', 'before' => ':time trước' ); src/Carbon/Lang/zh-TW.php000064400000001506150145555700011113 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/zh-TW/date.php */ return array( 'year' => ':count 年', 'month' => ':count 月', 'week' => ':count 周', 'day' => ':count 天', 'hour' => ':count 小時', 'minute' => ':count 分鐘', 'second' => ':count 秒', 'ago' => ':time前', 'from_now' => '距現在 :time', 'after' => ':time後', 'before' => ':time前' ); src/Carbon/Lang/zh.php000064400000001473150145555700010566 0ustar00 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Translation messages. See http://symfony.com/doc/current/book/translation.html * for possible formats. * */ /** * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/zh/date.php */ return array( 'year' => ':count年', 'month' => ':count月', 'week' => ':count周', 'day' => ':count天', 'hour' => ':count小时', 'minute' => ':count分钟', 'second' => ':count秒', 'ago' => ':time前', 'from_now' => ':time距现在', 'after' => ':time后', 'before' => ':time前' );