forked from devsam/core
Illuminate: ready. (critical)
- DB에서 illuminate를 가져올 수 있도록 설정 - 업그레이듵 불가, RootDB, DB를 직접 수정해야함
This commit is contained in:
+523
@@ -0,0 +1,523 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon;
|
||||
|
||||
use Carbon\Traits\Date;
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
use DateTimeZone;
|
||||
|
||||
/**
|
||||
* A simple API extension for DateTime.
|
||||
*
|
||||
* <autodoc generated by `composer phpdoc`>
|
||||
*
|
||||
* @property int $year
|
||||
* @property int $yearIso
|
||||
* @property int $month
|
||||
* @property int $day
|
||||
* @property int $hour
|
||||
* @property int $minute
|
||||
* @property int $second
|
||||
* @property int $micro
|
||||
* @property int $microsecond
|
||||
* @property int|float|string $timestamp seconds since the Unix Epoch
|
||||
* @property string $englishDayOfWeek the day of week in English
|
||||
* @property string $shortEnglishDayOfWeek the abbreviated day of week in English
|
||||
* @property string $englishMonth the month in English
|
||||
* @property string $shortEnglishMonth the abbreviated month in English
|
||||
* @property string $localeDayOfWeek the day of week in current locale LC_TIME
|
||||
* @property string $shortLocaleDayOfWeek the abbreviated day of week in current locale LC_TIME
|
||||
* @property string $localeMonth the month in current locale LC_TIME
|
||||
* @property string $shortLocaleMonth the abbreviated month in current locale LC_TIME
|
||||
* @property int $milliseconds
|
||||
* @property int $millisecond
|
||||
* @property int $milli
|
||||
* @property int $week 1 through 53
|
||||
* @property int $isoWeek 1 through 53
|
||||
* @property int $weekYear year according to week format
|
||||
* @property int $isoWeekYear year according to ISO week format
|
||||
* @property int $dayOfYear 1 through 366
|
||||
* @property int $age does a diffInYears() with default parameters
|
||||
* @property int $offset the timezone offset in seconds from UTC
|
||||
* @property int $offsetMinutes the timezone offset in minutes from UTC
|
||||
* @property int $offsetHours the timezone offset in hours from UTC
|
||||
* @property CarbonTimeZone $timezone the current timezone
|
||||
* @property CarbonTimeZone $tz alias of $timezone
|
||||
* @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday)
|
||||
* @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday)
|
||||
* @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday
|
||||
* @property-read int $daysInMonth number of days in the given month
|
||||
* @property-read string $latinMeridiem "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark)
|
||||
* @property-read string $latinUpperMeridiem "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark)
|
||||
* @property-read string $timezoneAbbreviatedName the current timezone abbreviated name
|
||||
* @property-read string $tzAbbrName alias of $timezoneAbbreviatedName
|
||||
* @property-read string $dayName long name of weekday translated according to Carbon locale, in english if no translation available for current language
|
||||
* @property-read string $shortDayName short name of weekday translated according to Carbon locale, in english if no translation available for current language
|
||||
* @property-read string $minDayName very short name of weekday translated according to Carbon locale, in english if no translation available for current language
|
||||
* @property-read string $monthName long name of month translated according to Carbon locale, in english if no translation available for current language
|
||||
* @property-read string $shortMonthName short name of month translated according to Carbon locale, in english if no translation available for current language
|
||||
* @property-read string $meridiem lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
|
||||
* @property-read string $upperMeridiem uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
|
||||
* @property-read int $noZeroHour current hour from 1 to 24
|
||||
* @property-read int $weeksInYear 51 through 53
|
||||
* @property-read int $isoWeeksInYear 51 through 53
|
||||
* @property-read int $weekOfMonth 1 through 5
|
||||
* @property-read int $weekNumberInMonth 1 through 5
|
||||
* @property-read int $firstWeekDay 0 through 6
|
||||
* @property-read int $lastWeekDay 0 through 6
|
||||
* @property-read int $daysInYear 365 or 366
|
||||
* @property-read int $quarter the quarter of this instance, 1 - 4
|
||||
* @property-read int $decade the decade of this instance
|
||||
* @property-read int $century the century of this instance
|
||||
* @property-read int $millennium the millennium of this instance
|
||||
* @property-read bool $dst daylight savings time indicator, true if DST, false otherwise
|
||||
* @property-read bool $local checks if the timezone is local, true if local, false otherwise
|
||||
* @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise
|
||||
* @property-read string $timezoneName the current timezone name
|
||||
* @property-read string $tzName alias of $timezoneName
|
||||
* @property-read string $locale locale of the current instance
|
||||
*
|
||||
* @method bool isUtc() Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.)
|
||||
* @method bool isLocal() Check if the current instance has non-UTC timezone.
|
||||
* @method bool isValid() Check if the current instance is a valid date.
|
||||
* @method bool isDST() Check if the current instance is in a daylight saving time.
|
||||
* @method bool isSunday() Checks if the instance day is sunday.
|
||||
* @method bool isMonday() Checks if the instance day is monday.
|
||||
* @method bool isTuesday() Checks if the instance day is tuesday.
|
||||
* @method bool isWednesday() Checks if the instance day is wednesday.
|
||||
* @method bool isThursday() Checks if the instance day is thursday.
|
||||
* @method bool isFriday() Checks if the instance day is friday.
|
||||
* @method bool isSaturday() Checks if the instance day is saturday.
|
||||
* @method bool isSameYear(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same year as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentYear() Checks if the instance is in the same year as the current moment.
|
||||
* @method bool isNextYear() Checks if the instance is in the same year as the current moment next year.
|
||||
* @method bool isLastYear() Checks if the instance is in the same year as the current moment last year.
|
||||
* @method bool isSameWeek(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same week as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentWeek() Checks if the instance is in the same week as the current moment.
|
||||
* @method bool isNextWeek() Checks if the instance is in the same week as the current moment next week.
|
||||
* @method bool isLastWeek() Checks if the instance is in the same week as the current moment last week.
|
||||
* @method bool isSameDay(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same day as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentDay() Checks if the instance is in the same day as the current moment.
|
||||
* @method bool isNextDay() Checks if the instance is in the same day as the current moment next day.
|
||||
* @method bool isLastDay() Checks if the instance is in the same day as the current moment last day.
|
||||
* @method bool isSameHour(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same hour as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentHour() Checks if the instance is in the same hour as the current moment.
|
||||
* @method bool isNextHour() Checks if the instance is in the same hour as the current moment next hour.
|
||||
* @method bool isLastHour() Checks if the instance is in the same hour as the current moment last hour.
|
||||
* @method bool isSameMinute(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same minute as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentMinute() Checks if the instance is in the same minute as the current moment.
|
||||
* @method bool isNextMinute() Checks if the instance is in the same minute as the current moment next minute.
|
||||
* @method bool isLastMinute() Checks if the instance is in the same minute as the current moment last minute.
|
||||
* @method bool isSameSecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same second as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentSecond() Checks if the instance is in the same second as the current moment.
|
||||
* @method bool isNextSecond() Checks if the instance is in the same second as the current moment next second.
|
||||
* @method bool isLastSecond() Checks if the instance is in the same second as the current moment last second.
|
||||
* @method bool isSameMicro(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentMicro() Checks if the instance is in the same microsecond as the current moment.
|
||||
* @method bool isNextMicro() Checks if the instance is in the same microsecond as the current moment next microsecond.
|
||||
* @method bool isLastMicro() Checks if the instance is in the same microsecond as the current moment last microsecond.
|
||||
* @method bool isSameMicrosecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentMicrosecond() Checks if the instance is in the same microsecond as the current moment.
|
||||
* @method bool isNextMicrosecond() Checks if the instance is in the same microsecond as the current moment next microsecond.
|
||||
* @method bool isLastMicrosecond() Checks if the instance is in the same microsecond as the current moment last microsecond.
|
||||
* @method bool isCurrentMonth() Checks if the instance is in the same month as the current moment.
|
||||
* @method bool isNextMonth() Checks if the instance is in the same month as the current moment next month.
|
||||
* @method bool isLastMonth() Checks if the instance is in the same month as the current moment last month.
|
||||
* @method bool isCurrentQuarter() Checks if the instance is in the same quarter as the current moment.
|
||||
* @method bool isNextQuarter() Checks if the instance is in the same quarter as the current moment next quarter.
|
||||
* @method bool isLastQuarter() Checks if the instance is in the same quarter as the current moment last quarter.
|
||||
* @method bool isSameDecade(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same decade as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentDecade() Checks if the instance is in the same decade as the current moment.
|
||||
* @method bool isNextDecade() Checks if the instance is in the same decade as the current moment next decade.
|
||||
* @method bool isLastDecade() Checks if the instance is in the same decade as the current moment last decade.
|
||||
* @method bool isSameCentury(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same century as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentCentury() Checks if the instance is in the same century as the current moment.
|
||||
* @method bool isNextCentury() Checks if the instance is in the same century as the current moment next century.
|
||||
* @method bool isLastCentury() Checks if the instance is in the same century as the current moment last century.
|
||||
* @method bool isSameMillennium(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same millennium as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentMillennium() Checks if the instance is in the same millennium as the current moment.
|
||||
* @method bool isNextMillennium() Checks if the instance is in the same millennium as the current moment next millennium.
|
||||
* @method bool isLastMillennium() Checks if the instance is in the same millennium as the current moment last millennium.
|
||||
* @method $this years(int $value) Set current instance year to the given value.
|
||||
* @method $this year(int $value) Set current instance year to the given value.
|
||||
* @method $this setYears(int $value) Set current instance year to the given value.
|
||||
* @method $this setYear(int $value) Set current instance year to the given value.
|
||||
* @method $this months(int $value) Set current instance month to the given value.
|
||||
* @method $this month(int $value) Set current instance month to the given value.
|
||||
* @method $this setMonths(int $value) Set current instance month to the given value.
|
||||
* @method $this setMonth(int $value) Set current instance month to the given value.
|
||||
* @method $this days(int $value) Set current instance day to the given value.
|
||||
* @method $this day(int $value) Set current instance day to the given value.
|
||||
* @method $this setDays(int $value) Set current instance day to the given value.
|
||||
* @method $this setDay(int $value) Set current instance day to the given value.
|
||||
* @method $this hours(int $value) Set current instance hour to the given value.
|
||||
* @method $this hour(int $value) Set current instance hour to the given value.
|
||||
* @method $this setHours(int $value) Set current instance hour to the given value.
|
||||
* @method $this setHour(int $value) Set current instance hour to the given value.
|
||||
* @method $this minutes(int $value) Set current instance minute to the given value.
|
||||
* @method $this minute(int $value) Set current instance minute to the given value.
|
||||
* @method $this setMinutes(int $value) Set current instance minute to the given value.
|
||||
* @method $this setMinute(int $value) Set current instance minute to the given value.
|
||||
* @method $this seconds(int $value) Set current instance second to the given value.
|
||||
* @method $this second(int $value) Set current instance second to the given value.
|
||||
* @method $this setSeconds(int $value) Set current instance second to the given value.
|
||||
* @method $this setSecond(int $value) Set current instance second to the given value.
|
||||
* @method $this millis(int $value) Set current instance millisecond to the given value.
|
||||
* @method $this milli(int $value) Set current instance millisecond to the given value.
|
||||
* @method $this setMillis(int $value) Set current instance millisecond to the given value.
|
||||
* @method $this setMilli(int $value) Set current instance millisecond to the given value.
|
||||
* @method $this milliseconds(int $value) Set current instance millisecond to the given value.
|
||||
* @method $this millisecond(int $value) Set current instance millisecond to the given value.
|
||||
* @method $this setMilliseconds(int $value) Set current instance millisecond to the given value.
|
||||
* @method $this setMillisecond(int $value) Set current instance millisecond to the given value.
|
||||
* @method $this micros(int $value) Set current instance microsecond to the given value.
|
||||
* @method $this micro(int $value) Set current instance microsecond to the given value.
|
||||
* @method $this setMicros(int $value) Set current instance microsecond to the given value.
|
||||
* @method $this setMicro(int $value) Set current instance microsecond to the given value.
|
||||
* @method $this microseconds(int $value) Set current instance microsecond to the given value.
|
||||
* @method $this microsecond(int $value) Set current instance microsecond to the given value.
|
||||
* @method $this setMicroseconds(int $value) Set current instance microsecond to the given value.
|
||||
* @method $this setMicrosecond(int $value) Set current instance microsecond to the given value.
|
||||
* @method $this addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addYear() Add one year to the instance (using date interval).
|
||||
* @method $this subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subYear() Sub one year to the instance (using date interval).
|
||||
* @method $this addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addMonth() Add one month to the instance (using date interval).
|
||||
* @method $this subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subMonth() Sub one month to the instance (using date interval).
|
||||
* @method $this addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addDay() Add one day to the instance (using date interval).
|
||||
* @method $this subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subDay() Sub one day to the instance (using date interval).
|
||||
* @method $this addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addHour() Add one hour to the instance (using date interval).
|
||||
* @method $this subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subHour() Sub one hour to the instance (using date interval).
|
||||
* @method $this addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addMinute() Add one minute to the instance (using date interval).
|
||||
* @method $this subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subMinute() Sub one minute to the instance (using date interval).
|
||||
* @method $this addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addSecond() Add one second to the instance (using date interval).
|
||||
* @method $this subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subSecond() Sub one second to the instance (using date interval).
|
||||
* @method $this addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addMilli() Add one millisecond to the instance (using date interval).
|
||||
* @method $this subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subMilli() Sub one millisecond to the instance (using date interval).
|
||||
* @method $this addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addMillisecond() Add one millisecond to the instance (using date interval).
|
||||
* @method $this subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subMillisecond() Sub one millisecond to the instance (using date interval).
|
||||
* @method $this addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addMicro() Add one microsecond to the instance (using date interval).
|
||||
* @method $this subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subMicro() Sub one microsecond to the instance (using date interval).
|
||||
* @method $this addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addMicrosecond() Add one microsecond to the instance (using date interval).
|
||||
* @method $this subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subMicrosecond() Sub one microsecond to the instance (using date interval).
|
||||
* @method $this addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addMillennium() Add one millennium to the instance (using date interval).
|
||||
* @method $this subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subMillennium() Sub one millennium to the instance (using date interval).
|
||||
* @method $this addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addCentury() Add one century to the instance (using date interval).
|
||||
* @method $this subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subCentury() Sub one century to the instance (using date interval).
|
||||
* @method $this addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addDecade() Add one decade to the instance (using date interval).
|
||||
* @method $this subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subDecade() Sub one decade to the instance (using date interval).
|
||||
* @method $this addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addQuarter() Add one quarter to the instance (using date interval).
|
||||
* @method $this subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subQuarter() Sub one quarter to the instance (using date interval).
|
||||
* @method $this addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method $this addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method $this addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addWeek() Add one week to the instance (using date interval).
|
||||
* @method $this subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subWeek() Sub one week to the instance (using date interval).
|
||||
* @method $this addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this addWeekday() Add one weekday to the instance (using date interval).
|
||||
* @method $this subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval).
|
||||
* @method $this subWeekday() Sub one weekday to the instance (using date interval).
|
||||
* @method $this addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealMicro() Add one microsecond to the instance (using timestamp).
|
||||
* @method $this subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealMicro() Sub one microsecond to the instance (using timestamp).
|
||||
* @method CarbonPeriod microsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given.
|
||||
* @method $this addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealMicrosecond() Add one microsecond to the instance (using timestamp).
|
||||
* @method $this subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealMicrosecond() Sub one microsecond to the instance (using timestamp).
|
||||
* @method CarbonPeriod microsecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given.
|
||||
* @method $this addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealMilli() Add one millisecond to the instance (using timestamp).
|
||||
* @method $this subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealMilli() Sub one millisecond to the instance (using timestamp).
|
||||
* @method CarbonPeriod millisUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given.
|
||||
* @method $this addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealMillisecond() Add one millisecond to the instance (using timestamp).
|
||||
* @method $this subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealMillisecond() Sub one millisecond to the instance (using timestamp).
|
||||
* @method CarbonPeriod millisecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given.
|
||||
* @method $this addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealSecond() Add one second to the instance (using timestamp).
|
||||
* @method $this subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealSecond() Sub one second to the instance (using timestamp).
|
||||
* @method CarbonPeriod secondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given.
|
||||
* @method $this addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealMinute() Add one minute to the instance (using timestamp).
|
||||
* @method $this subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealMinute() Sub one minute to the instance (using timestamp).
|
||||
* @method CarbonPeriod minutesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given.
|
||||
* @method $this addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealHour() Add one hour to the instance (using timestamp).
|
||||
* @method $this subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealHour() Sub one hour to the instance (using timestamp).
|
||||
* @method CarbonPeriod hoursUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given.
|
||||
* @method $this addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealDay() Add one day to the instance (using timestamp).
|
||||
* @method $this subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealDay() Sub one day to the instance (using timestamp).
|
||||
* @method CarbonPeriod daysUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given.
|
||||
* @method $this addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealWeek() Add one week to the instance (using timestamp).
|
||||
* @method $this subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealWeek() Sub one week to the instance (using timestamp).
|
||||
* @method CarbonPeriod weeksUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given.
|
||||
* @method $this addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealMonth() Add one month to the instance (using timestamp).
|
||||
* @method $this subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealMonth() Sub one month to the instance (using timestamp).
|
||||
* @method CarbonPeriod monthsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given.
|
||||
* @method $this addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealQuarter() Add one quarter to the instance (using timestamp).
|
||||
* @method $this subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealQuarter() Sub one quarter to the instance (using timestamp).
|
||||
* @method CarbonPeriod quartersUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given.
|
||||
* @method $this addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealYear() Add one year to the instance (using timestamp).
|
||||
* @method $this subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealYear() Sub one year to the instance (using timestamp).
|
||||
* @method CarbonPeriod yearsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given.
|
||||
* @method $this addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealDecade() Add one decade to the instance (using timestamp).
|
||||
* @method $this subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealDecade() Sub one decade to the instance (using timestamp).
|
||||
* @method CarbonPeriod decadesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given.
|
||||
* @method $this addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealCentury() Add one century to the instance (using timestamp).
|
||||
* @method $this subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealCentury() Sub one century to the instance (using timestamp).
|
||||
* @method CarbonPeriod centuriesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given.
|
||||
* @method $this addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this addRealMillennium() Add one millennium to the instance (using timestamp).
|
||||
* @method $this subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp).
|
||||
* @method $this subRealMillennium() Sub one millennium to the instance (using timestamp).
|
||||
* @method CarbonPeriod millenniaUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given.
|
||||
* @method $this roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
|
||||
* @method $this roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
|
||||
* @method $this floorYear(float $precision = 1) Truncate the current instance year with given precision.
|
||||
* @method $this floorYears(float $precision = 1) Truncate the current instance year with given precision.
|
||||
* @method $this ceilYear(float $precision = 1) Ceil the current instance year with given precision.
|
||||
* @method $this ceilYears(float $precision = 1) Ceil the current instance year with given precision.
|
||||
* @method $this roundMonth(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
|
||||
* @method $this roundMonths(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
|
||||
* @method $this floorMonth(float $precision = 1) Truncate the current instance month with given precision.
|
||||
* @method $this floorMonths(float $precision = 1) Truncate the current instance month with given precision.
|
||||
* @method $this ceilMonth(float $precision = 1) Ceil the current instance month with given precision.
|
||||
* @method $this ceilMonths(float $precision = 1) Ceil the current instance month with given precision.
|
||||
* @method $this roundDay(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method $this roundDays(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method $this floorDay(float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method $this floorDays(float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method $this ceilDay(float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method $this ceilDays(float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method $this roundHour(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
|
||||
* @method $this roundHours(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
|
||||
* @method $this floorHour(float $precision = 1) Truncate the current instance hour with given precision.
|
||||
* @method $this floorHours(float $precision = 1) Truncate the current instance hour with given precision.
|
||||
* @method $this ceilHour(float $precision = 1) Ceil the current instance hour with given precision.
|
||||
* @method $this ceilHours(float $precision = 1) Ceil the current instance hour with given precision.
|
||||
* @method $this roundMinute(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
|
||||
* @method $this roundMinutes(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
|
||||
* @method $this floorMinute(float $precision = 1) Truncate the current instance minute with given precision.
|
||||
* @method $this floorMinutes(float $precision = 1) Truncate the current instance minute with given precision.
|
||||
* @method $this ceilMinute(float $precision = 1) Ceil the current instance minute with given precision.
|
||||
* @method $this ceilMinutes(float $precision = 1) Ceil the current instance minute with given precision.
|
||||
* @method $this roundSecond(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
|
||||
* @method $this roundSeconds(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
|
||||
* @method $this floorSecond(float $precision = 1) Truncate the current instance second with given precision.
|
||||
* @method $this floorSeconds(float $precision = 1) Truncate the current instance second with given precision.
|
||||
* @method $this ceilSecond(float $precision = 1) Ceil the current instance second with given precision.
|
||||
* @method $this ceilSeconds(float $precision = 1) Ceil the current instance second with given precision.
|
||||
* @method $this roundMillennium(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
|
||||
* @method $this roundMillennia(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
|
||||
* @method $this floorMillennium(float $precision = 1) Truncate the current instance millennium with given precision.
|
||||
* @method $this floorMillennia(float $precision = 1) Truncate the current instance millennium with given precision.
|
||||
* @method $this ceilMillennium(float $precision = 1) Ceil the current instance millennium with given precision.
|
||||
* @method $this ceilMillennia(float $precision = 1) Ceil the current instance millennium with given precision.
|
||||
* @method $this roundCentury(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
|
||||
* @method $this roundCenturies(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
|
||||
* @method $this floorCentury(float $precision = 1) Truncate the current instance century with given precision.
|
||||
* @method $this floorCenturies(float $precision = 1) Truncate the current instance century with given precision.
|
||||
* @method $this ceilCentury(float $precision = 1) Ceil the current instance century with given precision.
|
||||
* @method $this ceilCenturies(float $precision = 1) Ceil the current instance century with given precision.
|
||||
* @method $this roundDecade(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
|
||||
* @method $this roundDecades(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
|
||||
* @method $this floorDecade(float $precision = 1) Truncate the current instance decade with given precision.
|
||||
* @method $this floorDecades(float $precision = 1) Truncate the current instance decade with given precision.
|
||||
* @method $this ceilDecade(float $precision = 1) Ceil the current instance decade with given precision.
|
||||
* @method $this ceilDecades(float $precision = 1) Ceil the current instance decade with given precision.
|
||||
* @method $this roundQuarter(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
|
||||
* @method $this roundQuarters(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
|
||||
* @method $this floorQuarter(float $precision = 1) Truncate the current instance quarter with given precision.
|
||||
* @method $this floorQuarters(float $precision = 1) Truncate the current instance quarter with given precision.
|
||||
* @method $this ceilQuarter(float $precision = 1) Ceil the current instance quarter with given precision.
|
||||
* @method $this ceilQuarters(float $precision = 1) Ceil the current instance quarter with given precision.
|
||||
* @method $this roundMillisecond(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
|
||||
* @method $this roundMilliseconds(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
|
||||
* @method $this floorMillisecond(float $precision = 1) Truncate the current instance millisecond with given precision.
|
||||
* @method $this floorMilliseconds(float $precision = 1) Truncate the current instance millisecond with given precision.
|
||||
* @method $this ceilMillisecond(float $precision = 1) Ceil the current instance millisecond with given precision.
|
||||
* @method $this ceilMilliseconds(float $precision = 1) Ceil the current instance millisecond with given precision.
|
||||
* @method $this roundMicrosecond(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
|
||||
* @method $this roundMicroseconds(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
|
||||
* @method $this floorMicrosecond(float $precision = 1) Truncate the current instance microsecond with given precision.
|
||||
* @method $this floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision.
|
||||
* @method $this ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision.
|
||||
* @method $this ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision.
|
||||
* @method string shortAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string longAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string shortRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string longRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string shortRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string longRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string shortRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string longRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method static Carbon|false createFromFormat(string $format, string $time, string|DateTimeZone $timezone = null) Parse a string into a new Carbon object according to the specified format.
|
||||
* @method static Carbon __set_state(array $array) https://php.net/manual/en/datetime.set-state.php
|
||||
*
|
||||
* </autodoc>
|
||||
*/
|
||||
class Carbon extends DateTime implements CarbonInterface
|
||||
{
|
||||
use Date;
|
||||
|
||||
/**
|
||||
* Returns true if the current class/instance is mutable.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isMutable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon;
|
||||
|
||||
use DateTimeInterface;
|
||||
|
||||
interface CarbonConverterInterface
|
||||
{
|
||||
public function convertDate(DateTimeInterface $dateTime, bool $negated = false): CarbonInterface;
|
||||
}
|
||||
+582
@@ -0,0 +1,582 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon;
|
||||
|
||||
use Carbon\Traits\Date;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use DateTimeZone;
|
||||
|
||||
/**
|
||||
* A simple API extension for DateTimeImmutable.
|
||||
*
|
||||
* <autodoc generated by `composer phpdoc`>
|
||||
*
|
||||
* @property int $year
|
||||
* @property int $yearIso
|
||||
* @property int $month
|
||||
* @property int $day
|
||||
* @property int $hour
|
||||
* @property int $minute
|
||||
* @property int $second
|
||||
* @property int $micro
|
||||
* @property int $microsecond
|
||||
* @property int|float|string $timestamp seconds since the Unix Epoch
|
||||
* @property string $englishDayOfWeek the day of week in English
|
||||
* @property string $shortEnglishDayOfWeek the abbreviated day of week in English
|
||||
* @property string $englishMonth the month in English
|
||||
* @property string $shortEnglishMonth the abbreviated month in English
|
||||
* @property string $localeDayOfWeek the day of week in current locale LC_TIME
|
||||
* @property string $shortLocaleDayOfWeek the abbreviated day of week in current locale LC_TIME
|
||||
* @property string $localeMonth the month in current locale LC_TIME
|
||||
* @property string $shortLocaleMonth the abbreviated month in current locale LC_TIME
|
||||
* @property int $milliseconds
|
||||
* @property int $millisecond
|
||||
* @property int $milli
|
||||
* @property int $week 1 through 53
|
||||
* @property int $isoWeek 1 through 53
|
||||
* @property int $weekYear year according to week format
|
||||
* @property int $isoWeekYear year according to ISO week format
|
||||
* @property int $dayOfYear 1 through 366
|
||||
* @property int $age does a diffInYears() with default parameters
|
||||
* @property int $offset the timezone offset in seconds from UTC
|
||||
* @property int $offsetMinutes the timezone offset in minutes from UTC
|
||||
* @property int $offsetHours the timezone offset in hours from UTC
|
||||
* @property CarbonTimeZone $timezone the current timezone
|
||||
* @property CarbonTimeZone $tz alias of $timezone
|
||||
* @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday)
|
||||
* @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday)
|
||||
* @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday
|
||||
* @property-read int $daysInMonth number of days in the given month
|
||||
* @property-read string $latinMeridiem "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark)
|
||||
* @property-read string $latinUpperMeridiem "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark)
|
||||
* @property-read string $timezoneAbbreviatedName the current timezone abbreviated name
|
||||
* @property-read string $tzAbbrName alias of $timezoneAbbreviatedName
|
||||
* @property-read string $dayName long name of weekday translated according to Carbon locale, in english if no translation available for current language
|
||||
* @property-read string $shortDayName short name of weekday translated according to Carbon locale, in english if no translation available for current language
|
||||
* @property-read string $minDayName very short name of weekday translated according to Carbon locale, in english if no translation available for current language
|
||||
* @property-read string $monthName long name of month translated according to Carbon locale, in english if no translation available for current language
|
||||
* @property-read string $shortMonthName short name of month translated according to Carbon locale, in english if no translation available for current language
|
||||
* @property-read string $meridiem lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
|
||||
* @property-read string $upperMeridiem uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
|
||||
* @property-read int $noZeroHour current hour from 1 to 24
|
||||
* @property-read int $weeksInYear 51 through 53
|
||||
* @property-read int $isoWeeksInYear 51 through 53
|
||||
* @property-read int $weekOfMonth 1 through 5
|
||||
* @property-read int $weekNumberInMonth 1 through 5
|
||||
* @property-read int $firstWeekDay 0 through 6
|
||||
* @property-read int $lastWeekDay 0 through 6
|
||||
* @property-read int $daysInYear 365 or 366
|
||||
* @property-read int $quarter the quarter of this instance, 1 - 4
|
||||
* @property-read int $decade the decade of this instance
|
||||
* @property-read int $century the century of this instance
|
||||
* @property-read int $millennium the millennium of this instance
|
||||
* @property-read bool $dst daylight savings time indicator, true if DST, false otherwise
|
||||
* @property-read bool $local checks if the timezone is local, true if local, false otherwise
|
||||
* @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise
|
||||
* @property-read string $timezoneName the current timezone name
|
||||
* @property-read string $tzName alias of $timezoneName
|
||||
* @property-read string $locale locale of the current instance
|
||||
*
|
||||
* @method bool isUtc() Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.)
|
||||
* @method bool isLocal() Check if the current instance has non-UTC timezone.
|
||||
* @method bool isValid() Check if the current instance is a valid date.
|
||||
* @method bool isDST() Check if the current instance is in a daylight saving time.
|
||||
* @method bool isSunday() Checks if the instance day is sunday.
|
||||
* @method bool isMonday() Checks if the instance day is monday.
|
||||
* @method bool isTuesday() Checks if the instance day is tuesday.
|
||||
* @method bool isWednesday() Checks if the instance day is wednesday.
|
||||
* @method bool isThursday() Checks if the instance day is thursday.
|
||||
* @method bool isFriday() Checks if the instance day is friday.
|
||||
* @method bool isSaturday() Checks if the instance day is saturday.
|
||||
* @method bool isSameYear(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same year as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentYear() Checks if the instance is in the same year as the current moment.
|
||||
* @method bool isNextYear() Checks if the instance is in the same year as the current moment next year.
|
||||
* @method bool isLastYear() Checks if the instance is in the same year as the current moment last year.
|
||||
* @method bool isSameWeek(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same week as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentWeek() Checks if the instance is in the same week as the current moment.
|
||||
* @method bool isNextWeek() Checks if the instance is in the same week as the current moment next week.
|
||||
* @method bool isLastWeek() Checks if the instance is in the same week as the current moment last week.
|
||||
* @method bool isSameDay(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same day as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentDay() Checks if the instance is in the same day as the current moment.
|
||||
* @method bool isNextDay() Checks if the instance is in the same day as the current moment next day.
|
||||
* @method bool isLastDay() Checks if the instance is in the same day as the current moment last day.
|
||||
* @method bool isSameHour(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same hour as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentHour() Checks if the instance is in the same hour as the current moment.
|
||||
* @method bool isNextHour() Checks if the instance is in the same hour as the current moment next hour.
|
||||
* @method bool isLastHour() Checks if the instance is in the same hour as the current moment last hour.
|
||||
* @method bool isSameMinute(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same minute as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentMinute() Checks if the instance is in the same minute as the current moment.
|
||||
* @method bool isNextMinute() Checks if the instance is in the same minute as the current moment next minute.
|
||||
* @method bool isLastMinute() Checks if the instance is in the same minute as the current moment last minute.
|
||||
* @method bool isSameSecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same second as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentSecond() Checks if the instance is in the same second as the current moment.
|
||||
* @method bool isNextSecond() Checks if the instance is in the same second as the current moment next second.
|
||||
* @method bool isLastSecond() Checks if the instance is in the same second as the current moment last second.
|
||||
* @method bool isSameMicro(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentMicro() Checks if the instance is in the same microsecond as the current moment.
|
||||
* @method bool isNextMicro() Checks if the instance is in the same microsecond as the current moment next microsecond.
|
||||
* @method bool isLastMicro() Checks if the instance is in the same microsecond as the current moment last microsecond.
|
||||
* @method bool isSameMicrosecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentMicrosecond() Checks if the instance is in the same microsecond as the current moment.
|
||||
* @method bool isNextMicrosecond() Checks if the instance is in the same microsecond as the current moment next microsecond.
|
||||
* @method bool isLastMicrosecond() Checks if the instance is in the same microsecond as the current moment last microsecond.
|
||||
* @method bool isCurrentMonth() Checks if the instance is in the same month as the current moment.
|
||||
* @method bool isNextMonth() Checks if the instance is in the same month as the current moment next month.
|
||||
* @method bool isLastMonth() Checks if the instance is in the same month as the current moment last month.
|
||||
* @method bool isCurrentQuarter() Checks if the instance is in the same quarter as the current moment.
|
||||
* @method bool isNextQuarter() Checks if the instance is in the same quarter as the current moment next quarter.
|
||||
* @method bool isLastQuarter() Checks if the instance is in the same quarter as the current moment last quarter.
|
||||
* @method bool isSameDecade(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same decade as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentDecade() Checks if the instance is in the same decade as the current moment.
|
||||
* @method bool isNextDecade() Checks if the instance is in the same decade as the current moment next decade.
|
||||
* @method bool isLastDecade() Checks if the instance is in the same decade as the current moment last decade.
|
||||
* @method bool isSameCentury(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same century as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentCentury() Checks if the instance is in the same century as the current moment.
|
||||
* @method bool isNextCentury() Checks if the instance is in the same century as the current moment next century.
|
||||
* @method bool isLastCentury() Checks if the instance is in the same century as the current moment last century.
|
||||
* @method bool isSameMillennium(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same millennium as the instance. If null passed, compare to now (with the same timezone).
|
||||
* @method bool isCurrentMillennium() Checks if the instance is in the same millennium as the current moment.
|
||||
* @method bool isNextMillennium() Checks if the instance is in the same millennium as the current moment next millennium.
|
||||
* @method bool isLastMillennium() Checks if the instance is in the same millennium as the current moment last millennium.
|
||||
* @method CarbonImmutable years(int $value) Set current instance year to the given value.
|
||||
* @method CarbonImmutable year(int $value) Set current instance year to the given value.
|
||||
* @method CarbonImmutable setYears(int $value) Set current instance year to the given value.
|
||||
* @method CarbonImmutable setYear(int $value) Set current instance year to the given value.
|
||||
* @method CarbonImmutable months(int $value) Set current instance month to the given value.
|
||||
* @method CarbonImmutable month(int $value) Set current instance month to the given value.
|
||||
* @method CarbonImmutable setMonths(int $value) Set current instance month to the given value.
|
||||
* @method CarbonImmutable setMonth(int $value) Set current instance month to the given value.
|
||||
* @method CarbonImmutable days(int $value) Set current instance day to the given value.
|
||||
* @method CarbonImmutable day(int $value) Set current instance day to the given value.
|
||||
* @method CarbonImmutable setDays(int $value) Set current instance day to the given value.
|
||||
* @method CarbonImmutable setDay(int $value) Set current instance day to the given value.
|
||||
* @method CarbonImmutable hours(int $value) Set current instance hour to the given value.
|
||||
* @method CarbonImmutable hour(int $value) Set current instance hour to the given value.
|
||||
* @method CarbonImmutable setHours(int $value) Set current instance hour to the given value.
|
||||
* @method CarbonImmutable setHour(int $value) Set current instance hour to the given value.
|
||||
* @method CarbonImmutable minutes(int $value) Set current instance minute to the given value.
|
||||
* @method CarbonImmutable minute(int $value) Set current instance minute to the given value.
|
||||
* @method CarbonImmutable setMinutes(int $value) Set current instance minute to the given value.
|
||||
* @method CarbonImmutable setMinute(int $value) Set current instance minute to the given value.
|
||||
* @method CarbonImmutable seconds(int $value) Set current instance second to the given value.
|
||||
* @method CarbonImmutable second(int $value) Set current instance second to the given value.
|
||||
* @method CarbonImmutable setSeconds(int $value) Set current instance second to the given value.
|
||||
* @method CarbonImmutable setSecond(int $value) Set current instance second to the given value.
|
||||
* @method CarbonImmutable millis(int $value) Set current instance millisecond to the given value.
|
||||
* @method CarbonImmutable milli(int $value) Set current instance millisecond to the given value.
|
||||
* @method CarbonImmutable setMillis(int $value) Set current instance millisecond to the given value.
|
||||
* @method CarbonImmutable setMilli(int $value) Set current instance millisecond to the given value.
|
||||
* @method CarbonImmutable milliseconds(int $value) Set current instance millisecond to the given value.
|
||||
* @method CarbonImmutable millisecond(int $value) Set current instance millisecond to the given value.
|
||||
* @method CarbonImmutable setMilliseconds(int $value) Set current instance millisecond to the given value.
|
||||
* @method CarbonImmutable setMillisecond(int $value) Set current instance millisecond to the given value.
|
||||
* @method CarbonImmutable micros(int $value) Set current instance microsecond to the given value.
|
||||
* @method CarbonImmutable micro(int $value) Set current instance microsecond to the given value.
|
||||
* @method CarbonImmutable setMicros(int $value) Set current instance microsecond to the given value.
|
||||
* @method CarbonImmutable setMicro(int $value) Set current instance microsecond to the given value.
|
||||
* @method CarbonImmutable microseconds(int $value) Set current instance microsecond to the given value.
|
||||
* @method CarbonImmutable microsecond(int $value) Set current instance microsecond to the given value.
|
||||
* @method CarbonImmutable setMicroseconds(int $value) Set current instance microsecond to the given value.
|
||||
* @method CarbonImmutable setMicrosecond(int $value) Set current instance microsecond to the given value.
|
||||
* @method CarbonImmutable addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addYear() Add one year to the instance (using date interval).
|
||||
* @method CarbonImmutable subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subYear() Sub one year to the instance (using date interval).
|
||||
* @method CarbonImmutable addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addMonth() Add one month to the instance (using date interval).
|
||||
* @method CarbonImmutable subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subMonth() Sub one month to the instance (using date interval).
|
||||
* @method CarbonImmutable addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addDay() Add one day to the instance (using date interval).
|
||||
* @method CarbonImmutable subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subDay() Sub one day to the instance (using date interval).
|
||||
* @method CarbonImmutable addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addHour() Add one hour to the instance (using date interval).
|
||||
* @method CarbonImmutable subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subHour() Sub one hour to the instance (using date interval).
|
||||
* @method CarbonImmutable addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addMinute() Add one minute to the instance (using date interval).
|
||||
* @method CarbonImmutable subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subMinute() Sub one minute to the instance (using date interval).
|
||||
* @method CarbonImmutable addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addSecond() Add one second to the instance (using date interval).
|
||||
* @method CarbonImmutable subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subSecond() Sub one second to the instance (using date interval).
|
||||
* @method CarbonImmutable addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addMilli() Add one millisecond to the instance (using date interval).
|
||||
* @method CarbonImmutable subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subMilli() Sub one millisecond to the instance (using date interval).
|
||||
* @method CarbonImmutable addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addMillisecond() Add one millisecond to the instance (using date interval).
|
||||
* @method CarbonImmutable subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subMillisecond() Sub one millisecond to the instance (using date interval).
|
||||
* @method CarbonImmutable addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addMicro() Add one microsecond to the instance (using date interval).
|
||||
* @method CarbonImmutable subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subMicro() Sub one microsecond to the instance (using date interval).
|
||||
* @method CarbonImmutable addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addMicrosecond() Add one microsecond to the instance (using date interval).
|
||||
* @method CarbonImmutable subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subMicrosecond() Sub one microsecond to the instance (using date interval).
|
||||
* @method CarbonImmutable addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addMillennium() Add one millennium to the instance (using date interval).
|
||||
* @method CarbonImmutable subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subMillennium() Sub one millennium to the instance (using date interval).
|
||||
* @method CarbonImmutable addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addCentury() Add one century to the instance (using date interval).
|
||||
* @method CarbonImmutable subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subCentury() Sub one century to the instance (using date interval).
|
||||
* @method CarbonImmutable addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addDecade() Add one decade to the instance (using date interval).
|
||||
* @method CarbonImmutable subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subDecade() Sub one decade to the instance (using date interval).
|
||||
* @method CarbonImmutable addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addQuarter() Add one quarter to the instance (using date interval).
|
||||
* @method CarbonImmutable subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subQuarter() Sub one quarter to the instance (using date interval).
|
||||
* @method CarbonImmutable addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed.
|
||||
* @method CarbonImmutable addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
|
||||
* @method CarbonImmutable addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addWeek() Add one week to the instance (using date interval).
|
||||
* @method CarbonImmutable subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subWeek() Sub one week to the instance (using date interval).
|
||||
* @method CarbonImmutable addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable addWeekday() Add one weekday to the instance (using date interval).
|
||||
* @method CarbonImmutable subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval).
|
||||
* @method CarbonImmutable subWeekday() Sub one weekday to the instance (using date interval).
|
||||
* @method CarbonImmutable addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealMicro() Add one microsecond to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMicro() Sub one microsecond to the instance (using timestamp).
|
||||
* @method CarbonPeriod microsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given.
|
||||
* @method CarbonImmutable addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealMicrosecond() Add one microsecond to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMicrosecond() Sub one microsecond to the instance (using timestamp).
|
||||
* @method CarbonPeriod microsecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given.
|
||||
* @method CarbonImmutable addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealMilli() Add one millisecond to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMilli() Sub one millisecond to the instance (using timestamp).
|
||||
* @method CarbonPeriod millisUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given.
|
||||
* @method CarbonImmutable addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealMillisecond() Add one millisecond to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMillisecond() Sub one millisecond to the instance (using timestamp).
|
||||
* @method CarbonPeriod millisecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given.
|
||||
* @method CarbonImmutable addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealSecond() Add one second to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealSecond() Sub one second to the instance (using timestamp).
|
||||
* @method CarbonPeriod secondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given.
|
||||
* @method CarbonImmutable addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealMinute() Add one minute to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMinute() Sub one minute to the instance (using timestamp).
|
||||
* @method CarbonPeriod minutesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given.
|
||||
* @method CarbonImmutable addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealHour() Add one hour to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealHour() Sub one hour to the instance (using timestamp).
|
||||
* @method CarbonPeriod hoursUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given.
|
||||
* @method CarbonImmutable addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealDay() Add one day to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealDay() Sub one day to the instance (using timestamp).
|
||||
* @method CarbonPeriod daysUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given.
|
||||
* @method CarbonImmutable addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealWeek() Add one week to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealWeek() Sub one week to the instance (using timestamp).
|
||||
* @method CarbonPeriod weeksUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given.
|
||||
* @method CarbonImmutable addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealMonth() Add one month to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMonth() Sub one month to the instance (using timestamp).
|
||||
* @method CarbonPeriod monthsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given.
|
||||
* @method CarbonImmutable addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealQuarter() Add one quarter to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealQuarter() Sub one quarter to the instance (using timestamp).
|
||||
* @method CarbonPeriod quartersUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given.
|
||||
* @method CarbonImmutable addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealYear() Add one year to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealYear() Sub one year to the instance (using timestamp).
|
||||
* @method CarbonPeriod yearsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given.
|
||||
* @method CarbonImmutable addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealDecade() Add one decade to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealDecade() Sub one decade to the instance (using timestamp).
|
||||
* @method CarbonPeriod decadesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given.
|
||||
* @method CarbonImmutable addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealCentury() Add one century to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealCentury() Sub one century to the instance (using timestamp).
|
||||
* @method CarbonPeriod centuriesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given.
|
||||
* @method CarbonImmutable addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable addRealMillennium() Add one millennium to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp).
|
||||
* @method CarbonImmutable subRealMillennium() Sub one millennium to the instance (using timestamp).
|
||||
* @method CarbonPeriod millenniaUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given.
|
||||
* @method CarbonImmutable roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
|
||||
* @method CarbonImmutable roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
|
||||
* @method CarbonImmutable floorYear(float $precision = 1) Truncate the current instance year with given precision.
|
||||
* @method CarbonImmutable floorYears(float $precision = 1) Truncate the current instance year with given precision.
|
||||
* @method CarbonImmutable ceilYear(float $precision = 1) Ceil the current instance year with given precision.
|
||||
* @method CarbonImmutable ceilYears(float $precision = 1) Ceil the current instance year with given precision.
|
||||
* @method CarbonImmutable roundMonth(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
|
||||
* @method CarbonImmutable roundMonths(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
|
||||
* @method CarbonImmutable floorMonth(float $precision = 1) Truncate the current instance month with given precision.
|
||||
* @method CarbonImmutable floorMonths(float $precision = 1) Truncate the current instance month with given precision.
|
||||
* @method CarbonImmutable ceilMonth(float $precision = 1) Ceil the current instance month with given precision.
|
||||
* @method CarbonImmutable ceilMonths(float $precision = 1) Ceil the current instance month with given precision.
|
||||
* @method CarbonImmutable roundDay(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method CarbonImmutable roundDays(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method CarbonImmutable floorDay(float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method CarbonImmutable floorDays(float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method CarbonImmutable ceilDay(float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method CarbonImmutable ceilDays(float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method CarbonImmutable roundHour(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
|
||||
* @method CarbonImmutable roundHours(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
|
||||
* @method CarbonImmutable floorHour(float $precision = 1) Truncate the current instance hour with given precision.
|
||||
* @method CarbonImmutable floorHours(float $precision = 1) Truncate the current instance hour with given precision.
|
||||
* @method CarbonImmutable ceilHour(float $precision = 1) Ceil the current instance hour with given precision.
|
||||
* @method CarbonImmutable ceilHours(float $precision = 1) Ceil the current instance hour with given precision.
|
||||
* @method CarbonImmutable roundMinute(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
|
||||
* @method CarbonImmutable roundMinutes(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
|
||||
* @method CarbonImmutable floorMinute(float $precision = 1) Truncate the current instance minute with given precision.
|
||||
* @method CarbonImmutable floorMinutes(float $precision = 1) Truncate the current instance minute with given precision.
|
||||
* @method CarbonImmutable ceilMinute(float $precision = 1) Ceil the current instance minute with given precision.
|
||||
* @method CarbonImmutable ceilMinutes(float $precision = 1) Ceil the current instance minute with given precision.
|
||||
* @method CarbonImmutable roundSecond(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
|
||||
* @method CarbonImmutable roundSeconds(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
|
||||
* @method CarbonImmutable floorSecond(float $precision = 1) Truncate the current instance second with given precision.
|
||||
* @method CarbonImmutable floorSeconds(float $precision = 1) Truncate the current instance second with given precision.
|
||||
* @method CarbonImmutable ceilSecond(float $precision = 1) Ceil the current instance second with given precision.
|
||||
* @method CarbonImmutable ceilSeconds(float $precision = 1) Ceil the current instance second with given precision.
|
||||
* @method CarbonImmutable roundMillennium(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
|
||||
* @method CarbonImmutable roundMillennia(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
|
||||
* @method CarbonImmutable floorMillennium(float $precision = 1) Truncate the current instance millennium with given precision.
|
||||
* @method CarbonImmutable floorMillennia(float $precision = 1) Truncate the current instance millennium with given precision.
|
||||
* @method CarbonImmutable ceilMillennium(float $precision = 1) Ceil the current instance millennium with given precision.
|
||||
* @method CarbonImmutable ceilMillennia(float $precision = 1) Ceil the current instance millennium with given precision.
|
||||
* @method CarbonImmutable roundCentury(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
|
||||
* @method CarbonImmutable roundCenturies(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
|
||||
* @method CarbonImmutable floorCentury(float $precision = 1) Truncate the current instance century with given precision.
|
||||
* @method CarbonImmutable floorCenturies(float $precision = 1) Truncate the current instance century with given precision.
|
||||
* @method CarbonImmutable ceilCentury(float $precision = 1) Ceil the current instance century with given precision.
|
||||
* @method CarbonImmutable ceilCenturies(float $precision = 1) Ceil the current instance century with given precision.
|
||||
* @method CarbonImmutable roundDecade(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
|
||||
* @method CarbonImmutable roundDecades(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
|
||||
* @method CarbonImmutable floorDecade(float $precision = 1) Truncate the current instance decade with given precision.
|
||||
* @method CarbonImmutable floorDecades(float $precision = 1) Truncate the current instance decade with given precision.
|
||||
* @method CarbonImmutable ceilDecade(float $precision = 1) Ceil the current instance decade with given precision.
|
||||
* @method CarbonImmutable ceilDecades(float $precision = 1) Ceil the current instance decade with given precision.
|
||||
* @method CarbonImmutable roundQuarter(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
|
||||
* @method CarbonImmutable roundQuarters(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
|
||||
* @method CarbonImmutable floorQuarter(float $precision = 1) Truncate the current instance quarter with given precision.
|
||||
* @method CarbonImmutable floorQuarters(float $precision = 1) Truncate the current instance quarter with given precision.
|
||||
* @method CarbonImmutable ceilQuarter(float $precision = 1) Ceil the current instance quarter with given precision.
|
||||
* @method CarbonImmutable ceilQuarters(float $precision = 1) Ceil the current instance quarter with given precision.
|
||||
* @method CarbonImmutable roundMillisecond(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
|
||||
* @method CarbonImmutable roundMilliseconds(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
|
||||
* @method CarbonImmutable floorMillisecond(float $precision = 1) Truncate the current instance millisecond with given precision.
|
||||
* @method CarbonImmutable floorMilliseconds(float $precision = 1) Truncate the current instance millisecond with given precision.
|
||||
* @method CarbonImmutable ceilMillisecond(float $precision = 1) Ceil the current instance millisecond with given precision.
|
||||
* @method CarbonImmutable ceilMilliseconds(float $precision = 1) Ceil the current instance millisecond with given precision.
|
||||
* @method CarbonImmutable roundMicrosecond(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
|
||||
* @method CarbonImmutable roundMicroseconds(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
|
||||
* @method CarbonImmutable floorMicrosecond(float $precision = 1) Truncate the current instance microsecond with given precision.
|
||||
* @method CarbonImmutable floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision.
|
||||
* @method CarbonImmutable ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision.
|
||||
* @method CarbonImmutable ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision.
|
||||
* @method string shortAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string longAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string shortRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string longRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string shortRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string longRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string shortRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method string longRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)
|
||||
* @method static CarbonImmutable|false createFromFormat(string $format, string $time, string|DateTimeZone $timezone = null) Parse a string into a new CarbonImmutable object according to the specified format.
|
||||
* @method static CarbonImmutable __set_state(array $array) https://php.net/manual/en/datetime.set-state.php
|
||||
*
|
||||
* </autodoc>
|
||||
*/
|
||||
class CarbonImmutable extends DateTimeImmutable implements CarbonInterface
|
||||
{
|
||||
use Date {
|
||||
__clone as dateTraitClone;
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->dateTraitClone();
|
||||
$this->endOfTime = false;
|
||||
$this->startOfTime = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a very old date representing start of time.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function startOfTime(): self
|
||||
{
|
||||
$date = static::parse('0001-01-01')->years(self::getStartOfTimeYear());
|
||||
$date->startOfTime = true;
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a very far date representing end of time.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function endOfTime(): self
|
||||
{
|
||||
$date = static::parse('9999-12-31 23:59:59.999999')->years(self::getEndOfTimeYear());
|
||||
$date->endOfTime = true;
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private static function getEndOfTimeYear(): int
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '7.3.0-dev', '<')) {
|
||||
return 145261681241552;
|
||||
}
|
||||
|
||||
// Remove if https://bugs.php.net/bug.php?id=81107 is fixed
|
||||
if (version_compare(PHP_VERSION, '8.1.0-dev', '>=')) {
|
||||
return 1118290769066902787;
|
||||
}
|
||||
|
||||
return PHP_INT_MAX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private static function getStartOfTimeYear(): int
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '7.3.0-dev', '<')) {
|
||||
return -135908816449551;
|
||||
}
|
||||
|
||||
// Remove if https://bugs.php.net/bug.php?id=81107 is fixed
|
||||
if (version_compare(PHP_VERSION, '8.1.0-dev', '>=')) {
|
||||
return -1118290769066898816;
|
||||
}
|
||||
|
||||
return max(PHP_INT_MIN, -9223372036854773760);
|
||||
}
|
||||
}
|
||||
+5032
File diff suppressed because it is too large
Load Diff
+2693
@@ -0,0 +1,2693 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon;
|
||||
|
||||
use Carbon\Exceptions\BadFluentConstructorException;
|
||||
use Carbon\Exceptions\BadFluentSetterException;
|
||||
use Carbon\Exceptions\InvalidCastException;
|
||||
use Carbon\Exceptions\InvalidIntervalException;
|
||||
use Carbon\Exceptions\ParseErrorException;
|
||||
use Carbon\Exceptions\UnitNotConfiguredException;
|
||||
use Carbon\Exceptions\UnknownGetterException;
|
||||
use Carbon\Exceptions\UnknownSetterException;
|
||||
use Carbon\Exceptions\UnknownUnitException;
|
||||
use Carbon\Traits\IntervalRounding;
|
||||
use Carbon\Traits\IntervalStep;
|
||||
use Carbon\Traits\Mixin;
|
||||
use Carbon\Traits\Options;
|
||||
use Closure;
|
||||
use DateInterval;
|
||||
use DateTimeInterface;
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
use ReflectionException;
|
||||
use ReturnTypeWillChange;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* A simple API extension for DateInterval.
|
||||
* The implementation provides helpers to handle weeks but only days are saved.
|
||||
* Weeks are calculated based on the total days of the current instance.
|
||||
*
|
||||
* @property int $years Total years of the current interval.
|
||||
* @property int $months Total months of the current interval.
|
||||
* @property int $weeks Total weeks of the current interval calculated from the days.
|
||||
* @property int $dayz Total days of the current interval (weeks * 7 + days).
|
||||
* @property int $hours Total hours of the current interval.
|
||||
* @property int $minutes Total minutes of the current interval.
|
||||
* @property int $seconds Total seconds of the current interval.
|
||||
* @property int $microseconds Total microseconds of the current interval.
|
||||
* @property int $milliseconds Total microseconds of the current interval.
|
||||
* @property int $microExcludeMilli Remaining microseconds without the milliseconds.
|
||||
* @property int $dayzExcludeWeeks Total days remaining in the final week of the current instance (days % 7).
|
||||
* @property int $daysExcludeWeeks alias of dayzExcludeWeeks
|
||||
* @property-read float $totalYears Number of years equivalent to the interval.
|
||||
* @property-read float $totalMonths Number of months equivalent to the interval.
|
||||
* @property-read float $totalWeeks Number of weeks equivalent to the interval.
|
||||
* @property-read float $totalDays Number of days equivalent to the interval.
|
||||
* @property-read float $totalDayz Alias for totalDays.
|
||||
* @property-read float $totalHours Number of hours equivalent to the interval.
|
||||
* @property-read float $totalMinutes Number of minutes equivalent to the interval.
|
||||
* @property-read float $totalSeconds Number of seconds equivalent to the interval.
|
||||
* @property-read float $totalMilliseconds Number of milliseconds equivalent to the interval.
|
||||
* @property-read float $totalMicroseconds Number of microseconds equivalent to the interval.
|
||||
* @property-read string $locale locale of the current instance
|
||||
*
|
||||
* @method static CarbonInterval years($years = 1) Create instance specifying a number of years or modify the number of years if called on an instance.
|
||||
* @method static CarbonInterval year($years = 1) Alias for years()
|
||||
* @method static CarbonInterval months($months = 1) Create instance specifying a number of months or modify the number of months if called on an instance.
|
||||
* @method static CarbonInterval month($months = 1) Alias for months()
|
||||
* @method static CarbonInterval weeks($weeks = 1) Create instance specifying a number of weeks or modify the number of weeks if called on an instance.
|
||||
* @method static CarbonInterval week($weeks = 1) Alias for weeks()
|
||||
* @method static CarbonInterval days($days = 1) Create instance specifying a number of days or modify the number of days if called on an instance.
|
||||
* @method static CarbonInterval dayz($days = 1) Alias for days()
|
||||
* @method static CarbonInterval daysExcludeWeeks($days = 1) Create instance specifying a number of days or modify the number of days (keeping the current number of weeks) if called on an instance.
|
||||
* @method static CarbonInterval dayzExcludeWeeks($days = 1) Alias for daysExcludeWeeks()
|
||||
* @method static CarbonInterval day($days = 1) Alias for days()
|
||||
* @method static CarbonInterval hours($hours = 1) Create instance specifying a number of hours or modify the number of hours if called on an instance.
|
||||
* @method static CarbonInterval hour($hours = 1) Alias for hours()
|
||||
* @method static CarbonInterval minutes($minutes = 1) Create instance specifying a number of minutes or modify the number of minutes if called on an instance.
|
||||
* @method static CarbonInterval minute($minutes = 1) Alias for minutes()
|
||||
* @method static CarbonInterval seconds($seconds = 1) Create instance specifying a number of seconds or modify the number of seconds if called on an instance.
|
||||
* @method static CarbonInterval second($seconds = 1) Alias for seconds()
|
||||
* @method static CarbonInterval milliseconds($milliseconds = 1) Create instance specifying a number of milliseconds or modify the number of milliseconds if called on an instance.
|
||||
* @method static CarbonInterval millisecond($milliseconds = 1) Alias for milliseconds()
|
||||
* @method static CarbonInterval microseconds($microseconds = 1) Create instance specifying a number of microseconds or modify the number of microseconds if called on an instance.
|
||||
* @method static CarbonInterval microsecond($microseconds = 1) Alias for microseconds()
|
||||
* @method $this addYears(int $years) Add given number of years to the current interval
|
||||
* @method $this subYears(int $years) Subtract given number of years to the current interval
|
||||
* @method $this addMonths(int $months) Add given number of months to the current interval
|
||||
* @method $this subMonths(int $months) Subtract given number of months to the current interval
|
||||
* @method $this addWeeks(int|float $weeks) Add given number of weeks to the current interval
|
||||
* @method $this subWeeks(int|float $weeks) Subtract given number of weeks to the current interval
|
||||
* @method $this addDays(int|float $days) Add given number of days to the current interval
|
||||
* @method $this subDays(int|float $days) Subtract given number of days to the current interval
|
||||
* @method $this addHours(int|float $hours) Add given number of hours to the current interval
|
||||
* @method $this subHours(int|float $hours) Subtract given number of hours to the current interval
|
||||
* @method $this addMinutes(int|float $minutes) Add given number of minutes to the current interval
|
||||
* @method $this subMinutes(int|float $minutes) Subtract given number of minutes to the current interval
|
||||
* @method $this addSeconds(int|float $seconds) Add given number of seconds to the current interval
|
||||
* @method $this subSeconds(int|float $seconds) Subtract given number of seconds to the current interval
|
||||
* @method $this addMilliseconds(int|float $milliseconds) Add given number of milliseconds to the current interval
|
||||
* @method $this subMilliseconds(int|float $milliseconds) Subtract given number of milliseconds to the current interval
|
||||
* @method $this addMicroseconds(int|float $microseconds) Add given number of microseconds to the current interval
|
||||
* @method $this subMicroseconds(int|float $microseconds) Subtract given number of microseconds to the current interval
|
||||
* @method $this roundYear(int|float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
|
||||
* @method $this roundYears(int|float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
|
||||
* @method $this floorYear(int|float $precision = 1) Truncate the current instance year with given precision.
|
||||
* @method $this floorYears(int|float $precision = 1) Truncate the current instance year with given precision.
|
||||
* @method $this ceilYear(int|float $precision = 1) Ceil the current instance year with given precision.
|
||||
* @method $this ceilYears(int|float $precision = 1) Ceil the current instance year with given precision.
|
||||
* @method $this roundMonth(int|float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
|
||||
* @method $this roundMonths(int|float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
|
||||
* @method $this floorMonth(int|float $precision = 1) Truncate the current instance month with given precision.
|
||||
* @method $this floorMonths(int|float $precision = 1) Truncate the current instance month with given precision.
|
||||
* @method $this ceilMonth(int|float $precision = 1) Ceil the current instance month with given precision.
|
||||
* @method $this ceilMonths(int|float $precision = 1) Ceil the current instance month with given precision.
|
||||
* @method $this roundWeek(int|float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method $this roundWeeks(int|float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method $this floorWeek(int|float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method $this floorWeeks(int|float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method $this ceilWeek(int|float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method $this ceilWeeks(int|float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method $this roundDay(int|float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method $this roundDays(int|float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method $this floorDay(int|float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method $this floorDays(int|float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method $this ceilDay(int|float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method $this ceilDays(int|float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method $this roundHour(int|float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
|
||||
* @method $this roundHours(int|float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
|
||||
* @method $this floorHour(int|float $precision = 1) Truncate the current instance hour with given precision.
|
||||
* @method $this floorHours(int|float $precision = 1) Truncate the current instance hour with given precision.
|
||||
* @method $this ceilHour(int|float $precision = 1) Ceil the current instance hour with given precision.
|
||||
* @method $this ceilHours(int|float $precision = 1) Ceil the current instance hour with given precision.
|
||||
* @method $this roundMinute(int|float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
|
||||
* @method $this roundMinutes(int|float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
|
||||
* @method $this floorMinute(int|float $precision = 1) Truncate the current instance minute with given precision.
|
||||
* @method $this floorMinutes(int|float $precision = 1) Truncate the current instance minute with given precision.
|
||||
* @method $this ceilMinute(int|float $precision = 1) Ceil the current instance minute with given precision.
|
||||
* @method $this ceilMinutes(int|float $precision = 1) Ceil the current instance minute with given precision.
|
||||
* @method $this roundSecond(int|float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
|
||||
* @method $this roundSeconds(int|float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
|
||||
* @method $this floorSecond(int|float $precision = 1) Truncate the current instance second with given precision.
|
||||
* @method $this floorSeconds(int|float $precision = 1) Truncate the current instance second with given precision.
|
||||
* @method $this ceilSecond(int|float $precision = 1) Ceil the current instance second with given precision.
|
||||
* @method $this ceilSeconds(int|float $precision = 1) Ceil the current instance second with given precision.
|
||||
* @method $this roundMillennium(int|float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
|
||||
* @method $this roundMillennia(int|float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
|
||||
* @method $this floorMillennium(int|float $precision = 1) Truncate the current instance millennium with given precision.
|
||||
* @method $this floorMillennia(int|float $precision = 1) Truncate the current instance millennium with given precision.
|
||||
* @method $this ceilMillennium(int|float $precision = 1) Ceil the current instance millennium with given precision.
|
||||
* @method $this ceilMillennia(int|float $precision = 1) Ceil the current instance millennium with given precision.
|
||||
* @method $this roundCentury(int|float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
|
||||
* @method $this roundCenturies(int|float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
|
||||
* @method $this floorCentury(int|float $precision = 1) Truncate the current instance century with given precision.
|
||||
* @method $this floorCenturies(int|float $precision = 1) Truncate the current instance century with given precision.
|
||||
* @method $this ceilCentury(int|float $precision = 1) Ceil the current instance century with given precision.
|
||||
* @method $this ceilCenturies(int|float $precision = 1) Ceil the current instance century with given precision.
|
||||
* @method $this roundDecade(int|float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
|
||||
* @method $this roundDecades(int|float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
|
||||
* @method $this floorDecade(int|float $precision = 1) Truncate the current instance decade with given precision.
|
||||
* @method $this floorDecades(int|float $precision = 1) Truncate the current instance decade with given precision.
|
||||
* @method $this ceilDecade(int|float $precision = 1) Ceil the current instance decade with given precision.
|
||||
* @method $this ceilDecades(int|float $precision = 1) Ceil the current instance decade with given precision.
|
||||
* @method $this roundQuarter(int|float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
|
||||
* @method $this roundQuarters(int|float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
|
||||
* @method $this floorQuarter(int|float $precision = 1) Truncate the current instance quarter with given precision.
|
||||
* @method $this floorQuarters(int|float $precision = 1) Truncate the current instance quarter with given precision.
|
||||
* @method $this ceilQuarter(int|float $precision = 1) Ceil the current instance quarter with given precision.
|
||||
* @method $this ceilQuarters(int|float $precision = 1) Ceil the current instance quarter with given precision.
|
||||
* @method $this roundMillisecond(int|float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
|
||||
* @method $this roundMilliseconds(int|float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
|
||||
* @method $this floorMillisecond(int|float $precision = 1) Truncate the current instance millisecond with given precision.
|
||||
* @method $this floorMilliseconds(int|float $precision = 1) Truncate the current instance millisecond with given precision.
|
||||
* @method $this ceilMillisecond(int|float $precision = 1) Ceil the current instance millisecond with given precision.
|
||||
* @method $this ceilMilliseconds(int|float $precision = 1) Ceil the current instance millisecond with given precision.
|
||||
* @method $this roundMicrosecond(int|float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
|
||||
* @method $this roundMicroseconds(int|float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
|
||||
* @method $this floorMicrosecond(int|float $precision = 1) Truncate the current instance microsecond with given precision.
|
||||
* @method $this floorMicroseconds(int|float $precision = 1) Truncate the current instance microsecond with given precision.
|
||||
* @method $this ceilMicrosecond(int|float $precision = 1) Ceil the current instance microsecond with given precision.
|
||||
* @method $this ceilMicroseconds(int|float $precision = 1) Ceil the current instance microsecond with given precision.
|
||||
*/
|
||||
class CarbonInterval extends DateInterval implements CarbonConverterInterface
|
||||
{
|
||||
use IntervalRounding;
|
||||
use IntervalStep;
|
||||
use Mixin {
|
||||
Mixin::mixin as baseMixin;
|
||||
}
|
||||
use Options;
|
||||
|
||||
/**
|
||||
* 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 \Symfony\Component\Translation\TranslatorInterface
|
||||
*/
|
||||
protected static $translator;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
protected static $cascadeFactors;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $formats = [
|
||||
'y' => 'y',
|
||||
'Y' => 'y',
|
||||
'o' => 'y',
|
||||
'm' => 'm',
|
||||
'n' => 'm',
|
||||
'W' => 'weeks',
|
||||
'd' => 'd',
|
||||
'j' => 'd',
|
||||
'z' => 'd',
|
||||
'h' => 'h',
|
||||
'g' => 'h',
|
||||
'H' => 'h',
|
||||
'G' => 'h',
|
||||
'i' => 'i',
|
||||
's' => 's',
|
||||
'u' => 'micro',
|
||||
'v' => 'milli',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
private static $flipCascadeFactors;
|
||||
|
||||
/**
|
||||
* The registered macros.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $macros = [];
|
||||
|
||||
/**
|
||||
* Timezone handler for settings() method.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $tzName;
|
||||
|
||||
/**
|
||||
* Set the instance's timezone from a string or object.
|
||||
*
|
||||
* @param \DateTimeZone|string $tzName
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setTimezone($tzName)
|
||||
{
|
||||
$this->tzName = $tzName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* Set the instance's timezone from a string or object and add/subtract the offset difference.
|
||||
*
|
||||
* @param \DateTimeZone|string $tzName
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function shiftTimezone($tzName)
|
||||
{
|
||||
$this->tzName = $tzName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of units and factors for cascading.
|
||||
*
|
||||
* Should only be modified by changing the factors or referenced constants.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getCascadeFactors()
|
||||
{
|
||||
return static::$cascadeFactors ?: [
|
||||
'milliseconds' => [Carbon::MICROSECONDS_PER_MILLISECOND, 'microseconds'],
|
||||
'seconds' => [Carbon::MILLISECONDS_PER_SECOND, 'milliseconds'],
|
||||
'minutes' => [Carbon::SECONDS_PER_MINUTE, 'seconds'],
|
||||
'hours' => [Carbon::MINUTES_PER_HOUR, 'minutes'],
|
||||
'dayz' => [Carbon::HOURS_PER_DAY, 'hours'],
|
||||
'weeks' => [Carbon::DAYS_PER_WEEK, 'dayz'],
|
||||
'months' => [Carbon::WEEKS_PER_MONTH, 'weeks'],
|
||||
'years' => [Carbon::MONTHS_PER_YEAR, 'months'],
|
||||
];
|
||||
}
|
||||
|
||||
private static function standardizeUnit($unit)
|
||||
{
|
||||
$unit = rtrim($unit, 'sz').'s';
|
||||
|
||||
return $unit === 'days' ? 'dayz' : $unit;
|
||||
}
|
||||
|
||||
private static function getFlipCascadeFactors()
|
||||
{
|
||||
if (!self::$flipCascadeFactors) {
|
||||
self::$flipCascadeFactors = [];
|
||||
|
||||
foreach (static::getCascadeFactors() as $to => [$factor, $from]) {
|
||||
self::$flipCascadeFactors[self::standardizeUnit($from)] = [self::standardizeUnit($to), $factor];
|
||||
}
|
||||
}
|
||||
|
||||
return self::$flipCascadeFactors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default cascading factors for ->cascade() method.
|
||||
*
|
||||
* @param array $cascadeFactors
|
||||
*/
|
||||
public static function setCascadeFactors(array $cascadeFactors)
|
||||
{
|
||||
self::$flipCascadeFactors = null;
|
||||
static::$cascadeFactors = $cascadeFactors;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//////////////////////////// CONSTRUCTORS /////////////////////////
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Create a new CarbonInterval instance.
|
||||
*
|
||||
* @param int|null $years
|
||||
* @param int|null $months
|
||||
* @param int|null $weeks
|
||||
* @param int|null $days
|
||||
* @param int|null $hours
|
||||
* @param int|null $minutes
|
||||
* @param int|null $seconds
|
||||
* @param int|null $microseconds
|
||||
*
|
||||
* @throws Exception when the interval_spec (passed as $years) cannot be parsed as an interval.
|
||||
*/
|
||||
public function __construct($years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null)
|
||||
{
|
||||
if ($years instanceof Closure) {
|
||||
$this->step = $years;
|
||||
$years = null;
|
||||
}
|
||||
|
||||
if ($years instanceof DateInterval) {
|
||||
parent::__construct(static::getDateIntervalSpec($years));
|
||||
$this->f = $years->f;
|
||||
static::copyNegativeUnits($years, $this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$spec = $years;
|
||||
|
||||
if (!\is_string($spec) || (float) $years || preg_match('/^[0-9.]/', $years)) {
|
||||
$spec = static::PERIOD_PREFIX;
|
||||
|
||||
$spec .= $years > 0 ? $years.static::PERIOD_YEARS : '';
|
||||
$spec .= $months > 0 ? $months.static::PERIOD_MONTHS : '';
|
||||
|
||||
$specDays = 0;
|
||||
$specDays += $weeks > 0 ? $weeks * static::getDaysPerWeek() : 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 : '';
|
||||
}
|
||||
|
||||
if ($spec === static::PERIOD_PREFIX) {
|
||||
// Allow the zero interval.
|
||||
$spec .= '0'.static::PERIOD_YEARS;
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($spec);
|
||||
|
||||
if ($microseconds !== null) {
|
||||
$this->f = $microseconds / Carbon::MICROSECONDS_PER_SECOND;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the factor for a given source-to-target couple.
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $target
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public static function getFactor($source, $target)
|
||||
{
|
||||
$source = self::standardizeUnit($source);
|
||||
$target = self::standardizeUnit($target);
|
||||
$factors = static::getFlipCascadeFactors();
|
||||
|
||||
if (isset($factors[$source])) {
|
||||
[$to, $factor] = $factors[$source];
|
||||
|
||||
if ($to === $target) {
|
||||
return $factor;
|
||||
}
|
||||
|
||||
return $factor * static::getFactor($to, $target);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current config for days per week.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getDaysPerWeek()
|
||||
{
|
||||
return static::getFactor('dayz', 'weeks') ?: Carbon::DAYS_PER_WEEK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current config for hours per day.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getHoursPerDay()
|
||||
{
|
||||
return static::getFactor('hours', 'dayz') ?: Carbon::HOURS_PER_DAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current config for minutes per hour.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getMinutesPerHour()
|
||||
{
|
||||
return static::getFactor('minutes', 'hours') ?: Carbon::MINUTES_PER_HOUR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current config for seconds per minute.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getSecondsPerMinute()
|
||||
{
|
||||
return static::getFactor('seconds', 'minutes') ?: Carbon::SECONDS_PER_MINUTE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current config for microseconds per second.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getMillisecondsPerSecond()
|
||||
{
|
||||
return static::getFactor('milliseconds', 'seconds') ?: Carbon::MILLISECONDS_PER_SECOND;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current config for microseconds per second.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getMicrosecondsPerMillisecond()
|
||||
{
|
||||
return static::getFactor('microseconds', 'milliseconds') ?: Carbon::MICROSECONDS_PER_MILLISECOND;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 int $years
|
||||
* @param int $months
|
||||
* @param int $weeks
|
||||
* @param int $days
|
||||
* @param int $hours
|
||||
* @param int $minutes
|
||||
* @param int $seconds
|
||||
* @param int $microseconds
|
||||
*
|
||||
* @throws Exception when the interval_spec (passed as $years) cannot be parsed as an interval.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create($years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null)
|
||||
{
|
||||
return new static($years, $months, $weeks, $days, $hours, $minutes, $seconds, $microseconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string into a new CarbonInterval object according to the specified format.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* echo Carboninterval::createFromFormat('H:i', '1:30');
|
||||
* ```
|
||||
*
|
||||
* @param string $format Format of the $interval input string
|
||||
* @param string $interval Input string to convert into an interval
|
||||
*
|
||||
* @throws Exception when the $interval cannot be parsed as an interval.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function createFromFormat(string $format, ?string $interval)
|
||||
{
|
||||
$instance = new static(0);
|
||||
$length = mb_strlen($format);
|
||||
|
||||
if (preg_match('/s([,.])([uv])$/', $format, $match)) {
|
||||
$interval = explode($match[1], $interval);
|
||||
$index = \count($interval) - 1;
|
||||
$interval[$index] = str_pad($interval[$index], $match[2] === 'v' ? 3 : 6, '0');
|
||||
$interval = implode($match[1], $interval);
|
||||
}
|
||||
|
||||
$interval = $interval ?? '';
|
||||
|
||||
for ($index = 0; $index < $length; $index++) {
|
||||
$expected = mb_substr($format, $index, 1);
|
||||
$nextCharacter = mb_substr($interval, 0, 1);
|
||||
$unit = static::$formats[$expected] ?? null;
|
||||
|
||||
if ($unit) {
|
||||
if (!preg_match('/^-?\d+/', $interval, $match)) {
|
||||
throw new ParseErrorException('number', $nextCharacter);
|
||||
}
|
||||
|
||||
$interval = mb_substr($interval, mb_strlen($match[0]));
|
||||
$instance->$unit += (int) ($match[0]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($nextCharacter !== $expected) {
|
||||
throw new ParseErrorException(
|
||||
"'$expected'",
|
||||
$nextCharacter,
|
||||
'Allowed substitutes for interval formats are '.implode(', ', array_keys(static::$formats))."\n".
|
||||
'See https://php.net/manual/en/function.date.php for their meaning'
|
||||
);
|
||||
}
|
||||
|
||||
$interval = mb_substr($interval, 1);
|
||||
}
|
||||
|
||||
if ($interval !== '') {
|
||||
throw new ParseErrorException(
|
||||
'end of string',
|
||||
$interval
|
||||
);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of the instance.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function copy()
|
||||
{
|
||||
$date = new static(0);
|
||||
$date->copyProperties($this);
|
||||
$date->step = $this->step;
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of the instance.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function clone()
|
||||
{
|
||||
return $this->copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 $method magic method name called
|
||||
* @param array $parameters parameters list
|
||||
*
|
||||
* @return static|null
|
||||
*/
|
||||
public static function __callStatic($method, $parameters)
|
||||
{
|
||||
try {
|
||||
$interval = new static(0);
|
||||
$localStrictModeEnabled = $interval->localStrictModeEnabled;
|
||||
$interval->localStrictModeEnabled = true;
|
||||
|
||||
$result = static::hasMacro($method)
|
||||
? static::bindMacroContext(null, function () use (&$method, &$parameters, &$interval) {
|
||||
return $interval->callMacro($method, $parameters);
|
||||
})
|
||||
: $interval->$method(...$parameters);
|
||||
|
||||
$interval->localStrictModeEnabled = $localStrictModeEnabled;
|
||||
|
||||
return $result;
|
||||
} catch (BadFluentSetterException $exception) {
|
||||
if (Carbon::isStrictModeEnabled()) {
|
||||
throw new BadFluentConstructorException($method, 0, $exception);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current context from inside a macro callee or a new one if static.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
protected static function this()
|
||||
{
|
||||
return end(static::$macroContextStack) ?: new static(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a CarbonInterval from string.
|
||||
*
|
||||
* Format:
|
||||
*
|
||||
* Suffix | Unit | Example | DateInterval expression
|
||||
* -------|---------|---------|------------------------
|
||||
* y | years | 1y | P1Y
|
||||
* mo | months | 3mo | P3M
|
||||
* w | weeks | 2w | P2W
|
||||
* d | days | 28d | P28D
|
||||
* h | hours | 4h | PT4H
|
||||
* m | minutes | 12m | PT12M
|
||||
* s | seconds | 59s | PT59S
|
||||
*
|
||||
* e. g. `1w 3d 4h 32m 23s` is converted to 10 days 4 hours 32 minutes and 23 seconds.
|
||||
*
|
||||
* Special cases:
|
||||
* - An empty string will return a zero interval
|
||||
* - Fractions are allowed for weeks, days, hours and minutes and will be converted
|
||||
* and rounded to the next smaller value (caution: 0.5w = 4d)
|
||||
*
|
||||
* @param string $intervalDefinition
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function fromString($intervalDefinition)
|
||||
{
|
||||
if (empty($intervalDefinition)) {
|
||||
return new static(0);
|
||||
}
|
||||
|
||||
$years = 0;
|
||||
$months = 0;
|
||||
$weeks = 0;
|
||||
$days = 0;
|
||||
$hours = 0;
|
||||
$minutes = 0;
|
||||
$seconds = 0;
|
||||
$milliseconds = 0;
|
||||
$microseconds = 0;
|
||||
|
||||
$pattern = '/(\d+(?:\.\d+)?)\h*([^\d\h]*)/i';
|
||||
preg_match_all($pattern, $intervalDefinition, $parts, PREG_SET_ORDER);
|
||||
|
||||
while ([$part, $value, $unit] = array_shift($parts)) {
|
||||
$intValue = (int) $value;
|
||||
$fraction = (float) $value - $intValue;
|
||||
|
||||
// Fix calculation precision
|
||||
switch (round($fraction, 6)) {
|
||||
case 1:
|
||||
$fraction = 0;
|
||||
$intValue++;
|
||||
|
||||
break;
|
||||
case 0:
|
||||
$fraction = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($unit === 'µs' ? 'µs' : strtolower($unit)) {
|
||||
case 'millennia':
|
||||
case 'millennium':
|
||||
$years += $intValue * CarbonInterface::YEARS_PER_MILLENNIUM;
|
||||
|
||||
break;
|
||||
|
||||
case 'century':
|
||||
case 'centuries':
|
||||
$years += $intValue * CarbonInterface::YEARS_PER_CENTURY;
|
||||
|
||||
break;
|
||||
|
||||
case 'decade':
|
||||
case 'decades':
|
||||
$years += $intValue * CarbonInterface::YEARS_PER_DECADE;
|
||||
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
case 'years':
|
||||
case 'y':
|
||||
$years += $intValue;
|
||||
|
||||
break;
|
||||
|
||||
case 'quarter':
|
||||
case 'quarters':
|
||||
$months += $intValue * CarbonInterface::MONTHS_PER_QUARTER;
|
||||
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
case 'months':
|
||||
case 'mo':
|
||||
$months += $intValue;
|
||||
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
case 'weeks':
|
||||
case 'w':
|
||||
$weeks += $intValue;
|
||||
|
||||
if ($fraction) {
|
||||
$parts[] = [null, $fraction * static::getDaysPerWeek(), 'd'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
case 'days':
|
||||
case 'd':
|
||||
$days += $intValue;
|
||||
|
||||
if ($fraction) {
|
||||
$parts[] = [null, $fraction * static::getHoursPerDay(), 'h'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
case 'hours':
|
||||
case 'h':
|
||||
$hours += $intValue;
|
||||
|
||||
if ($fraction) {
|
||||
$parts[] = [null, $fraction * static::getMinutesPerHour(), 'm'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
case 'minutes':
|
||||
case 'm':
|
||||
$minutes += $intValue;
|
||||
|
||||
if ($fraction) {
|
||||
$parts[] = [null, $fraction * static::getSecondsPerMinute(), 's'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'second':
|
||||
case 'seconds':
|
||||
case 's':
|
||||
$seconds += $intValue;
|
||||
|
||||
if ($fraction) {
|
||||
$parts[] = [null, $fraction * static::getMillisecondsPerSecond(), 'ms'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'millisecond':
|
||||
case 'milliseconds':
|
||||
case 'milli':
|
||||
case 'ms':
|
||||
$milliseconds += $intValue;
|
||||
|
||||
if ($fraction) {
|
||||
$microseconds += round($fraction * static::getMicrosecondsPerMillisecond());
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'microsecond':
|
||||
case 'microseconds':
|
||||
case 'micro':
|
||||
case 'µs':
|
||||
$microseconds += $intValue;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidIntervalException(
|
||||
sprintf('Invalid part %s in definition %s', $part, $intervalDefinition)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return new static($years, $months, $weeks, $days, $hours, $minutes, $seconds, $milliseconds * Carbon::MICROSECONDS_PER_MILLISECOND + $microseconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a CarbonInterval from string using a different locale.
|
||||
*
|
||||
* @param string $interval interval string in the given language (may also contain English).
|
||||
* @param string|null $locale if locale is null or not specified, current global locale will be used instead.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function parseFromLocale($interval, $locale = null)
|
||||
{
|
||||
return static::fromString(Carbon::translateTimeString($interval, $locale ?: static::getLocale(), 'en'));
|
||||
}
|
||||
|
||||
private static function castIntervalToClass(DateInterval $interval, string $className)
|
||||
{
|
||||
$mainClass = DateInterval::class;
|
||||
|
||||
if (!is_a($className, $mainClass, true)) {
|
||||
throw new InvalidCastException("$className is not a sub-class of $mainClass.");
|
||||
}
|
||||
|
||||
$microseconds = $interval->f;
|
||||
$instance = new $className(static::getDateIntervalSpec($interval));
|
||||
|
||||
if ($microseconds) {
|
||||
$instance->f = $microseconds;
|
||||
}
|
||||
|
||||
if ($interval instanceof self && is_a($className, self::class, true)) {
|
||||
static::copyStep($interval, $instance);
|
||||
}
|
||||
|
||||
static::copyNegativeUnits($interval, $instance);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
private static function copyNegativeUnits(DateInterval $from, DateInterval $to): void
|
||||
{
|
||||
$to->invert = $from->invert;
|
||||
|
||||
foreach (['y', 'm', 'd', 'h', 'i', 's'] as $unit) {
|
||||
if ($from->$unit < 0) {
|
||||
$to->$unit *= -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function copyStep(self $from, self $to): void
|
||||
{
|
||||
$to->setStep($from->getStep());
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast the current instance into the given class.
|
||||
*
|
||||
* @param string $className The $className::instance() method will be called to cast the current object.
|
||||
*
|
||||
* @return DateInterval
|
||||
*/
|
||||
public function cast(string $className)
|
||||
{
|
||||
return self::castIntervalToClass($this, $className);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 $interval
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function instance(DateInterval $interval)
|
||||
{
|
||||
return self::castIntervalToClass($interval, static::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a CarbonInterval instance from given variable if possible.
|
||||
*
|
||||
* Always return a new instance. Parse only strings and only these likely to be intervals (skip dates
|
||||
* and recurrences). Throw an exception for invalid format, but otherwise return null.
|
||||
*
|
||||
* @param mixed|int|DateInterval|string|Closure|null $interval interval or number of the given $unit
|
||||
* @param string|null $unit if specified, $interval must be an integer
|
||||
*
|
||||
* @return static|null
|
||||
*/
|
||||
public static function make($interval, $unit = null)
|
||||
{
|
||||
if ($unit) {
|
||||
$interval = "$interval ".Carbon::pluralUnit($unit);
|
||||
}
|
||||
|
||||
if ($interval instanceof DateInterval) {
|
||||
return static::instance($interval);
|
||||
}
|
||||
|
||||
if ($interval instanceof Closure) {
|
||||
return new static($interval);
|
||||
}
|
||||
|
||||
if (!\is_string($interval)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return static::makeFromString($interval);
|
||||
}
|
||||
|
||||
protected static function makeFromString(string $interval)
|
||||
{
|
||||
$interval = preg_replace('/\s+/', ' ', trim($interval));
|
||||
|
||||
if (preg_match('/^P[T0-9]/', $interval)) {
|
||||
return new static($interval);
|
||||
}
|
||||
|
||||
if (preg_match('/^(?:\h*\d+(?:\.\d+)?\h*[a-z]+)+$/i', $interval)) {
|
||||
return static::fromString($interval);
|
||||
}
|
||||
|
||||
/** @var static $interval */
|
||||
$interval = static::createFromDateString($interval);
|
||||
|
||||
return !$interval || $interval->isEmpty() ? null : $interval;
|
||||
}
|
||||
|
||||
protected function resolveInterval($interval)
|
||||
{
|
||||
if (!($interval instanceof self)) {
|
||||
return self::make($interval);
|
||||
}
|
||||
|
||||
return $interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up a DateInterval from the relative parts of the string.
|
||||
*
|
||||
* @param string $time
|
||||
*
|
||||
* @return static
|
||||
*
|
||||
* @link https://php.net/manual/en/dateinterval.createfromdatestring.php
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public static function createFromDateString($time)
|
||||
{
|
||||
$interval = @parent::createFromDateString(strtr($time, [
|
||||
',' => ' ',
|
||||
' and ' => ' ',
|
||||
]));
|
||||
|
||||
if ($interval instanceof DateInterval) {
|
||||
$interval = static::instance($interval);
|
||||
}
|
||||
|
||||
return $interval;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
///////////////////////// GETTERS AND SETTERS /////////////////////
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Get a part of the CarbonInterval object.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws UnknownGetterException
|
||||
*
|
||||
* @return int|float|string
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
if (str_starts_with($name, 'total')) {
|
||||
return $this->total(substr($name, 5));
|
||||
}
|
||||
|
||||
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 'milli':
|
||||
case 'milliseconds':
|
||||
return (int) (round($this->f * Carbon::MICROSECONDS_PER_SECOND) / Carbon::MICROSECONDS_PER_MILLISECOND);
|
||||
|
||||
case 'micro':
|
||||
case 'microseconds':
|
||||
return (int) round($this->f * Carbon::MICROSECONDS_PER_SECOND);
|
||||
|
||||
case 'microExcludeMilli':
|
||||
return (int) round($this->f * Carbon::MICROSECONDS_PER_SECOND) % Carbon::MICROSECONDS_PER_MILLISECOND;
|
||||
|
||||
case 'weeks':
|
||||
return (int) ($this->d / static::getDaysPerWeek());
|
||||
|
||||
case 'daysExcludeWeeks':
|
||||
case 'dayzExcludeWeeks':
|
||||
return $this->d % static::getDaysPerWeek();
|
||||
|
||||
case 'locale':
|
||||
return $this->getTranslatorLocale();
|
||||
|
||||
default:
|
||||
throw new UnknownGetterException($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a part of the CarbonInterval object.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws UnknownGetterException
|
||||
*
|
||||
* @return int|float|string
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a part of the CarbonInterval object.
|
||||
*
|
||||
* @param string|array $name
|
||||
* @param int $value
|
||||
*
|
||||
* @throws UnknownSetterException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function set($name, $value = null)
|
||||
{
|
||||
$properties = \is_array($name) ? $name : [$name => $value];
|
||||
|
||||
foreach ($properties as $key => $value) {
|
||||
switch (Carbon::singularUnit(rtrim($key, 'z'))) {
|
||||
case 'year':
|
||||
$this->y = $value;
|
||||
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$this->m = $value;
|
||||
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$this->d = $value * static::getDaysPerWeek();
|
||||
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$this->d = $value;
|
||||
|
||||
break;
|
||||
|
||||
case 'daysexcludeweek':
|
||||
case 'dayzexcludeweek':
|
||||
$this->d = $this->weeks * static::getDaysPerWeek() + $value;
|
||||
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$this->h = $value;
|
||||
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$this->i = $value;
|
||||
|
||||
break;
|
||||
|
||||
case 'second':
|
||||
$this->s = $value;
|
||||
|
||||
break;
|
||||
|
||||
case 'milli':
|
||||
case 'millisecond':
|
||||
$this->microseconds = $value * Carbon::MICROSECONDS_PER_MILLISECOND + $this->microseconds % Carbon::MICROSECONDS_PER_MILLISECOND;
|
||||
|
||||
break;
|
||||
|
||||
case 'micro':
|
||||
case 'microsecond':
|
||||
$this->f = $value / Carbon::MICROSECONDS_PER_SECOND;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($this->localStrictModeEnabled ?? Carbon::isStrictModeEnabled()) {
|
||||
throw new UnknownSetterException($key);
|
||||
}
|
||||
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a part of the CarbonInterval object.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $value
|
||||
*
|
||||
* @throws UnknownSetterException
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->set($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 * static::getDaysPerWeek()) + $days;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the interval is empty for each unit.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->years === 0 &&
|
||||
$this->months === 0 &&
|
||||
$this->dayz === 0 &&
|
||||
!$this->days &&
|
||||
$this->hours === 0 &&
|
||||
$this->minutes === 0 &&
|
||||
$this->seconds === 0 &&
|
||||
$this->microseconds === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom macro.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* CarbonInterval::macro('twice', function () {
|
||||
* return $this->times(2);
|
||||
* });
|
||||
* echo CarbonInterval::hours(2)->twice();
|
||||
* ```
|
||||
*
|
||||
* @param string $name
|
||||
* @param object|callable $macro
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function macro($name, $macro)
|
||||
{
|
||||
static::$macros[$name] = $macro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register macros from a mixin object.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* CarbonInterval::mixin(new class {
|
||||
* public function daysToHours() {
|
||||
* return function () {
|
||||
* $this->hours += $this->days;
|
||||
* $this->days = 0;
|
||||
*
|
||||
* return $this;
|
||||
* };
|
||||
* }
|
||||
* public function hoursToDays() {
|
||||
* return function () {
|
||||
* $this->days += $this->hours;
|
||||
* $this->hours = 0;
|
||||
*
|
||||
* return $this;
|
||||
* };
|
||||
* }
|
||||
* });
|
||||
* echo CarbonInterval::hours(5)->hoursToDays() . "\n";
|
||||
* echo CarbonInterval::days(5)->daysToHours() . "\n";
|
||||
* ```
|
||||
*
|
||||
* @param object|string $mixin
|
||||
*
|
||||
* @throws ReflectionException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function mixin($mixin)
|
||||
{
|
||||
static::baseMixin($mixin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if macro is registered.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasMacro($name)
|
||||
{
|
||||
return isset(static::$macros[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call given macro.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callMacro($name, $parameters)
|
||||
{
|
||||
$macro = static::$macros[$name];
|
||||
|
||||
if ($macro instanceof Closure) {
|
||||
$boundMacro = @$macro->bindTo($this, static::class) ?: @$macro->bindTo(null, static::class);
|
||||
|
||||
return ($boundMacro ?: $macro)(...$parameters);
|
||||
}
|
||||
|
||||
return $macro(...$parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 $method magic method name called
|
||||
* @param array $parameters parameters list
|
||||
*
|
||||
* @throws BadFluentSetterException|Throwable
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
if (static::hasMacro($method)) {
|
||||
return static::bindMacroContext($this, function () use (&$method, &$parameters) {
|
||||
return $this->callMacro($method, $parameters);
|
||||
});
|
||||
}
|
||||
|
||||
$roundedValue = $this->callRoundMethod($method, $parameters);
|
||||
|
||||
if ($roundedValue !== null) {
|
||||
return $roundedValue;
|
||||
}
|
||||
|
||||
if (preg_match('/^(?<method>add|sub)(?<unit>[A-Z].*)$/', $method, $match)) {
|
||||
return $this->{$match['method']}($parameters[0], $match['unit']);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->set($method, \count($parameters) === 0 ? 1 : $parameters[0]);
|
||||
} catch (UnknownSetterException $exception) {
|
||||
if ($this->localStrictModeEnabled ?? Carbon::isStrictModeEnabled()) {
|
||||
throw new BadFluentSetterException($method, 0, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getForHumansInitialVariables($syntax, $short)
|
||||
{
|
||||
if (\is_array($syntax)) {
|
||||
return $syntax;
|
||||
}
|
||||
|
||||
if (\is_int($short)) {
|
||||
return [
|
||||
'parts' => $short,
|
||||
'short' => false,
|
||||
];
|
||||
}
|
||||
|
||||
if (\is_bool($syntax)) {
|
||||
return [
|
||||
'short' => $syntax,
|
||||
'syntax' => CarbonInterface::DIFF_ABSOLUTE,
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $syntax
|
||||
* @param mixed $short
|
||||
* @param mixed $parts
|
||||
* @param mixed $options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getForHumansParameters($syntax = null, $short = false, $parts = -1, $options = null)
|
||||
{
|
||||
$optionalSpace = ' ';
|
||||
$default = $this->getTranslationMessage('list.0') ?? $this->getTranslationMessage('list') ?? ' ';
|
||||
$join = $default === '' ? '' : ' ';
|
||||
$altNumbers = false;
|
||||
$aUnit = false;
|
||||
$minimumUnit = 's';
|
||||
extract($this->getForHumansInitialVariables($syntax, $short));
|
||||
|
||||
if ($syntax === null) {
|
||||
$syntax = CarbonInterface::DIFF_ABSOLUTE;
|
||||
}
|
||||
|
||||
if ($parts === -1) {
|
||||
$parts = INF;
|
||||
}
|
||||
|
||||
if ($options === null) {
|
||||
$options = static::getHumanDiffOptions();
|
||||
}
|
||||
|
||||
if ($join === false) {
|
||||
$join = ' ';
|
||||
} elseif ($join === true) {
|
||||
$join = [
|
||||
$default,
|
||||
$this->getTranslationMessage('list.1') ?? $default,
|
||||
];
|
||||
}
|
||||
|
||||
if ($altNumbers) {
|
||||
if ($altNumbers !== true) {
|
||||
$language = new Language($this->locale);
|
||||
$altNumbers = \in_array($language->getCode(), (array) $altNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
if (\is_array($join)) {
|
||||
[$default, $last] = $join;
|
||||
|
||||
if ($default !== ' ') {
|
||||
$optionalSpace = '';
|
||||
}
|
||||
|
||||
$join = function ($list) use ($default, $last) {
|
||||
if (\count($list) < 2) {
|
||||
return implode('', $list);
|
||||
}
|
||||
|
||||
$end = array_pop($list);
|
||||
|
||||
return implode($default, $list).$last.$end;
|
||||
};
|
||||
}
|
||||
|
||||
if (\is_string($join)) {
|
||||
if ($join !== ' ') {
|
||||
$optionalSpace = '';
|
||||
}
|
||||
|
||||
$glue = $join;
|
||||
$join = function ($list) use ($glue) {
|
||||
return implode($glue, $list);
|
||||
};
|
||||
}
|
||||
|
||||
$interpolations = [
|
||||
':optional-space' => $optionalSpace,
|
||||
];
|
||||
|
||||
return [$syntax, $short, $parts, $options, $join, $aUnit, $altNumbers, $interpolations, $minimumUnit];
|
||||
}
|
||||
|
||||
protected static function getRoundingMethodFromOptions(int $options): ?string
|
||||
{
|
||||
if ($options & CarbonInterface::ROUND) {
|
||||
return 'round';
|
||||
}
|
||||
|
||||
if ($options & CarbonInterface::CEIL) {
|
||||
return 'ceil';
|
||||
}
|
||||
|
||||
if ($options & CarbonInterface::FLOOR) {
|
||||
return 'floor';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns interval values as an array where key are the unit names and values the counts.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
'years' => $this->years,
|
||||
'months' => $this->months,
|
||||
'weeks' => $this->weeks,
|
||||
'days' => $this->daysExcludeWeeks,
|
||||
'hours' => $this->hours,
|
||||
'minutes' => $this->minutes,
|
||||
'seconds' => $this->seconds,
|
||||
'microseconds' => $this->microseconds,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns interval non-zero values as an array where key are the unit names and values the counts.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function getNonZeroValues()
|
||||
{
|
||||
return array_filter($this->toArray(), 'intval');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns interval values as an array where key are the unit names and values the counts
|
||||
* from the biggest non-zero one the the smallest non-zero one.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function getValuesSequence()
|
||||
{
|
||||
$nonZeroValues = $this->getNonZeroValues();
|
||||
|
||||
if ($nonZeroValues === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$keys = array_keys($nonZeroValues);
|
||||
$firstKey = $keys[0];
|
||||
$lastKey = $keys[\count($keys) - 1];
|
||||
$values = [];
|
||||
$record = false;
|
||||
|
||||
foreach ($this->toArray() as $unit => $count) {
|
||||
if ($unit === $firstKey) {
|
||||
$record = true;
|
||||
}
|
||||
|
||||
if ($record) {
|
||||
$values[$unit] = $count;
|
||||
}
|
||||
|
||||
if ($unit === $lastKey) {
|
||||
$record = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current interval in a human readable format in the current locale.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* echo CarbonInterval::fromString('4d 3h 40m')->forHumans() . "\n";
|
||||
* echo CarbonInterval::fromString('4d 3h 40m')->forHumans(['parts' => 2]) . "\n";
|
||||
* echo CarbonInterval::fromString('4d 3h 40m')->forHumans(['parts' => 3, 'join' => true]) . "\n";
|
||||
* echo CarbonInterval::fromString('4d 3h 40m')->forHumans(['short' => true]) . "\n";
|
||||
* echo CarbonInterval::fromString('1d 24h')->forHumans(['join' => ' or ']) . "\n";
|
||||
* echo CarbonInterval::fromString('1d 24h')->forHumans(['minimumUnit' => 'hour']) . "\n";
|
||||
* ```
|
||||
*
|
||||
* @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains:
|
||||
* - 'syntax' entry (see below)
|
||||
* - 'short' entry (see below)
|
||||
* - 'parts' entry (see below)
|
||||
* - 'options' entry (see below)
|
||||
* - 'aUnit' entry, prefer "an hour" over "1 hour" if true
|
||||
* - 'join' entry determines how to join multiple parts of the string
|
||||
* ` - if $join is a string, it's used as a joiner glue
|
||||
* ` - if $join is a callable/closure, it get the list of string and should return a string
|
||||
* ` - if $join is an array, the first item will be the default glue, and the second item
|
||||
* ` will be used instead of the glue for the last item
|
||||
* ` - if $join is true, it will be guessed from the locale ('list' translation file entry)
|
||||
* ` - if $join is missing, a space will be used as glue
|
||||
* - 'minimumUnit' entry determines the smallest unit of time to display can be long or
|
||||
* ` short form of the units, e.g. 'hour' or 'h' (default value: s)
|
||||
* if int passed, it add modifiers:
|
||||
* Possible values:
|
||||
* - CarbonInterface::DIFF_ABSOLUTE no modifiers
|
||||
* - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
|
||||
* - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier
|
||||
* Default value: CarbonInterface::DIFF_ABSOLUTE
|
||||
* @param bool $short displays short format of time units
|
||||
* @param int $parts maximum number of parts to display (default value: -1: no limits)
|
||||
* @param int $options human diff options
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function forHumans($syntax = null, $short = false, $parts = -1, $options = null)
|
||||
{
|
||||
[$syntax, $short, $parts, $options, $join, $aUnit, $altNumbers, $interpolations, $minimumUnit] = $this->getForHumansParameters($syntax, $short, $parts, $options);
|
||||
|
||||
$interval = [];
|
||||
|
||||
$syntax = (int) ($syntax ?? CarbonInterface::DIFF_ABSOLUTE);
|
||||
$absolute = $syntax === CarbonInterface::DIFF_ABSOLUTE;
|
||||
$relativeToNow = $syntax === CarbonInterface::DIFF_RELATIVE_TO_NOW;
|
||||
$count = 1;
|
||||
$unit = $short ? 's' : 'second';
|
||||
$isFuture = $this->invert === 1;
|
||||
$transId = $relativeToNow ? ($isFuture ? 'from_now' : 'ago') : ($isFuture ? 'after' : 'before');
|
||||
|
||||
/** @var \Symfony\Component\Translation\Translator $translator */
|
||||
$translator = $this->getLocalTranslator();
|
||||
|
||||
$handleDeclensions = function ($unit, $count) use ($interpolations, $transId, $translator, $altNumbers, $absolute) {
|
||||
if (!$absolute) {
|
||||
// Some languages have special pluralization for past and future tense.
|
||||
$key = $unit.'_'.$transId;
|
||||
$result = $this->translate($key, $interpolations, $count, $translator, $altNumbers);
|
||||
|
||||
if ($result !== $key) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->translate($unit, $interpolations, $count, $translator, $altNumbers);
|
||||
|
||||
if ($result !== $unit) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
$intervalValues = $this;
|
||||
$method = static::getRoundingMethodFromOptions($options);
|
||||
|
||||
if ($method) {
|
||||
$previousCount = INF;
|
||||
|
||||
while (
|
||||
\count($intervalValues->getNonZeroValues()) > $parts &&
|
||||
($count = \count($keys = array_keys($intervalValues->getValuesSequence()))) > 1
|
||||
) {
|
||||
$intervalValues = $this->copy()->roundUnit(
|
||||
$keys[min($count, $previousCount - 1) - 2],
|
||||
1,
|
||||
$method
|
||||
);
|
||||
$previousCount = $count;
|
||||
}
|
||||
}
|
||||
|
||||
$diffIntervalArray = [
|
||||
['value' => $intervalValues->years, 'unit' => 'year', 'unitShort' => 'y'],
|
||||
['value' => $intervalValues->months, 'unit' => 'month', 'unitShort' => 'm'],
|
||||
['value' => $intervalValues->weeks, 'unit' => 'week', 'unitShort' => 'w'],
|
||||
['value' => $intervalValues->daysExcludeWeeks, 'unit' => 'day', 'unitShort' => 'd'],
|
||||
['value' => $intervalValues->hours, 'unit' => 'hour', 'unitShort' => 'h'],
|
||||
['value' => $intervalValues->minutes, 'unit' => 'minute', 'unitShort' => 'min'],
|
||||
['value' => $intervalValues->seconds, 'unit' => 'second', 'unitShort' => 's'],
|
||||
['value' => $intervalValues->milliseconds, 'unit' => 'millisecond', 'unitShort' => 'ms'],
|
||||
['value' => $intervalValues->microExcludeMilli, 'unit' => 'microsecond', 'unitShort' => 'µs'],
|
||||
];
|
||||
|
||||
$transChoice = function ($short, $unitData) use ($absolute, $handleDeclensions, $translator, $aUnit, $altNumbers, $interpolations) {
|
||||
$count = $unitData['value'];
|
||||
|
||||
if ($short) {
|
||||
$result = $handleDeclensions($unitData['unitShort'], $count);
|
||||
|
||||
if ($result !== null) {
|
||||
return $result;
|
||||
}
|
||||
} elseif ($aUnit) {
|
||||
$result = $handleDeclensions('a_'.$unitData['unit'], $count);
|
||||
|
||||
if ($result !== null) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$absolute) {
|
||||
return $handleDeclensions($unitData['unit'], $count);
|
||||
}
|
||||
|
||||
return $this->translate($unitData['unit'], $interpolations, $count, $translator, $altNumbers);
|
||||
};
|
||||
|
||||
$fallbackUnit = ['second', 's'];
|
||||
foreach ($diffIntervalArray as $diffIntervalData) {
|
||||
if ($diffIntervalData['value'] > 0) {
|
||||
$unit = $short ? $diffIntervalData['unitShort'] : $diffIntervalData['unit'];
|
||||
$count = $diffIntervalData['value'];
|
||||
$interval[] = $transChoice($short, $diffIntervalData);
|
||||
} elseif ($options & CarbonInterface::SEQUENTIAL_PARTS_ONLY && \count($interval) > 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// break the loop after we get the required number of parts in array
|
||||
if (\count($interval) >= $parts) {
|
||||
break;
|
||||
}
|
||||
|
||||
// break the loop after we have reached the minimum unit
|
||||
if (\in_array($minimumUnit, [$diffIntervalData['unit'], $diffIntervalData['unitShort']])) {
|
||||
$fallbackUnit = [$diffIntervalData['unit'], $diffIntervalData['unitShort']];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (\count($interval) === 0) {
|
||||
if ($relativeToNow && $options & CarbonInterface::JUST_NOW) {
|
||||
$key = 'diff_now';
|
||||
$translation = $this->translate($key, $interpolations, null, $translator);
|
||||
|
||||
if ($translation !== $key) {
|
||||
return $translation;
|
||||
}
|
||||
}
|
||||
|
||||
$count = $options & CarbonInterface::NO_ZERO_DIFF ? 1 : 0;
|
||||
$unit = $fallbackUnit[$short ? 1 : 0];
|
||||
$interval[] = $this->translate($unit, $interpolations, $count, $translator, $altNumbers);
|
||||
}
|
||||
|
||||
// join the interval parts by a space
|
||||
$time = $join($interval);
|
||||
|
||||
unset($diffIntervalArray, $interval);
|
||||
|
||||
if ($absolute) {
|
||||
return $time;
|
||||
}
|
||||
|
||||
$isFuture = $this->invert === 1;
|
||||
|
||||
$transId = $relativeToNow ? ($isFuture ? 'from_now' : 'ago') : ($isFuture ? 'after' : 'before');
|
||||
|
||||
if ($parts === 1) {
|
||||
if ($relativeToNow && $unit === 'day') {
|
||||
if ($count === 1 && $options & CarbonInterface::ONE_DAY_WORDS) {
|
||||
$key = $isFuture ? 'diff_tomorrow' : 'diff_yesterday';
|
||||
$translation = $this->translate($key, $interpolations, null, $translator);
|
||||
|
||||
if ($translation !== $key) {
|
||||
return $translation;
|
||||
}
|
||||
}
|
||||
|
||||
if ($count === 2 && $options & CarbonInterface::TWO_DAY_WORDS) {
|
||||
$key = $isFuture ? 'diff_after_tomorrow' : 'diff_before_yesterday';
|
||||
$translation = $this->translate($key, $interpolations, null, $translator);
|
||||
|
||||
if ($translation !== $key) {
|
||||
return $translation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aTime = $aUnit ? $handleDeclensions('a_'.$unit, $count) : null;
|
||||
|
||||
$time = $aTime ?: $handleDeclensions($unit, $count) ?: $time;
|
||||
}
|
||||
|
||||
$time = [':time' => $time];
|
||||
|
||||
return $this->translate($transId, array_merge($time, $interpolations, $time), null, $translator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the instance as a string using the forHumans() function.
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$format = $this->localToStringFormat;
|
||||
|
||||
if ($format) {
|
||||
if ($format instanceof Closure) {
|
||||
return $format($this);
|
||||
}
|
||||
|
||||
return $this->format($format);
|
||||
}
|
||||
|
||||
return $this->forHumans();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return native DateInterval PHP object matching the current instance.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* var_dump(CarbonInterval::hours(2)->toDateInterval());
|
||||
* ```
|
||||
*
|
||||
* @return DateInterval
|
||||
*/
|
||||
public function toDateInterval()
|
||||
{
|
||||
return self::castIntervalToClass($this, DateInterval::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the interval to a CarbonPeriod.
|
||||
*
|
||||
* @param DateTimeInterface|string|int ...$params Start date, [end date or recurrences] and optional settings.
|
||||
*
|
||||
* @return CarbonPeriod
|
||||
*/
|
||||
public function toPeriod(...$params)
|
||||
{
|
||||
if ($this->tzName) {
|
||||
$tz = \is_string($this->tzName) ? new DateTimeZone($this->tzName) : $this->tzName;
|
||||
|
||||
if ($tz instanceof DateTimeZone) {
|
||||
array_unshift($params, $tz);
|
||||
}
|
||||
}
|
||||
|
||||
return CarbonPeriod::create($this, ...$params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert the interval.
|
||||
*
|
||||
* @param bool|int $inverted if a parameter is passed, the passed value casted as 1 or 0 is used
|
||||
* as the new value of the ->invert property.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function invert($inverted = null)
|
||||
{
|
||||
$this->invert = (\func_num_args() === 0 ? !$this->invert : $inverted) ? 1 : 0;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function solveNegativeInterval()
|
||||
{
|
||||
if (!$this->isEmpty() && $this->years <= 0 && $this->months <= 0 && $this->dayz <= 0 && $this->hours <= 0 && $this->minutes <= 0 && $this->seconds <= 0 && $this->microseconds <= 0) {
|
||||
$this->years *= -1;
|
||||
$this->months *= -1;
|
||||
$this->dayz *= -1;
|
||||
$this->hours *= -1;
|
||||
$this->minutes *= -1;
|
||||
$this->seconds *= -1;
|
||||
$this->microseconds *= -1;
|
||||
$this->invert();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the passed interval to the current instance.
|
||||
*
|
||||
* @param string|DateInterval $unit
|
||||
* @param int|float $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function add($unit, $value = 1)
|
||||
{
|
||||
if (is_numeric($unit)) {
|
||||
[$value, $unit] = [$unit, $value];
|
||||
}
|
||||
|
||||
if (\is_string($unit) && !preg_match('/^\s*\d/', $unit)) {
|
||||
$unit = "$value $unit";
|
||||
$value = 1;
|
||||
}
|
||||
|
||||
$interval = static::make($unit);
|
||||
|
||||
if (!$interval) {
|
||||
throw new InvalidIntervalException('This type of data cannot be added/subtracted.');
|
||||
}
|
||||
|
||||
if ($value !== 1) {
|
||||
$interval->times($value);
|
||||
}
|
||||
|
||||
$sign = ($this->invert === 1) !== ($interval->invert === 1) ? -1 : 1;
|
||||
$this->years += $interval->y * $sign;
|
||||
$this->months += $interval->m * $sign;
|
||||
$this->dayz += ($interval->days === false ? $interval->d : $interval->days) * $sign;
|
||||
$this->hours += $interval->h * $sign;
|
||||
$this->minutes += $interval->i * $sign;
|
||||
$this->seconds += $interval->s * $sign;
|
||||
$this->microseconds += $interval->microseconds * $sign;
|
||||
|
||||
$this->solveNegativeInterval();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract the passed interval to the current instance.
|
||||
*
|
||||
* @param string|DateInterval $unit
|
||||
* @param int|float $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sub($unit, $value = 1)
|
||||
{
|
||||
if (is_numeric($unit)) {
|
||||
[$value, $unit] = [$unit, $value];
|
||||
}
|
||||
|
||||
return $this->add($unit, -(float) $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract the passed interval to the current instance.
|
||||
*
|
||||
* @param string|DateInterval $unit
|
||||
* @param int|float $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function subtract($unit, $value = 1)
|
||||
{
|
||||
return $this->sub($unit, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add given parameters to the current interval.
|
||||
*
|
||||
* @param int $years
|
||||
* @param int $months
|
||||
* @param int|float $weeks
|
||||
* @param int|float $days
|
||||
* @param int|float $hours
|
||||
* @param int|float $minutes
|
||||
* @param int|float $seconds
|
||||
* @param int|float $microseconds
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function plus(
|
||||
$years = 0,
|
||||
$months = 0,
|
||||
$weeks = 0,
|
||||
$days = 0,
|
||||
$hours = 0,
|
||||
$minutes = 0,
|
||||
$seconds = 0,
|
||||
$microseconds = 0
|
||||
): self {
|
||||
return $this->add("
|
||||
$years years $months months $weeks weeks $days days
|
||||
$hours hours $minutes minutes $seconds seconds $microseconds microseconds
|
||||
");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add given parameters to the current interval.
|
||||
*
|
||||
* @param int $years
|
||||
* @param int $months
|
||||
* @param int|float $weeks
|
||||
* @param int|float $days
|
||||
* @param int|float $hours
|
||||
* @param int|float $minutes
|
||||
* @param int|float $seconds
|
||||
* @param int|float $microseconds
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function minus(
|
||||
$years = 0,
|
||||
$months = 0,
|
||||
$weeks = 0,
|
||||
$days = 0,
|
||||
$hours = 0,
|
||||
$minutes = 0,
|
||||
$seconds = 0,
|
||||
$microseconds = 0
|
||||
): self {
|
||||
return $this->sub("
|
||||
$years years $months months $weeks weeks $days days
|
||||
$hours hours $minutes minutes $seconds seconds $microseconds microseconds
|
||||
");
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply current instance given number of times. times() is naive, it multiplies each unit
|
||||
* (so day can be greater than 31, hour can be greater than 23, etc.) and the result is rounded
|
||||
* separately for each unit.
|
||||
*
|
||||
* Use times() when you want a fast and approximated calculation that does not cascade units.
|
||||
*
|
||||
* For a precise and cascaded calculation,
|
||||
*
|
||||
* @see multiply()
|
||||
*
|
||||
* @param float|int $factor
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function times($factor)
|
||||
{
|
||||
if ($factor < 0) {
|
||||
$this->invert = $this->invert ? 0 : 1;
|
||||
$factor = -$factor;
|
||||
}
|
||||
|
||||
$this->years = (int) round($this->years * $factor);
|
||||
$this->months = (int) round($this->months * $factor);
|
||||
$this->dayz = (int) round($this->dayz * $factor);
|
||||
$this->hours = (int) round($this->hours * $factor);
|
||||
$this->minutes = (int) round($this->minutes * $factor);
|
||||
$this->seconds = (int) round($this->seconds * $factor);
|
||||
$this->microseconds = (int) round($this->microseconds * $factor);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide current instance by a given divider. shares() is naive, it divides each unit separately
|
||||
* and the result is rounded for each unit. So 5 hours and 20 minutes shared by 3 becomes 2 hours
|
||||
* and 7 minutes.
|
||||
*
|
||||
* Use shares() when you want a fast and approximated calculation that does not cascade units.
|
||||
*
|
||||
* For a precise and cascaded calculation,
|
||||
*
|
||||
* @see divide()
|
||||
*
|
||||
* @param float|int $divider
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function shares($divider)
|
||||
{
|
||||
return $this->times(1 / $divider);
|
||||
}
|
||||
|
||||
protected function copyProperties(self $interval, $ignoreSign = false)
|
||||
{
|
||||
$this->years = $interval->years;
|
||||
$this->months = $interval->months;
|
||||
$this->dayz = $interval->dayz;
|
||||
$this->hours = $interval->hours;
|
||||
$this->minutes = $interval->minutes;
|
||||
$this->seconds = $interval->seconds;
|
||||
$this->microseconds = $interval->microseconds;
|
||||
|
||||
if (!$ignoreSign) {
|
||||
$this->invert = $interval->invert;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply and cascade current instance by a given factor.
|
||||
*
|
||||
* @param float|int $factor
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function multiply($factor)
|
||||
{
|
||||
if ($factor < 0) {
|
||||
$this->invert = $this->invert ? 0 : 1;
|
||||
$factor = -$factor;
|
||||
}
|
||||
|
||||
$yearPart = (int) floor($this->years * $factor); // Split calculation to prevent imprecision
|
||||
|
||||
if ($yearPart) {
|
||||
$this->years -= $yearPart / $factor;
|
||||
}
|
||||
|
||||
return $this->copyProperties(
|
||||
static::create($yearPart)
|
||||
->microseconds(abs($this->totalMicroseconds) * $factor)
|
||||
->cascade(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide and cascade current instance by a given divider.
|
||||
*
|
||||
* @param float|int $divider
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function divide($divider)
|
||||
{
|
||||
return $this->multiply(1 / $divider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the interval_spec string of a date interval.
|
||||
*
|
||||
* @param DateInterval $interval
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDateIntervalSpec(DateInterval $interval)
|
||||
{
|
||||
$date = array_filter([
|
||||
static::PERIOD_YEARS => abs($interval->y),
|
||||
static::PERIOD_MONTHS => abs($interval->m),
|
||||
static::PERIOD_DAYS => abs($interval->d),
|
||||
]);
|
||||
|
||||
$time = array_filter([
|
||||
static::PERIOD_HOURS => abs($interval->h),
|
||||
static::PERIOD_MINUTES => abs($interval->i),
|
||||
static::PERIOD_SECONDS => abs($interval->s),
|
||||
]);
|
||||
|
||||
$specString = static::PERIOD_PREFIX;
|
||||
|
||||
foreach ($date as $key => $value) {
|
||||
$specString .= $value.$key;
|
||||
}
|
||||
|
||||
if (\count($time) > 0) {
|
||||
$specString .= static::PERIOD_TIME_PREFIX;
|
||||
foreach ($time as $key => $value) {
|
||||
$specString .= $value.$key;
|
||||
}
|
||||
}
|
||||
|
||||
return $specString === static::PERIOD_PREFIX ? 'PT0S' : $specString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the interval_spec string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function spec()
|
||||
{
|
||||
return static::getDateIntervalSpec($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparing 2 date intervals.
|
||||
*
|
||||
* @param DateInterval $first
|
||||
* @param DateInterval $second
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function compareDateIntervals(DateInterval $first, DateInterval $second)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$passed = $current->avoidMutation()->add($second);
|
||||
$current->add($first);
|
||||
|
||||
if ($current < $passed) {
|
||||
return -1;
|
||||
}
|
||||
if ($current > $passed) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparing with passed interval.
|
||||
*
|
||||
* @param DateInterval $interval
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function compare(DateInterval $interval)
|
||||
{
|
||||
return static::compareDateIntervals($this, $interval);
|
||||
}
|
||||
|
||||
private function invertCascade(array $values)
|
||||
{
|
||||
return $this->set(array_map(function ($value) {
|
||||
return -$value;
|
||||
}, $values))->doCascade(true)->invert();
|
||||
}
|
||||
|
||||
private function doCascade(bool $deep)
|
||||
{
|
||||
$originalData = $this->toArray();
|
||||
$originalData['milliseconds'] = (int) ($originalData['microseconds'] / static::getMicrosecondsPerMillisecond());
|
||||
$originalData['microseconds'] = $originalData['microseconds'] % static::getMicrosecondsPerMillisecond();
|
||||
$originalData['daysExcludeWeeks'] = $originalData['days'];
|
||||
unset($originalData['days']);
|
||||
$newData = $originalData;
|
||||
|
||||
foreach (static::getFlipCascadeFactors() as $source => [$target, $factor]) {
|
||||
foreach (['source', 'target'] as $key) {
|
||||
if ($$key === 'dayz') {
|
||||
$$key = 'daysExcludeWeeks';
|
||||
}
|
||||
}
|
||||
|
||||
$value = $newData[$source];
|
||||
$modulo = ($factor + ($value % $factor)) % $factor;
|
||||
$newData[$source] = $modulo;
|
||||
$newData[$target] += ($value - $modulo) / $factor;
|
||||
}
|
||||
|
||||
$positive = null;
|
||||
|
||||
if (!$deep) {
|
||||
foreach ($newData as $value) {
|
||||
if ($value) {
|
||||
if ($positive === null) {
|
||||
$positive = ($value > 0);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (($value > 0) !== $positive) {
|
||||
return $this->invertCascade($originalData)
|
||||
->solveNegativeInterval();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->set($newData)
|
||||
->solveNegativeInterval();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert overflowed values into bigger units.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function cascade()
|
||||
{
|
||||
return $this->doCascade(false);
|
||||
}
|
||||
|
||||
public function hasNegativeValues(): bool
|
||||
{
|
||||
foreach ($this->toArray() as $value) {
|
||||
if ($value < 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hasPositiveValues(): bool
|
||||
{
|
||||
foreach ($this->toArray() as $value) {
|
||||
if ($value > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get amount of given unit equivalent to the interval.
|
||||
*
|
||||
* @param string $unit
|
||||
*
|
||||
* @throws UnknownUnitException|UnitNotConfiguredException
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function total($unit)
|
||||
{
|
||||
$realUnit = $unit = strtolower($unit);
|
||||
|
||||
if (\in_array($unit, ['days', 'weeks'])) {
|
||||
$realUnit = 'dayz';
|
||||
} elseif (!\in_array($unit, ['microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', 'dayz', 'months', 'years'])) {
|
||||
throw new UnknownUnitException($unit);
|
||||
}
|
||||
|
||||
$result = 0;
|
||||
$cumulativeFactor = 0;
|
||||
$unitFound = false;
|
||||
$factors = static::getFlipCascadeFactors();
|
||||
$daysPerWeek = static::getDaysPerWeek();
|
||||
|
||||
$values = [
|
||||
'years' => $this->years,
|
||||
'months' => $this->months,
|
||||
'weeks' => (int) ($this->d / $daysPerWeek),
|
||||
'dayz' => $this->d % $daysPerWeek,
|
||||
'hours' => $this->hours,
|
||||
'minutes' => $this->minutes,
|
||||
'seconds' => $this->seconds,
|
||||
'milliseconds' => (int) ($this->microseconds / Carbon::MICROSECONDS_PER_MILLISECOND),
|
||||
'microseconds' => $this->microseconds % Carbon::MICROSECONDS_PER_MILLISECOND,
|
||||
];
|
||||
|
||||
if (isset($factors['dayz']) && $factors['dayz'][0] !== 'weeks') {
|
||||
$values['dayz'] += $values['weeks'] * $daysPerWeek;
|
||||
$values['weeks'] = 0;
|
||||
}
|
||||
|
||||
foreach ($factors as $source => [$target, $factor]) {
|
||||
if ($source === $realUnit) {
|
||||
$unitFound = true;
|
||||
$value = $values[$source];
|
||||
$result += $value;
|
||||
$cumulativeFactor = 1;
|
||||
}
|
||||
|
||||
if ($factor === false) {
|
||||
if ($unitFound) {
|
||||
break;
|
||||
}
|
||||
|
||||
$result = 0;
|
||||
$cumulativeFactor = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($target === $realUnit) {
|
||||
$unitFound = true;
|
||||
}
|
||||
|
||||
if ($cumulativeFactor) {
|
||||
$cumulativeFactor *= $factor;
|
||||
$result += $values[$target] * $cumulativeFactor;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $values[$source];
|
||||
|
||||
$result = ($result + $value) / $factor;
|
||||
}
|
||||
|
||||
if (isset($target) && !$cumulativeFactor) {
|
||||
$result += $values[$target];
|
||||
}
|
||||
|
||||
if (!$unitFound) {
|
||||
throw new UnitNotConfiguredException($unit);
|
||||
}
|
||||
|
||||
if ($this->invert) {
|
||||
$result *= -1;
|
||||
}
|
||||
|
||||
if ($unit === 'weeks') {
|
||||
return $result / $daysPerWeek;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is equal to another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @see equalTo()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function eq($interval): bool
|
||||
{
|
||||
return $this->equalTo($interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is equal to another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function equalTo($interval): bool
|
||||
{
|
||||
$interval = $this->resolveInterval($interval);
|
||||
|
||||
return $interval !== null && $this->totalMicroseconds === $interval->totalMicroseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is not equal to another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @see notEqualTo()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ne($interval): bool
|
||||
{
|
||||
return $this->notEqualTo($interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is not equal to another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function notEqualTo($interval): bool
|
||||
{
|
||||
return !$this->eq($interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is greater (longer) than another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @see greaterThan()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function gt($interval): bool
|
||||
{
|
||||
return $this->greaterThan($interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is greater (longer) than another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function greaterThan($interval): bool
|
||||
{
|
||||
$interval = $this->resolveInterval($interval);
|
||||
|
||||
return $interval === null || $this->totalMicroseconds > $interval->totalMicroseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is greater (longer) than or equal to another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @see greaterThanOrEqualTo()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function gte($interval): bool
|
||||
{
|
||||
return $this->greaterThanOrEqualTo($interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is greater (longer) than or equal to another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function greaterThanOrEqualTo($interval): bool
|
||||
{
|
||||
return $this->greaterThan($interval) || $this->equalTo($interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is less (shorter) than another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @see lessThan()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function lt($interval): bool
|
||||
{
|
||||
return $this->lessThan($interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is less (shorter) than another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function lessThan($interval): bool
|
||||
{
|
||||
$interval = $this->resolveInterval($interval);
|
||||
|
||||
return $interval !== null && $this->totalMicroseconds < $interval->totalMicroseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is less (shorter) than or equal to another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @see lessThanOrEqualTo()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function lte($interval): bool
|
||||
{
|
||||
return $this->lessThanOrEqualTo($interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is less (shorter) than or equal to another
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function lessThanOrEqualTo($interval): bool
|
||||
{
|
||||
return $this->lessThan($interval) || $this->equalTo($interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is between two others.
|
||||
*
|
||||
* The third argument allow you to specify if bounds are included or not (true by default)
|
||||
* but for when you including/excluding bounds may produce different results in your application,
|
||||
* we recommend to use the explicit methods ->betweenIncluded() or ->betweenExcluded() instead.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(3)); // true
|
||||
* CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::hours(36)); // false
|
||||
* CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(2)); // true
|
||||
* CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(2), false); // false
|
||||
* ```
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval1
|
||||
* @param CarbonInterval|DateInterval|mixed $interval2
|
||||
* @param bool $equal Indicates if an equal to comparison should be done
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function between($interval1, $interval2, $equal = true): bool
|
||||
{
|
||||
return $equal
|
||||
? $this->greaterThanOrEqualTo($interval1) && $this->lessThanOrEqualTo($interval2)
|
||||
: $this->greaterThan($interval1) && $this->lessThan($interval2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is between two others, bounds excluded.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(3)); // true
|
||||
* CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::hours(36)); // false
|
||||
* CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(2)); // true
|
||||
* ```
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval1
|
||||
* @param CarbonInterval|DateInterval|mixed $interval2
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function betweenIncluded($interval1, $interval2): bool
|
||||
{
|
||||
return $this->between($interval1, $interval2, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is between two others, bounds excluded.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(3)); // true
|
||||
* CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::hours(36)); // false
|
||||
* CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(2)); // false
|
||||
* ```
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval1
|
||||
* @param CarbonInterval|DateInterval|mixed $interval2
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function betweenExcluded($interval1, $interval2): bool
|
||||
{
|
||||
return $this->between($interval1, $interval2, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is between two others
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(3)); // true
|
||||
* CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::hours(36)); // false
|
||||
* CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(2)); // true
|
||||
* CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(2), false); // false
|
||||
* ```
|
||||
*
|
||||
* @param CarbonInterval|DateInterval|mixed $interval1
|
||||
* @param CarbonInterval|DateInterval|mixed $interval2
|
||||
* @param bool $equal Indicates if an equal to comparison should be done
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isBetween($interval1, $interval2, $equal = true): bool
|
||||
{
|
||||
return $this->between($interval1, $interval2, $equal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Round the current instance at the given unit with given precision if specified and the given function.
|
||||
*
|
||||
* @param string $unit
|
||||
* @param float|int|string|DateInterval|null $precision
|
||||
* @param string $function
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function roundUnit($unit, $precision = 1, $function = 'round')
|
||||
{
|
||||
$base = CarbonImmutable::parse('2000-01-01 00:00:00', 'UTC')
|
||||
->roundUnit($unit, $precision, $function);
|
||||
$next = $base->add($this);
|
||||
$inverted = $next < $base;
|
||||
|
||||
if ($inverted) {
|
||||
$next = $base->sub($this);
|
||||
}
|
||||
|
||||
$this->copyProperties(
|
||||
$next
|
||||
->roundUnit($unit, $precision, $function)
|
||||
->diffAsCarbonInterval($base)
|
||||
);
|
||||
|
||||
return $this->invert($inverted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate the current instance at the given unit with given precision if specified.
|
||||
*
|
||||
* @param string $unit
|
||||
* @param float|int|string|DateInterval|null $precision
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function floorUnit($unit, $precision = 1)
|
||||
{
|
||||
return $this->roundUnit($unit, $precision, 'floor');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ceil the current instance at the given unit with given precision if specified.
|
||||
*
|
||||
* @param string $unit
|
||||
* @param float|int|string|DateInterval|null $precision
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ceilUnit($unit, $precision = 1)
|
||||
{
|
||||
return $this->roundUnit($unit, $precision, 'ceil');
|
||||
}
|
||||
|
||||
/**
|
||||
* Round the current instance second with given precision if specified.
|
||||
*
|
||||
* @param float|int|string|DateInterval|null $precision
|
||||
* @param string $function
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function round($precision = 1, $function = 'round')
|
||||
{
|
||||
return $this->roundWith($precision, $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Round the current instance second with given precision if specified.
|
||||
*
|
||||
* @param float|int|string|DateInterval|null $precision
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function floor($precision = 1)
|
||||
{
|
||||
return $this->round($precision, 'floor');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ceil the current instance second with given precision if specified.
|
||||
*
|
||||
* @param float|int|string|DateInterval|null $precision
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ceil($precision = 1)
|
||||
{
|
||||
return $this->round($precision, 'ceil');
|
||||
}
|
||||
}
|
||||
+2556
@@ -0,0 +1,2556 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon;
|
||||
|
||||
use Carbon\Exceptions\InvalidCastException;
|
||||
use Carbon\Exceptions\InvalidIntervalException;
|
||||
use Carbon\Exceptions\InvalidPeriodDateException;
|
||||
use Carbon\Exceptions\InvalidPeriodParameterException;
|
||||
use Carbon\Exceptions\NotACarbonClassException;
|
||||
use Carbon\Exceptions\NotAPeriodException;
|
||||
use Carbon\Exceptions\UnknownGetterException;
|
||||
use Carbon\Exceptions\UnknownMethodException;
|
||||
use Carbon\Exceptions\UnreachableException;
|
||||
use Carbon\Traits\IntervalRounding;
|
||||
use Carbon\Traits\Mixin;
|
||||
use Carbon\Traits\Options;
|
||||
use Closure;
|
||||
use Countable;
|
||||
use DateInterval;
|
||||
use DatePeriod;
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
use DateTimeZone;
|
||||
use InvalidArgumentException;
|
||||
use Iterator;
|
||||
use JsonSerializable;
|
||||
use ReflectionException;
|
||||
use ReturnTypeWillChange;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Substitution of DatePeriod with some modifications and many more features.
|
||||
*
|
||||
* @property-read int|float $recurrences number of recurrences (if end not set).
|
||||
* @property-read bool $include_start_date rather the start date is included in the iteration.
|
||||
* @property-read bool $include_end_date rather the end date is included in the iteration (if recurrences not set).
|
||||
* @property-read CarbonInterface $start Period start date.
|
||||
* @property-read CarbonInterface $current Current date from the iteration.
|
||||
* @property-read CarbonInterface $end Period end date.
|
||||
* @property-read CarbonInterval $interval Underlying date interval instance. Always present, one day by default.
|
||||
*
|
||||
* @method static CarbonPeriod start($date, $inclusive = null) Create instance specifying start date or modify the start date if called on an instance.
|
||||
* @method static CarbonPeriod since($date, $inclusive = null) Alias for start().
|
||||
* @method static CarbonPeriod sinceNow($inclusive = null) Create instance with start date set to now or set the start date to now if called on an instance.
|
||||
* @method static CarbonPeriod end($date = null, $inclusive = null) Create instance specifying end date or modify the end date if called on an instance.
|
||||
* @method static CarbonPeriod until($date = null, $inclusive = null) Alias for end().
|
||||
* @method static CarbonPeriod untilNow($inclusive = null) Create instance with end date set to now or set the end date to now if called on an instance.
|
||||
* @method static CarbonPeriod dates($start, $end = null) Create instance with start and end dates or modify the start and end dates if called on an instance.
|
||||
* @method static CarbonPeriod between($start, $end = null) Create instance with start and end dates or modify the start and end dates if called on an instance.
|
||||
* @method static CarbonPeriod recurrences($recurrences = null) Create instance with maximum number of recurrences or modify the number of recurrences if called on an instance.
|
||||
* @method static CarbonPeriod times($recurrences = null) Alias for recurrences().
|
||||
* @method static CarbonPeriod options($options = null) Create instance with options or modify the options if called on an instance.
|
||||
* @method static CarbonPeriod toggle($options, $state = null) Create instance with options toggled on or off, or toggle options if called on an instance.
|
||||
* @method static CarbonPeriod filter($callback, $name = null) Create instance with filter added to the stack or append a filter if called on an instance.
|
||||
* @method static CarbonPeriod push($callback, $name = null) Alias for filter().
|
||||
* @method static CarbonPeriod prepend($callback, $name = null) Create instance with filter prepended to the stack or prepend a filter if called on an instance.
|
||||
* @method static CarbonPeriod filters(array $filters = []) Create instance with filters stack or replace the whole filters stack if called on an instance.
|
||||
* @method static CarbonPeriod interval($interval) Create instance with given date interval or modify the interval if called on an instance.
|
||||
* @method static CarbonPeriod each($interval) Create instance with given date interval or modify the interval if called on an instance.
|
||||
* @method static CarbonPeriod every($interval) Create instance with given date interval or modify the interval if called on an instance.
|
||||
* @method static CarbonPeriod step($interval) Create instance with given date interval or modify the interval if called on an instance.
|
||||
* @method static CarbonPeriod stepBy($interval) Create instance with given date interval or modify the interval if called on an instance.
|
||||
* @method static CarbonPeriod invert() Create instance with inverted date interval or invert the interval if called on an instance.
|
||||
* @method static CarbonPeriod years($years = 1) Create instance specifying a number of years for date interval or replace the interval by the given a number of years if called on an instance.
|
||||
* @method static CarbonPeriod year($years = 1) Alias for years().
|
||||
* @method static CarbonPeriod months($months = 1) Create instance specifying a number of months for date interval or replace the interval by the given a number of months if called on an instance.
|
||||
* @method static CarbonPeriod month($months = 1) Alias for months().
|
||||
* @method static CarbonPeriod weeks($weeks = 1) Create instance specifying a number of weeks for date interval or replace the interval by the given a number of weeks if called on an instance.
|
||||
* @method static CarbonPeriod week($weeks = 1) Alias for weeks().
|
||||
* @method static CarbonPeriod days($days = 1) Create instance specifying a number of days for date interval or replace the interval by the given a number of days if called on an instance.
|
||||
* @method static CarbonPeriod dayz($days = 1) Alias for days().
|
||||
* @method static CarbonPeriod day($days = 1) Alias for days().
|
||||
* @method static CarbonPeriod hours($hours = 1) Create instance specifying a number of hours for date interval or replace the interval by the given a number of hours if called on an instance.
|
||||
* @method static CarbonPeriod hour($hours = 1) Alias for hours().
|
||||
* @method static CarbonPeriod minutes($minutes = 1) Create instance specifying a number of minutes for date interval or replace the interval by the given a number of minutes if called on an instance.
|
||||
* @method static CarbonPeriod minute($minutes = 1) Alias for minutes().
|
||||
* @method static CarbonPeriod seconds($seconds = 1) Create instance specifying a number of seconds for date interval or replace the interval by the given a number of seconds if called on an instance.
|
||||
* @method static CarbonPeriod second($seconds = 1) Alias for seconds().
|
||||
* @method $this roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
|
||||
* @method $this roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function.
|
||||
* @method $this floorYear(float $precision = 1) Truncate the current instance year with given precision.
|
||||
* @method $this floorYears(float $precision = 1) Truncate the current instance year with given precision.
|
||||
* @method $this ceilYear(float $precision = 1) Ceil the current instance year with given precision.
|
||||
* @method $this ceilYears(float $precision = 1) Ceil the current instance year with given precision.
|
||||
* @method $this roundMonth(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
|
||||
* @method $this roundMonths(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function.
|
||||
* @method $this floorMonth(float $precision = 1) Truncate the current instance month with given precision.
|
||||
* @method $this floorMonths(float $precision = 1) Truncate the current instance month with given precision.
|
||||
* @method $this ceilMonth(float $precision = 1) Ceil the current instance month with given precision.
|
||||
* @method $this ceilMonths(float $precision = 1) Ceil the current instance month with given precision.
|
||||
* @method $this roundWeek(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method $this roundWeeks(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method $this floorWeek(float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method $this floorWeeks(float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method $this ceilWeek(float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method $this ceilWeeks(float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method $this roundDay(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method $this roundDays(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function.
|
||||
* @method $this floorDay(float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method $this floorDays(float $precision = 1) Truncate the current instance day with given precision.
|
||||
* @method $this ceilDay(float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method $this ceilDays(float $precision = 1) Ceil the current instance day with given precision.
|
||||
* @method $this roundHour(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
|
||||
* @method $this roundHours(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function.
|
||||
* @method $this floorHour(float $precision = 1) Truncate the current instance hour with given precision.
|
||||
* @method $this floorHours(float $precision = 1) Truncate the current instance hour with given precision.
|
||||
* @method $this ceilHour(float $precision = 1) Ceil the current instance hour with given precision.
|
||||
* @method $this ceilHours(float $precision = 1) Ceil the current instance hour with given precision.
|
||||
* @method $this roundMinute(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
|
||||
* @method $this roundMinutes(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function.
|
||||
* @method $this floorMinute(float $precision = 1) Truncate the current instance minute with given precision.
|
||||
* @method $this floorMinutes(float $precision = 1) Truncate the current instance minute with given precision.
|
||||
* @method $this ceilMinute(float $precision = 1) Ceil the current instance minute with given precision.
|
||||
* @method $this ceilMinutes(float $precision = 1) Ceil the current instance minute with given precision.
|
||||
* @method $this roundSecond(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
|
||||
* @method $this roundSeconds(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function.
|
||||
* @method $this floorSecond(float $precision = 1) Truncate the current instance second with given precision.
|
||||
* @method $this floorSeconds(float $precision = 1) Truncate the current instance second with given precision.
|
||||
* @method $this ceilSecond(float $precision = 1) Ceil the current instance second with given precision.
|
||||
* @method $this ceilSeconds(float $precision = 1) Ceil the current instance second with given precision.
|
||||
* @method $this roundMillennium(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
|
||||
* @method $this roundMillennia(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function.
|
||||
* @method $this floorMillennium(float $precision = 1) Truncate the current instance millennium with given precision.
|
||||
* @method $this floorMillennia(float $precision = 1) Truncate the current instance millennium with given precision.
|
||||
* @method $this ceilMillennium(float $precision = 1) Ceil the current instance millennium with given precision.
|
||||
* @method $this ceilMillennia(float $precision = 1) Ceil the current instance millennium with given precision.
|
||||
* @method $this roundCentury(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
|
||||
* @method $this roundCenturies(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function.
|
||||
* @method $this floorCentury(float $precision = 1) Truncate the current instance century with given precision.
|
||||
* @method $this floorCenturies(float $precision = 1) Truncate the current instance century with given precision.
|
||||
* @method $this ceilCentury(float $precision = 1) Ceil the current instance century with given precision.
|
||||
* @method $this ceilCenturies(float $precision = 1) Ceil the current instance century with given precision.
|
||||
* @method $this roundDecade(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
|
||||
* @method $this roundDecades(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function.
|
||||
* @method $this floorDecade(float $precision = 1) Truncate the current instance decade with given precision.
|
||||
* @method $this floorDecades(float $precision = 1) Truncate the current instance decade with given precision.
|
||||
* @method $this ceilDecade(float $precision = 1) Ceil the current instance decade with given precision.
|
||||
* @method $this ceilDecades(float $precision = 1) Ceil the current instance decade with given precision.
|
||||
* @method $this roundQuarter(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
|
||||
* @method $this roundQuarters(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function.
|
||||
* @method $this floorQuarter(float $precision = 1) Truncate the current instance quarter with given precision.
|
||||
* @method $this floorQuarters(float $precision = 1) Truncate the current instance quarter with given precision.
|
||||
* @method $this ceilQuarter(float $precision = 1) Ceil the current instance quarter with given precision.
|
||||
* @method $this ceilQuarters(float $precision = 1) Ceil the current instance quarter with given precision.
|
||||
* @method $this roundMillisecond(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
|
||||
* @method $this roundMilliseconds(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function.
|
||||
* @method $this floorMillisecond(float $precision = 1) Truncate the current instance millisecond with given precision.
|
||||
* @method $this floorMilliseconds(float $precision = 1) Truncate the current instance millisecond with given precision.
|
||||
* @method $this ceilMillisecond(float $precision = 1) Ceil the current instance millisecond with given precision.
|
||||
* @method $this ceilMilliseconds(float $precision = 1) Ceil the current instance millisecond with given precision.
|
||||
* @method $this roundMicrosecond(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
|
||||
* @method $this roundMicroseconds(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function.
|
||||
* @method $this floorMicrosecond(float $precision = 1) Truncate the current instance microsecond with given precision.
|
||||
* @method $this floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision.
|
||||
* @method $this ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision.
|
||||
* @method $this ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision.
|
||||
*/
|
||||
class CarbonPeriod implements Iterator, Countable, JsonSerializable
|
||||
{
|
||||
use IntervalRounding;
|
||||
use Mixin {
|
||||
Mixin::mixin as baseMixin;
|
||||
}
|
||||
use Options;
|
||||
|
||||
/**
|
||||
* Built-in filters.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const RECURRENCES_FILTER = [self::class, 'filterRecurrences'];
|
||||
public const END_DATE_FILTER = [self::class, 'filterEndDate'];
|
||||
|
||||
/**
|
||||
* Special value which can be returned by filters to end iteration. Also a filter.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const END_ITERATION = [self::class, 'endIteration'];
|
||||
|
||||
/**
|
||||
* Exclude start date from iteration.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public const EXCLUDE_START_DATE = 1;
|
||||
|
||||
/**
|
||||
* Exclude end date from iteration.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public const EXCLUDE_END_DATE = 2;
|
||||
|
||||
/**
|
||||
* Yield CarbonImmutable instances.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public const IMMUTABLE = 4;
|
||||
|
||||
/**
|
||||
* Number of maximum attempts before giving up on finding next valid date.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public const NEXT_MAX_ATTEMPTS = 1000;
|
||||
|
||||
/**
|
||||
* Number of maximum attempts before giving up on finding end date.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public const END_MAX_ATTEMPTS = 10000;
|
||||
|
||||
/**
|
||||
* The registered macros.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $macros = [];
|
||||
|
||||
/**
|
||||
* Date class of iteration items.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateClass = Carbon::class;
|
||||
|
||||
/**
|
||||
* Underlying date interval instance. Always present, one day by default.
|
||||
*
|
||||
* @var CarbonInterval
|
||||
*/
|
||||
protected $dateInterval;
|
||||
|
||||
/**
|
||||
* Whether current date interval was set by default.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isDefaultInterval;
|
||||
|
||||
/**
|
||||
* The filters stack.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $filters = [];
|
||||
|
||||
/**
|
||||
* Period start date. Applied on rewind. Always present, now by default.
|
||||
*
|
||||
* @var CarbonInterface
|
||||
*/
|
||||
protected $startDate;
|
||||
|
||||
/**
|
||||
* Period end date. For inverted interval should be before the start date. Applied via a filter.
|
||||
*
|
||||
* @var CarbonInterface|null
|
||||
*/
|
||||
protected $endDate;
|
||||
|
||||
/**
|
||||
* Limit for number of recurrences. Applied via a filter.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
protected $recurrences;
|
||||
|
||||
/**
|
||||
* Iteration options.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* Index of current date. Always sequential, even if some dates are skipped by filters.
|
||||
* Equal to null only before the first iteration.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $key;
|
||||
|
||||
/**
|
||||
* Current date. May temporarily hold unaccepted value when looking for a next valid date.
|
||||
* Equal to null only before the first iteration.
|
||||
*
|
||||
* @var CarbonInterface
|
||||
*/
|
||||
protected $current;
|
||||
|
||||
/**
|
||||
* Timezone of current date. Taken from the start date.
|
||||
*
|
||||
* @var \DateTimeZone|null
|
||||
*/
|
||||
protected $timezone;
|
||||
|
||||
/**
|
||||
* The cached validation result for current date.
|
||||
*
|
||||
* @var bool|string|null
|
||||
*/
|
||||
protected $validationResult;
|
||||
|
||||
/**
|
||||
* Timezone handler for settings() method.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $tzName;
|
||||
|
||||
/**
|
||||
* Make a CarbonPeriod instance from given variable if possible.
|
||||
*
|
||||
* @param mixed $var
|
||||
*
|
||||
* @return static|null
|
||||
*/
|
||||
public static function make($var)
|
||||
{
|
||||
try {
|
||||
return static::instance($var);
|
||||
} catch (NotAPeriodException $e) {
|
||||
return static::create($var);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance from a DatePeriod or CarbonPeriod object.
|
||||
*
|
||||
* @param CarbonPeriod|DatePeriod $period
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function instance($period)
|
||||
{
|
||||
if ($period instanceof static) {
|
||||
return $period->copy();
|
||||
}
|
||||
|
||||
if ($period instanceof self) {
|
||||
return new static(
|
||||
$period->getStartDate(),
|
||||
$period->getEndDate() ?: $period->getRecurrences(),
|
||||
$period->getDateInterval(),
|
||||
$period->getOptions()
|
||||
);
|
||||
}
|
||||
|
||||
if ($period instanceof DatePeriod) {
|
||||
return new static(
|
||||
$period->start,
|
||||
$period->end ?: ($period->recurrences - 1),
|
||||
$period->interval,
|
||||
$period->include_start_date ? 0 : static::EXCLUDE_START_DATE
|
||||
);
|
||||
}
|
||||
|
||||
$class = \get_called_class();
|
||||
$type = \gettype($period);
|
||||
|
||||
throw new NotAPeriodException(
|
||||
'Argument 1 passed to '.$class.'::'.__METHOD__.'() '.
|
||||
'must be an instance of DatePeriod or '.$class.', '.
|
||||
($type === 'object' ? 'instance of '.\get_class($period) : $type).' given.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create(...$params)
|
||||
{
|
||||
return static::createFromArray($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance from an array of parameters.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function createFromArray(array $params)
|
||||
{
|
||||
return new static(...$params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create CarbonPeriod from ISO 8601 string.
|
||||
*
|
||||
* @param string $iso
|
||||
* @param int|null $options
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function createFromIso($iso, $options = null)
|
||||
{
|
||||
$params = static::parseIso8601($iso);
|
||||
|
||||
$instance = static::createFromArray($params);
|
||||
|
||||
if ($options !== null) {
|
||||
$instance->setOptions($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether given interval contains non zero value of any time unit.
|
||||
*
|
||||
* @param \DateInterval $interval
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function intervalHasTime(DateInterval $interval)
|
||||
{
|
||||
return $interval->h || $interval->i || $interval->s || $interval->f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether given variable is an ISO 8601 specification.
|
||||
*
|
||||
* Note: Check is very basic, as actual validation will be done later when parsing.
|
||||
* We just want to ensure that variable is not any other type of a valid parameter.
|
||||
*
|
||||
* @param mixed $var
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function isIso8601($var)
|
||||
{
|
||||
if (!\is_string($var)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Match slash but not within a timezone name.
|
||||
$part = '[a-z]+(?:[_-][a-z]+)*';
|
||||
|
||||
preg_match("#\b$part/$part\b|(/)#i", $var, $match);
|
||||
|
||||
return isset($match[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse given ISO 8601 string into an array of arguments.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ElseExpression)
|
||||
*
|
||||
* @param string $iso
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function parseIso8601($iso)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$interval = null;
|
||||
$start = null;
|
||||
$end = null;
|
||||
|
||||
foreach (explode('/', $iso) as $key => $part) {
|
||||
if ($key === 0 && preg_match('/^R([0-9]*)$/', $part, $match)) {
|
||||
$parsed = \strlen($match[1]) ? (int) $match[1] : null;
|
||||
} elseif ($interval === null && $parsed = CarbonInterval::make($part)) {
|
||||
$interval = $part;
|
||||
} elseif ($start === null && $parsed = Carbon::make($part)) {
|
||||
$start = $part;
|
||||
} elseif ($end === null && $parsed = Carbon::make(static::addMissingParts($start ?? '', $part))) {
|
||||
$end = $part;
|
||||
} else {
|
||||
throw new InvalidPeriodParameterException("Invalid ISO 8601 specification: $iso.");
|
||||
}
|
||||
|
||||
$result[] = $parsed;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add missing parts of the target date from the soure date.
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $target
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function addMissingParts($source, $target)
|
||||
{
|
||||
$pattern = '/'.preg_replace('/[0-9]+/', '[0-9]+', preg_quote($target, '/')).'$/';
|
||||
|
||||
$result = preg_replace($pattern, $target, $source, 1, $count);
|
||||
|
||||
return $count ? $result : $target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom macro.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* CarbonPeriod::macro('middle', function () {
|
||||
* return $this->getStartDate()->average($this->getEndDate());
|
||||
* });
|
||||
* echo CarbonPeriod::since('2011-05-12')->until('2011-06-03')->middle();
|
||||
* ```
|
||||
*
|
||||
* @param string $name
|
||||
* @param object|callable $macro
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function macro($name, $macro)
|
||||
{
|
||||
static::$macros[$name] = $macro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register macros from a mixin object.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* CarbonPeriod::mixin(new class {
|
||||
* public function addDays() {
|
||||
* return function ($count = 1) {
|
||||
* return $this->setStartDate(
|
||||
* $this->getStartDate()->addDays($count)
|
||||
* )->setEndDate(
|
||||
* $this->getEndDate()->addDays($count)
|
||||
* );
|
||||
* };
|
||||
* }
|
||||
* public function subDays() {
|
||||
* return function ($count = 1) {
|
||||
* return $this->setStartDate(
|
||||
* $this->getStartDate()->subDays($count)
|
||||
* )->setEndDate(
|
||||
* $this->getEndDate()->subDays($count)
|
||||
* );
|
||||
* };
|
||||
* }
|
||||
* });
|
||||
* echo CarbonPeriod::create('2000-01-01', '2000-02-01')->addDays(5)->subDays(3);
|
||||
* ```
|
||||
*
|
||||
* @param object|string $mixin
|
||||
*
|
||||
* @throws ReflectionException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function mixin($mixin)
|
||||
{
|
||||
static::baseMixin($mixin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if macro is registered.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasMacro($name)
|
||||
{
|
||||
return isset(static::$macros[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide static proxy for instance aliases.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic($method, $parameters)
|
||||
{
|
||||
$date = new static();
|
||||
|
||||
if (static::hasMacro($method)) {
|
||||
return static::bindMacroContext(null, function () use (&$method, &$parameters, &$date) {
|
||||
return $date->callMacro($method, $parameters);
|
||||
});
|
||||
}
|
||||
|
||||
return $date->$method(...$parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* CarbonPeriod constructor.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ElseExpression)
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(...$arguments)
|
||||
{
|
||||
// Parse and assign arguments one by one. First argument may be an ISO 8601 spec,
|
||||
// which will be first parsed into parts and then processed the same way.
|
||||
|
||||
$argumentsCount = \count($arguments);
|
||||
|
||||
if ($argumentsCount && static::isIso8601($iso = $arguments[0])) {
|
||||
array_splice($arguments, 0, 1, static::parseIso8601($iso));
|
||||
}
|
||||
|
||||
if ($argumentsCount === 1) {
|
||||
if ($arguments[0] instanceof DatePeriod) {
|
||||
$arguments = [
|
||||
$arguments[0]->start,
|
||||
$arguments[0]->end ?: ($arguments[0]->recurrences - 1),
|
||||
$arguments[0]->interval,
|
||||
$arguments[0]->include_start_date ? 0 : static::EXCLUDE_START_DATE,
|
||||
];
|
||||
} elseif ($arguments[0] instanceof self) {
|
||||
$arguments = [
|
||||
$arguments[0]->getStartDate(),
|
||||
$arguments[0]->getEndDate() ?: $arguments[0]->getRecurrences(),
|
||||
$arguments[0]->getDateInterval(),
|
||||
$arguments[0]->getOptions(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($arguments as $argument) {
|
||||
$parsedDate = null;
|
||||
|
||||
if ($argument instanceof DateTimeZone) {
|
||||
$this->setTimezone($argument);
|
||||
} elseif ($this->dateInterval === null &&
|
||||
(
|
||||
\is_string($argument) && preg_match(
|
||||
'/^(-?\d(\d(?![\/-])|[^\d\/-]([\/-])?)*|P[T0-9].*|(?:\h*\d+(?:\.\d+)?\h*[a-z]+)+)$/i',
|
||||
$argument
|
||||
) ||
|
||||
$argument instanceof DateInterval ||
|
||||
$argument instanceof Closure
|
||||
) &&
|
||||
$parsedInterval = @CarbonInterval::make($argument)
|
||||
) {
|
||||
$this->setDateInterval($parsedInterval);
|
||||
} elseif ($this->startDate === null && $parsedDate = $this->makeDateTime($argument)) {
|
||||
$this->setStartDate($parsedDate);
|
||||
} elseif ($this->endDate === null && ($parsedDate = $parsedDate ?? $this->makeDateTime($argument))) {
|
||||
$this->setEndDate($parsedDate);
|
||||
} elseif ($this->recurrences === null && $this->endDate === null && is_numeric($argument)) {
|
||||
$this->setRecurrences($argument);
|
||||
} elseif ($this->options === null && (\is_int($argument) || $argument === null)) {
|
||||
$this->setOptions($argument);
|
||||
} else {
|
||||
throw new InvalidPeriodParameterException('Invalid constructor parameters.');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->startDate === null) {
|
||||
$this->setStartDate(Carbon::now());
|
||||
}
|
||||
|
||||
if ($this->dateInterval === null) {
|
||||
$this->setDateInterval(CarbonInterval::day());
|
||||
|
||||
$this->isDefaultInterval = true;
|
||||
}
|
||||
|
||||
if ($this->options === null) {
|
||||
$this->setOptions(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of the instance.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function copy()
|
||||
{
|
||||
return clone $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the getter for a property allowing both `DatePeriod` snakeCase and camelCase names.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return callable|null
|
||||
*/
|
||||
protected function getGetter(string $name)
|
||||
{
|
||||
switch (strtolower(preg_replace('/[A-Z]/', '_$0', $name))) {
|
||||
case 'start':
|
||||
case 'start_date':
|
||||
return [$this, 'getStartDate'];
|
||||
case 'end':
|
||||
case 'end_date':
|
||||
return [$this, 'getEndDate'];
|
||||
case 'interval':
|
||||
case 'date_interval':
|
||||
return [$this, 'getDateInterval'];
|
||||
case 'recurrences':
|
||||
return [$this, 'getRecurrences'];
|
||||
case 'include_start_date':
|
||||
return [$this, 'isStartIncluded'];
|
||||
case 'include_end_date':
|
||||
return [$this, 'isEndIncluded'];
|
||||
case 'current':
|
||||
return [$this, 'current'];
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a property allowing both `DatePeriod` snakeCase and camelCase names.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool|CarbonInterface|CarbonInterval|int|null
|
||||
*/
|
||||
public function get(string $name)
|
||||
{
|
||||
$getter = $this->getGetter($name);
|
||||
|
||||
if ($getter) {
|
||||
return $getter();
|
||||
}
|
||||
|
||||
throw new UnknownGetterException($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a property allowing both `DatePeriod` snakeCase and camelCase names.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool|CarbonInterface|CarbonInterval|int|null
|
||||
*/
|
||||
public function __get(string $name)
|
||||
{
|
||||
return $this->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an attribute exists on the object
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset(string $name): bool
|
||||
{
|
||||
return $this->getGetter($name) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @alias copy
|
||||
*
|
||||
* Get a copy of the instance.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function clone()
|
||||
{
|
||||
return clone $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the iteration item class.
|
||||
*
|
||||
* @param string $dateClass
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDateClass(string $dateClass)
|
||||
{
|
||||
if (!is_a($dateClass, CarbonInterface::class, true)) {
|
||||
throw new NotACarbonClassException($dateClass);
|
||||
}
|
||||
|
||||
$this->dateClass = $dateClass;
|
||||
|
||||
if (is_a($dateClass, Carbon::class, true)) {
|
||||
$this->toggleOptions(static::IMMUTABLE, false);
|
||||
} elseif (is_a($dateClass, CarbonImmutable::class, true)) {
|
||||
$this->toggleOptions(static::IMMUTABLE, true);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns iteration item date class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateClass(): string
|
||||
{
|
||||
return $this->dateClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the period date interval.
|
||||
*
|
||||
* @param DateInterval|string $interval
|
||||
*
|
||||
* @throws InvalidIntervalException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDateInterval($interval)
|
||||
{
|
||||
if (!$interval = CarbonInterval::make($interval)) {
|
||||
throw new InvalidIntervalException('Invalid interval.');
|
||||
}
|
||||
|
||||
if ($interval->spec() === 'PT0S' && !$interval->f && !$interval->getStep()) {
|
||||
throw new InvalidIntervalException('Empty interval is not accepted.');
|
||||
}
|
||||
|
||||
$this->dateInterval = $interval;
|
||||
|
||||
$this->isDefaultInterval = false;
|
||||
|
||||
$this->handleChangedParameters();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert the period date interval.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function invertDateInterval()
|
||||
{
|
||||
$interval = $this->dateInterval->invert();
|
||||
|
||||
return $this->setDateInterval($interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set start and end date.
|
||||
*
|
||||
* @param DateTime|DateTimeInterface|string $start
|
||||
* @param DateTime|DateTimeInterface|string|null $end
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDates($start, $end)
|
||||
{
|
||||
$this->setStartDate($start);
|
||||
$this->setEndDate($end);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the period options.
|
||||
*
|
||||
* @param int|null $options
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setOptions($options)
|
||||
{
|
||||
if (!\is_int($options) && $options !== null) {
|
||||
throw new InvalidPeriodParameterException('Invalid options.');
|
||||
}
|
||||
|
||||
$this->options = $options ?: 0;
|
||||
|
||||
$this->handleChangedParameters();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the period options.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle given options on or off.
|
||||
*
|
||||
* @param int $options
|
||||
* @param bool|null $state
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function toggleOptions($options, $state = null)
|
||||
{
|
||||
if ($state === null) {
|
||||
$state = ($this->options & $options) !== $options;
|
||||
}
|
||||
|
||||
return $this->setOptions(
|
||||
$state ?
|
||||
$this->options | $options :
|
||||
$this->options & ~$options
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle EXCLUDE_START_DATE option.
|
||||
*
|
||||
* @param bool $state
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function excludeStartDate($state = true)
|
||||
{
|
||||
return $this->toggleOptions(static::EXCLUDE_START_DATE, $state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle EXCLUDE_END_DATE option.
|
||||
*
|
||||
* @param bool $state
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function excludeEndDate($state = true)
|
||||
{
|
||||
return $this->toggleOptions(static::EXCLUDE_END_DATE, $state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying date interval.
|
||||
*
|
||||
* @return CarbonInterval
|
||||
*/
|
||||
public function getDateInterval()
|
||||
{
|
||||
return $this->dateInterval->copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get start date of the period.
|
||||
*
|
||||
* @param string|null $rounding Optional rounding 'floor', 'ceil', 'round' using the period interval.
|
||||
*
|
||||
* @return CarbonInterface
|
||||
*/
|
||||
public function getStartDate(string $rounding = null)
|
||||
{
|
||||
$date = $this->startDate->avoidMutation();
|
||||
|
||||
return $rounding ? $date->round($this->getDateInterval(), $rounding) : $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get end date of the period.
|
||||
*
|
||||
* @param string|null $rounding Optional rounding 'floor', 'ceil', 'round' using the period interval.
|
||||
*
|
||||
* @return CarbonInterface|null
|
||||
*/
|
||||
public function getEndDate(string $rounding = null)
|
||||
{
|
||||
if (!$this->endDate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$date = $this->endDate->avoidMutation();
|
||||
|
||||
return $rounding ? $date->round($this->getDateInterval(), $rounding) : $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of recurrences.
|
||||
*
|
||||
* @return int|float|null
|
||||
*/
|
||||
public function getRecurrences()
|
||||
{
|
||||
return $this->recurrences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the start date should be excluded.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isStartExcluded()
|
||||
{
|
||||
return ($this->options & static::EXCLUDE_START_DATE) !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the end date should be excluded.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEndExcluded()
|
||||
{
|
||||
return ($this->options & static::EXCLUDE_END_DATE) !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the start date should be included.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isStartIncluded()
|
||||
{
|
||||
return !$this->isStartExcluded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the end date should be included.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEndIncluded()
|
||||
{
|
||||
return !$this->isEndExcluded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the start if it's included by option, else return the start + 1 period interval.
|
||||
*
|
||||
* @return CarbonInterface
|
||||
*/
|
||||
public function getIncludedStartDate()
|
||||
{
|
||||
$start = $this->getStartDate();
|
||||
|
||||
if ($this->isStartExcluded()) {
|
||||
return $start->add($this->getDateInterval());
|
||||
}
|
||||
|
||||
return $start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the end if it's included by option, else return the end - 1 period interval.
|
||||
* Warning: if the period has no fixed end, this method will iterate the period to calculate it.
|
||||
*
|
||||
* @return CarbonInterface
|
||||
*/
|
||||
public function getIncludedEndDate()
|
||||
{
|
||||
$end = $this->getEndDate();
|
||||
|
||||
if (!$end) {
|
||||
return $this->calculateEnd();
|
||||
}
|
||||
|
||||
if ($this->isEndExcluded()) {
|
||||
return $end->sub($this->getDateInterval());
|
||||
}
|
||||
|
||||
return $end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a filter to the stack.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addFilter($callback, $name = null)
|
||||
{
|
||||
$tuple = $this->createFilterTuple(\func_get_args());
|
||||
|
||||
$this->filters[] = $tuple;
|
||||
|
||||
$this->handleChangedParameters();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend a filter to the stack.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function prependFilter($callback, $name = null)
|
||||
{
|
||||
$tuple = $this->createFilterTuple(\func_get_args());
|
||||
|
||||
array_unshift($this->filters, $tuple);
|
||||
|
||||
$this->handleChangedParameters();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a filter by instance or name.
|
||||
*
|
||||
* @param callable|string $filter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function removeFilter($filter)
|
||||
{
|
||||
$key = \is_callable($filter) ? 0 : 1;
|
||||
|
||||
$this->filters = array_values(array_filter(
|
||||
$this->filters,
|
||||
function ($tuple) use ($key, $filter) {
|
||||
return $tuple[$key] !== $filter;
|
||||
}
|
||||
));
|
||||
|
||||
$this->updateInternalState();
|
||||
|
||||
$this->handleChangedParameters();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether given instance or name is in the filter stack.
|
||||
*
|
||||
* @param callable|string $filter
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFilter($filter)
|
||||
{
|
||||
$key = \is_callable($filter) ? 0 : 1;
|
||||
|
||||
foreach ($this->filters as $tuple) {
|
||||
if ($tuple[$key] === $filter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filters stack.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return $this->filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set filters stack.
|
||||
*
|
||||
* @param array $filters
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilters(array $filters)
|
||||
{
|
||||
$this->filters = $filters;
|
||||
|
||||
$this->updateInternalState();
|
||||
|
||||
$this->handleChangedParameters();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset filters stack.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function resetFilters()
|
||||
{
|
||||
$this->filters = [];
|
||||
|
||||
if ($this->endDate !== null) {
|
||||
$this->filters[] = [static::END_DATE_FILTER, null];
|
||||
}
|
||||
|
||||
if ($this->recurrences !== null) {
|
||||
$this->filters[] = [static::RECURRENCES_FILTER, null];
|
||||
}
|
||||
|
||||
$this->handleChangedParameters();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a recurrences filter (set maximum number of recurrences).
|
||||
*
|
||||
* @param int|float|null $recurrences
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRecurrences($recurrences)
|
||||
{
|
||||
if (!is_numeric($recurrences) && $recurrences !== null || $recurrences < 0) {
|
||||
throw new InvalidPeriodParameterException('Invalid number of recurrences.');
|
||||
}
|
||||
|
||||
if ($recurrences === null) {
|
||||
return $this->removeFilter(static::RECURRENCES_FILTER);
|
||||
}
|
||||
|
||||
$this->recurrences = $recurrences === INF ? INF : (int) $recurrences;
|
||||
|
||||
if (!$this->hasFilter(static::RECURRENCES_FILTER)) {
|
||||
return $this->addFilter(static::RECURRENCES_FILTER);
|
||||
}
|
||||
|
||||
$this->handleChangedParameters();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the period start date.
|
||||
*
|
||||
* @param DateTime|DateTimeInterface|string $date
|
||||
* @param bool|null $inclusive
|
||||
*
|
||||
* @throws InvalidPeriodDateException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStartDate($date, $inclusive = null)
|
||||
{
|
||||
if (!$date = ([$this->dateClass, 'make'])($date)) {
|
||||
throw new InvalidPeriodDateException('Invalid start date.');
|
||||
}
|
||||
|
||||
$this->startDate = $date;
|
||||
|
||||
if ($inclusive !== null) {
|
||||
$this->toggleOptions(static::EXCLUDE_START_DATE, !$inclusive);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the period end date.
|
||||
*
|
||||
* @param DateTime|DateTimeInterface|string|null $date
|
||||
* @param bool|null $inclusive
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEndDate($date, $inclusive = null)
|
||||
{
|
||||
if ($date !== null && !$date = ([$this->dateClass, 'make'])($date)) {
|
||||
throw new InvalidPeriodDateException('Invalid end date.');
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
return $this->removeFilter(static::END_DATE_FILTER);
|
||||
}
|
||||
|
||||
$this->endDate = $date;
|
||||
|
||||
if ($inclusive !== null) {
|
||||
$this->toggleOptions(static::EXCLUDE_END_DATE, !$inclusive);
|
||||
}
|
||||
|
||||
if (!$this->hasFilter(static::END_DATE_FILTER)) {
|
||||
return $this->addFilter(static::END_DATE_FILTER);
|
||||
}
|
||||
|
||||
$this->handleChangedParameters();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current position is valid.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function valid()
|
||||
{
|
||||
return $this->validateCurrentDate() === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current key.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
return $this->valid()
|
||||
? $this->key
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current date.
|
||||
*
|
||||
* @return CarbonInterface|null
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return $this->valid()
|
||||
? $this->prepareForReturn($this->current)
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move forward to the next date.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
if ($this->current === null) {
|
||||
$this->rewind();
|
||||
}
|
||||
|
||||
if ($this->validationResult !== static::END_ITERATION) {
|
||||
$this->key++;
|
||||
|
||||
$this->incrementCurrentDateUntilValid();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind to the start date.
|
||||
*
|
||||
* Iterating over a date in the UTC timezone avoids bug during backward DST change.
|
||||
*
|
||||
* @see https://bugs.php.net/bug.php?id=72255
|
||||
* @see https://bugs.php.net/bug.php?id=74274
|
||||
* @see https://wiki.php.net/rfc/datetime_and_daylight_saving_time
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
$this->key = 0;
|
||||
$this->current = ([$this->dateClass, 'make'])($this->startDate);
|
||||
$settings = $this->getSettings();
|
||||
|
||||
if ($this->hasLocalTranslator()) {
|
||||
$settings['locale'] = $this->getTranslatorLocale();
|
||||
}
|
||||
|
||||
$this->current->settings($settings);
|
||||
$this->timezone = static::intervalHasTime($this->dateInterval) ? $this->current->getTimezone() : null;
|
||||
|
||||
if ($this->timezone) {
|
||||
$this->current = $this->current->utc();
|
||||
}
|
||||
|
||||
$this->validationResult = null;
|
||||
|
||||
if ($this->isStartExcluded() || $this->validateCurrentDate() === false) {
|
||||
$this->incrementCurrentDateUntilValid();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip iterations and returns iteration state (false if ended, true if still valid).
|
||||
*
|
||||
* @param int $count steps number to skip (1 by default)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function skip($count = 1)
|
||||
{
|
||||
for ($i = $count; $this->valid() && $i > 0; $i--) {
|
||||
$this->next();
|
||||
}
|
||||
|
||||
return $this->valid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the date period as ISO 8601.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toIso8601String()
|
||||
{
|
||||
$parts = [];
|
||||
|
||||
if ($this->recurrences !== null) {
|
||||
$parts[] = 'R'.$this->recurrences;
|
||||
}
|
||||
|
||||
$parts[] = $this->startDate->toIso8601String();
|
||||
|
||||
$parts[] = $this->dateInterval->spec();
|
||||
|
||||
if ($this->endDate !== null) {
|
||||
$parts[] = $this->endDate->toIso8601String();
|
||||
}
|
||||
|
||||
return implode('/', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the date period into a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
$translator = ([$this->dateClass, 'getTranslator'])();
|
||||
|
||||
$parts = [];
|
||||
|
||||
$format = !$this->startDate->isStartOfDay() || $this->endDate && !$this->endDate->isStartOfDay()
|
||||
? 'Y-m-d H:i:s'
|
||||
: 'Y-m-d';
|
||||
|
||||
if ($this->recurrences !== null) {
|
||||
$parts[] = $this->translate('period_recurrences', [], $this->recurrences, $translator);
|
||||
}
|
||||
|
||||
$parts[] = $this->translate('period_interval', [':interval' => $this->dateInterval->forHumans([
|
||||
'join' => true,
|
||||
])], null, $translator);
|
||||
|
||||
$parts[] = $this->translate('period_start_date', [':date' => $this->startDate->rawFormat($format)], null, $translator);
|
||||
|
||||
if ($this->endDate !== null) {
|
||||
$parts[] = $this->translate('period_end_date', [':date' => $this->endDate->rawFormat($format)], null, $translator);
|
||||
}
|
||||
|
||||
$result = implode(' ', $parts);
|
||||
|
||||
return mb_strtoupper(mb_substr($result, 0, 1)).mb_substr($result, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the date period as ISO 8601.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function spec()
|
||||
{
|
||||
return $this->toIso8601String();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast the current instance into the given class.
|
||||
*
|
||||
* @param string $className The $className::instance() method will be called to cast the current object.
|
||||
*
|
||||
* @return DatePeriod
|
||||
*/
|
||||
public function cast(string $className)
|
||||
{
|
||||
if (!method_exists($className, 'instance')) {
|
||||
if (is_a($className, DatePeriod::class, true)) {
|
||||
return new $className(
|
||||
$this->getStartDate(),
|
||||
$this->getDateInterval(),
|
||||
$this->getEndDate() ? $this->getIncludedEndDate() : $this->getRecurrences(),
|
||||
$this->isStartExcluded() ? DatePeriod::EXCLUDE_START_DATE : 0
|
||||
);
|
||||
}
|
||||
|
||||
throw new InvalidCastException("$className has not the instance() method needed to cast the date.");
|
||||
}
|
||||
|
||||
return $className::instance($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return native DatePeriod PHP object matching the current instance.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* var_dump(CarbonPeriod::create('2021-01-05', '2021-02-15')->toDatePeriod());
|
||||
* ```
|
||||
*
|
||||
* @return DatePeriod
|
||||
*/
|
||||
public function toDatePeriod()
|
||||
{
|
||||
return $this->cast(DatePeriod::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the date period into an array without changing current iteration state.
|
||||
*
|
||||
* @return CarbonInterface[]
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$state = [
|
||||
$this->key,
|
||||
$this->current ? $this->current->avoidMutation() : null,
|
||||
$this->validationResult,
|
||||
];
|
||||
|
||||
$result = iterator_to_array($this);
|
||||
|
||||
[$this->key, $this->current, $this->validationResult] = $state;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count dates in the date period.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return \count($this->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the first date in the date period.
|
||||
*
|
||||
* @return CarbonInterface|null
|
||||
*/
|
||||
public function first()
|
||||
{
|
||||
return ($this->toArray() ?: [])[0] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last date in the date period.
|
||||
*
|
||||
* @return CarbonInterface|null
|
||||
*/
|
||||
public function last()
|
||||
{
|
||||
$array = $this->toArray();
|
||||
|
||||
return $array ? $array[\count($array) - 1] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the date period into a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add aliases for setters.
|
||||
*
|
||||
* CarbonPeriod::days(3)->hours(5)->invert()
|
||||
* ->sinceNow()->until('2010-01-10')
|
||||
* ->filter(...)
|
||||
* ->count()
|
||||
*
|
||||
* Note: We use magic method to let static and instance aliases with the same names.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
if (static::hasMacro($method)) {
|
||||
return static::bindMacroContext($this, function () use (&$method, &$parameters) {
|
||||
return $this->callMacro($method, $parameters);
|
||||
});
|
||||
}
|
||||
|
||||
$roundedValue = $this->callRoundMethod($method, $parameters);
|
||||
|
||||
if ($roundedValue !== null) {
|
||||
return $roundedValue;
|
||||
}
|
||||
|
||||
$first = \count($parameters) >= 1 ? $parameters[0] : null;
|
||||
$second = \count($parameters) >= 2 ? $parameters[1] : null;
|
||||
|
||||
switch ($method) {
|
||||
case 'start':
|
||||
case 'since':
|
||||
return $this->setStartDate($first, $second);
|
||||
|
||||
case 'sinceNow':
|
||||
return $this->setStartDate(new Carbon, $first);
|
||||
|
||||
case 'end':
|
||||
case 'until':
|
||||
return $this->setEndDate($first, $second);
|
||||
|
||||
case 'untilNow':
|
||||
return $this->setEndDate(new Carbon, $first);
|
||||
|
||||
case 'dates':
|
||||
case 'between':
|
||||
return $this->setDates($first, $second);
|
||||
|
||||
case 'recurrences':
|
||||
case 'times':
|
||||
return $this->setRecurrences($first);
|
||||
|
||||
case 'options':
|
||||
return $this->setOptions($first);
|
||||
|
||||
case 'toggle':
|
||||
return $this->toggleOptions($first, $second);
|
||||
|
||||
case 'filter':
|
||||
case 'push':
|
||||
return $this->addFilter($first, $second);
|
||||
|
||||
case 'prepend':
|
||||
return $this->prependFilter($first, $second);
|
||||
|
||||
case 'filters':
|
||||
return $this->setFilters($first ?: []);
|
||||
|
||||
case 'interval':
|
||||
case 'each':
|
||||
case 'every':
|
||||
case 'step':
|
||||
case 'stepBy':
|
||||
return $this->setDateInterval($first);
|
||||
|
||||
case 'invert':
|
||||
return $this->invertDateInterval();
|
||||
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'months':
|
||||
case 'month':
|
||||
case 'weeks':
|
||||
case 'week':
|
||||
case 'days':
|
||||
case 'dayz':
|
||||
case 'day':
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
return $this->setDateInterval((
|
||||
// Override default P1D when instantiating via fluent setters.
|
||||
[$this->isDefaultInterval ? new CarbonInterval('PT0S') : $this->dateInterval, $method]
|
||||
)(
|
||||
\count($parameters) === 0 ? 1 : $first
|
||||
));
|
||||
}
|
||||
|
||||
if ($this->localStrictModeEnabled ?? Carbon::isStrictModeEnabled()) {
|
||||
throw new UnknownMethodException($method);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance's timezone from a string or object and apply it to start/end.
|
||||
*
|
||||
* @param \DateTimeZone|string $timezone
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setTimezone($timezone)
|
||||
{
|
||||
$this->tzName = $timezone;
|
||||
$this->timezone = $timezone;
|
||||
|
||||
if ($this->startDate) {
|
||||
$this->setStartDate($this->startDate->setTimezone($timezone));
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$this->setEndDate($this->endDate->setTimezone($timezone));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance's timezone from a string or object and add/subtract the offset difference to start/end.
|
||||
*
|
||||
* @param \DateTimeZone|string $timezone
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function shiftTimezone($timezone)
|
||||
{
|
||||
$this->tzName = $timezone;
|
||||
$this->timezone = $timezone;
|
||||
|
||||
if ($this->startDate) {
|
||||
$this->setStartDate($this->startDate->shiftTimezone($timezone));
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$this->setEndDate($this->endDate->shiftTimezone($timezone));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the end is set, else calculated from start an recurrences.
|
||||
*
|
||||
* @param string|null $rounding Optional rounding 'floor', 'ceil', 'round' using the period interval.
|
||||
*
|
||||
* @return CarbonInterface
|
||||
*/
|
||||
public function calculateEnd(string $rounding = null)
|
||||
{
|
||||
if ($end = $this->getEndDate($rounding)) {
|
||||
return $end;
|
||||
}
|
||||
|
||||
if ($this->dateInterval->isEmpty()) {
|
||||
return $this->getStartDate($rounding);
|
||||
}
|
||||
|
||||
$date = $this->getEndFromRecurrences() ?? $this->iterateUntilEnd();
|
||||
|
||||
if ($date && $rounding) {
|
||||
$date = $date->avoidMutation()->round($this->getDateInterval(), $rounding);
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CarbonInterface|null
|
||||
*/
|
||||
private function getEndFromRecurrences()
|
||||
{
|
||||
if ($this->recurrences === null) {
|
||||
throw new UnreachableException(
|
||||
"Could not calculate period end without either explicit end or recurrences.\n".
|
||||
"If you're looking for a forever-period, use ->setRecurrences(INF)."
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->recurrences === INF) {
|
||||
$start = $this->getStartDate();
|
||||
|
||||
return $start < $start->avoidMutation()->add($this->getDateInterval())
|
||||
? CarbonImmutable::endOfTime()
|
||||
: CarbonImmutable::startOfTime();
|
||||
}
|
||||
|
||||
if ($this->filters === [[static::RECURRENCES_FILTER, null]]) {
|
||||
return $this->getStartDate()->avoidMutation()->add(
|
||||
$this->getDateInterval()->times(
|
||||
$this->recurrences - ($this->isStartExcluded() ? 0 : 1)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CarbonInterface|null
|
||||
*/
|
||||
private function iterateUntilEnd()
|
||||
{
|
||||
$attempts = 0;
|
||||
$date = null;
|
||||
|
||||
foreach ($this as $date) {
|
||||
if (++$attempts > static::END_MAX_ATTEMPTS) {
|
||||
throw new UnreachableException(
|
||||
'Could not calculate period end after iterating '.static::END_MAX_ATTEMPTS.' times.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current period overlaps the given one (if 1 parameter passed)
|
||||
* or the period between 2 dates (if 2 parameters passed).
|
||||
*
|
||||
* @param CarbonPeriod|\DateTimeInterface|Carbon|CarbonImmutable|string $rangeOrRangeStart
|
||||
* @param \DateTimeInterface|Carbon|CarbonImmutable|string|null $rangeEnd
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function overlaps($rangeOrRangeStart, $rangeEnd = null)
|
||||
{
|
||||
$range = $rangeEnd ? static::create($rangeOrRangeStart, $rangeEnd) : $rangeOrRangeStart;
|
||||
|
||||
if (!($range instanceof self)) {
|
||||
$range = static::create($range);
|
||||
}
|
||||
|
||||
[$start, $end] = $this->orderCouple($this->getStartDate(), $this->calculateEnd());
|
||||
[$rangeStart, $rangeEnd] = $this->orderCouple($range->getStartDate(), $range->calculateEnd());
|
||||
|
||||
return $end > $rangeStart && $rangeEnd > $start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a given function on each date of the period.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* Carbon::create('2020-11-29')->daysUntil('2020-12-24')->forEach(function (Carbon $date) {
|
||||
* echo $date->diffInDays('2020-12-25')." days before Christmas!\n";
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param callable $callback
|
||||
*/
|
||||
public function forEach(callable $callback)
|
||||
{
|
||||
foreach ($this as $date) {
|
||||
$callback($date);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a given function on each date of the period and yield the result of this function.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* $period = Carbon::create('2020-11-29')->daysUntil('2020-12-24');
|
||||
* echo implode("\n", iterator_to_array($period->map(function (Carbon $date) {
|
||||
* return $date->diffInDays('2020-12-25').' days before Christmas!';
|
||||
* })));
|
||||
* ```
|
||||
*
|
||||
* @param callable $callback
|
||||
*
|
||||
* @return \Generator
|
||||
*/
|
||||
public function map(callable $callback)
|
||||
{
|
||||
foreach ($this as $date) {
|
||||
yield $callback($date);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is equal to another.
|
||||
* Warning: if options differ, instances wil never be equal.
|
||||
*
|
||||
* @param mixed $period
|
||||
*
|
||||
* @see equalTo()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function eq($period): bool
|
||||
{
|
||||
return $this->equalTo($period);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is equal to another.
|
||||
* Warning: if options differ, instances wil never be equal.
|
||||
*
|
||||
* @param mixed $period
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function equalTo($period): bool
|
||||
{
|
||||
if (!($period instanceof self)) {
|
||||
$period = self::make($period);
|
||||
}
|
||||
|
||||
$end = $this->getEndDate();
|
||||
|
||||
return $period !== null
|
||||
&& $this->getDateInterval()->eq($period->getDateInterval())
|
||||
&& $this->getStartDate()->eq($period->getStartDate())
|
||||
&& ($end ? $end->eq($period->getEndDate()) : $this->getRecurrences() === $period->getRecurrences())
|
||||
&& ($this->getOptions() & (~static::IMMUTABLE)) === ($period->getOptions() & (~static::IMMUTABLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is not equal to another.
|
||||
* Warning: if options differ, instances wil never be equal.
|
||||
*
|
||||
* @param mixed $period
|
||||
*
|
||||
* @see notEqualTo()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ne($period): bool
|
||||
{
|
||||
return $this->notEqualTo($period);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the instance is not equal to another.
|
||||
* Warning: if options differ, instances wil never be equal.
|
||||
*
|
||||
* @param mixed $period
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function notEqualTo($period): bool
|
||||
{
|
||||
return !$this->eq($period);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the start date is before an other given date.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @param mixed $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function startsBefore($date = null): bool
|
||||
{
|
||||
return $this->getStartDate()->lessThan($this->resolveCarbon($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the start date is before or the same as a given date.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @param mixed $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function startsBeforeOrAt($date = null): bool
|
||||
{
|
||||
return $this->getStartDate()->lessThanOrEqualTo($this->resolveCarbon($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the start date is after an other given date.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @param mixed $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function startsAfter($date = null): bool
|
||||
{
|
||||
return $this->getStartDate()->greaterThan($this->resolveCarbon($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the start date is after or the same as a given date.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @param mixed $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function startsAfterOrAt($date = null): bool
|
||||
{
|
||||
return $this->getStartDate()->greaterThanOrEqualTo($this->resolveCarbon($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the start date is the same as a given date.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @param mixed $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function startsAt($date = null): bool
|
||||
{
|
||||
return $this->getStartDate()->equalTo($this->resolveCarbon($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the end date is before an other given date.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @param mixed $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function endsBefore($date = null): bool
|
||||
{
|
||||
return $this->calculateEnd()->lessThan($this->resolveCarbon($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the end date is before or the same as a given date.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @param mixed $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function endsBeforeOrAt($date = null): bool
|
||||
{
|
||||
return $this->calculateEnd()->lessThanOrEqualTo($this->resolveCarbon($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the end date is after an other given date.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @param mixed $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function endsAfter($date = null): bool
|
||||
{
|
||||
return $this->calculateEnd()->greaterThan($this->resolveCarbon($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the end date is after or the same as a given date.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @param mixed $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function endsAfterOrAt($date = null): bool
|
||||
{
|
||||
return $this->calculateEnd()->greaterThanOrEqualTo($this->resolveCarbon($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the end date is the same as a given date.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @param mixed $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function endsAt($date = null): bool
|
||||
{
|
||||
return $this->calculateEnd()->equalTo($this->resolveCarbon($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if start date is now or later.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isStarted(): bool
|
||||
{
|
||||
return $this->startsBeforeOrAt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if end date is now or later.
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnded(): bool
|
||||
{
|
||||
return $this->endsBeforeOrAt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if now is between start date (included) and end date (excluded).
|
||||
* (Rather start/end are included by options is ignored.)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInProgress(): bool
|
||||
{
|
||||
return $this->isStarted() && !$this->isEnded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Round the current instance at the given unit with given precision if specified and the given function.
|
||||
*
|
||||
* @param string $unit
|
||||
* @param float|int|string|\DateInterval|null $precision
|
||||
* @param string $function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function roundUnit($unit, $precision = 1, $function = 'round')
|
||||
{
|
||||
$this->setStartDate($this->getStartDate()->roundUnit($unit, $precision, $function));
|
||||
|
||||
if ($this->endDate) {
|
||||
$this->setEndDate($this->getEndDate()->roundUnit($unit, $precision, $function));
|
||||
}
|
||||
|
||||
$this->setDateInterval($this->getDateInterval()->roundUnit($unit, $precision, $function));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate the current instance at the given unit with given precision if specified.
|
||||
*
|
||||
* @param string $unit
|
||||
* @param float|int|string|\DateInterval|null $precision
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function floorUnit($unit, $precision = 1)
|
||||
{
|
||||
return $this->roundUnit($unit, $precision, 'floor');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ceil the current instance at the given unit with given precision if specified.
|
||||
*
|
||||
* @param string $unit
|
||||
* @param float|int|string|\DateInterval|null $precision
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ceilUnit($unit, $precision = 1)
|
||||
{
|
||||
return $this->roundUnit($unit, $precision, 'ceil');
|
||||
}
|
||||
|
||||
/**
|
||||
* Round the current instance second with given precision if specified (else period interval is used).
|
||||
*
|
||||
* @param float|int|string|\DateInterval|null $precision
|
||||
* @param string $function
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function round($precision = null, $function = 'round')
|
||||
{
|
||||
return $this->roundWith($precision ?? (string) $this->getDateInterval(), $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Round the current instance second with given precision if specified (else period interval is used).
|
||||
*
|
||||
* @param float|int|string|\DateInterval|null $precision
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function floor($precision = null)
|
||||
{
|
||||
return $this->round($precision, 'floor');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ceil the current instance second with given precision if specified (else period interval is used).
|
||||
*
|
||||
* @param float|int|string|\DateInterval|null $precision
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ceil($precision = null)
|
||||
{
|
||||
return $this->round($precision, 'ceil');
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON.
|
||||
*
|
||||
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
*
|
||||
* @return CarbonInterface[]
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given date is between start and end.
|
||||
*
|
||||
* @param \Carbon\Carbon|\Carbon\CarbonPeriod|\Carbon\CarbonInterval|\DateInterval|\DatePeriod|\DateTimeInterface|string|null $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function contains($date = null): bool
|
||||
{
|
||||
$startMethod = 'startsBefore'.($this->isStartIncluded() ? 'OrAt' : '');
|
||||
$endMethod = 'endsAfter'.($this->isEndIncluded() ? 'OrAt' : '');
|
||||
|
||||
return $this->$startMethod($date) && $this->$endMethod($date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the current period follows a given other period (with no overlap).
|
||||
* For instance, [2019-08-01 -> 2019-08-12] follows [2019-07-29 -> 2019-07-31]
|
||||
* Note than in this example, follows() would be false if 2019-08-01 or 2019-07-31 was excluded by options.
|
||||
*
|
||||
* @param \Carbon\CarbonPeriod|\DatePeriod|string $period
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function follows($period, ...$arguments): bool
|
||||
{
|
||||
$period = $this->resolveCarbonPeriod($period, ...$arguments);
|
||||
|
||||
return $this->getIncludedStartDate()->equalTo($period->getIncludedEndDate()->add($period->getDateInterval()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given other period follows the current one (with no overlap).
|
||||
* For instance, [2019-07-29 -> 2019-07-31] is followed by [2019-08-01 -> 2019-08-12]
|
||||
* Note than in this example, isFollowedBy() would be false if 2019-08-01 or 2019-07-31 was excluded by options.
|
||||
*
|
||||
* @param \Carbon\CarbonPeriod|\DatePeriod|string $period
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFollowedBy($period, ...$arguments): bool
|
||||
{
|
||||
$period = $this->resolveCarbonPeriod($period, ...$arguments);
|
||||
|
||||
return $period->follows($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given period either follows or is followed by the current one.
|
||||
*
|
||||
* @see follows()
|
||||
* @see isFollowedBy()
|
||||
*
|
||||
* @param \Carbon\CarbonPeriod|\DatePeriod|string $period
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isConsecutiveWith($period, ...$arguments): bool
|
||||
{
|
||||
return $this->follows($period, ...$arguments) || $this->isFollowedBy($period, ...$arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update properties after removing built-in filters.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function updateInternalState()
|
||||
{
|
||||
if (!$this->hasFilter(static::END_DATE_FILTER)) {
|
||||
$this->endDate = null;
|
||||
}
|
||||
|
||||
if (!$this->hasFilter(static::RECURRENCES_FILTER)) {
|
||||
$this->recurrences = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a filter tuple from raw parameters.
|
||||
*
|
||||
* Will create an automatic filter callback for one of Carbon's is* methods.
|
||||
*
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function createFilterTuple(array $parameters)
|
||||
{
|
||||
$method = array_shift($parameters);
|
||||
|
||||
if (!$this->isCarbonPredicateMethod($method)) {
|
||||
return [$method, array_shift($parameters)];
|
||||
}
|
||||
|
||||
return [function ($date) use ($method, $parameters) {
|
||||
return ([$date, $method])(...$parameters);
|
||||
}, $method];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether given callable is a string pointing to one of Carbon's is* methods
|
||||
* and should be automatically converted to a filter callback.
|
||||
*
|
||||
* @param callable $callable
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isCarbonPredicateMethod($callable)
|
||||
{
|
||||
return \is_string($callable) && str_starts_with($callable, 'is') &&
|
||||
(method_exists($this->dateClass, $callable) || ([$this->dateClass, 'hasMacro'])($callable));
|
||||
}
|
||||
|
||||
/**
|
||||
* Recurrences filter callback (limits number of recurrences).
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @param \Carbon\Carbon $current
|
||||
* @param int $key
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function filterRecurrences($current, $key)
|
||||
{
|
||||
if ($key < $this->recurrences) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return static::END_ITERATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* End date filter callback.
|
||||
*
|
||||
* @param \Carbon\Carbon $current
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function filterEndDate($current)
|
||||
{
|
||||
if (!$this->isEndExcluded() && $current == $this->endDate) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->dateInterval->invert ? $current > $this->endDate : $current < $this->endDate) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return static::END_ITERATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* End iteration filter callback.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function endIteration()
|
||||
{
|
||||
return static::END_ITERATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle change of the parameters.
|
||||
*/
|
||||
protected function handleChangedParameters()
|
||||
{
|
||||
if (($this->getOptions() & static::IMMUTABLE) && $this->dateClass === Carbon::class) {
|
||||
$this->setDateClass(CarbonImmutable::class);
|
||||
} elseif (!($this->getOptions() & static::IMMUTABLE) && $this->dateClass === CarbonImmutable::class) {
|
||||
$this->setDateClass(Carbon::class);
|
||||
}
|
||||
|
||||
$this->validationResult = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate current date and stop iteration when necessary.
|
||||
*
|
||||
* Returns true when current date is valid, false if it is not, or static::END_ITERATION
|
||||
* when iteration should be stopped.
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function validateCurrentDate()
|
||||
{
|
||||
if ($this->current === null) {
|
||||
$this->rewind();
|
||||
}
|
||||
|
||||
// Check after the first rewind to avoid repeating the initial validation.
|
||||
return $this->validationResult ?? ($this->validationResult = $this->checkFilters());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether current value and key pass all the filters.
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function checkFilters()
|
||||
{
|
||||
$current = $this->prepareForReturn($this->current);
|
||||
|
||||
foreach ($this->filters as $tuple) {
|
||||
$result = \call_user_func(
|
||||
$tuple[0],
|
||||
$current->avoidMutation(),
|
||||
$this->key,
|
||||
$this
|
||||
);
|
||||
|
||||
if ($result === static::END_ITERATION) {
|
||||
return static::END_ITERATION;
|
||||
}
|
||||
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare given date to be returned to the external logic.
|
||||
*
|
||||
* @param CarbonInterface $date
|
||||
*
|
||||
* @return CarbonInterface
|
||||
*/
|
||||
protected function prepareForReturn(CarbonInterface $date)
|
||||
{
|
||||
$date = ([$this->dateClass, 'make'])($date);
|
||||
|
||||
if ($this->timezone) {
|
||||
$date = $date->setTimezone($this->timezone);
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep incrementing the current date until a valid date is found or the iteration is ended.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function incrementCurrentDateUntilValid()
|
||||
{
|
||||
$attempts = 0;
|
||||
|
||||
do {
|
||||
$this->current = $this->current->add($this->dateInterval);
|
||||
|
||||
$this->validationResult = null;
|
||||
|
||||
if (++$attempts > static::NEXT_MAX_ATTEMPTS) {
|
||||
throw new UnreachableException('Could not find next valid date.');
|
||||
}
|
||||
} while ($this->validateCurrentDate() === false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call given macro.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callMacro($name, $parameters)
|
||||
{
|
||||
$macro = static::$macros[$name];
|
||||
|
||||
if ($macro instanceof Closure) {
|
||||
$boundMacro = @$macro->bindTo($this, static::class) ?: @$macro->bindTo(null, static::class);
|
||||
|
||||
return ($boundMacro ?: $macro)(...$parameters);
|
||||
}
|
||||
|
||||
return $macro(...$parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Carbon instance passed through, a now instance in the same timezone
|
||||
* if null given or parse the input if string given.
|
||||
*
|
||||
* @param \Carbon\Carbon|\Carbon\CarbonPeriod|\Carbon\CarbonInterval|\DateInterval|\DatePeriod|\DateTimeInterface|string|null $date
|
||||
*
|
||||
* @return \Carbon\CarbonInterface
|
||||
*/
|
||||
protected function resolveCarbon($date = null)
|
||||
{
|
||||
return $this->getStartDate()->nowWithSameTz()->carbonize($date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve passed arguments or DatePeriod to a CarbonPeriod object.
|
||||
*
|
||||
* @param mixed $period
|
||||
* @param mixed ...$arguments
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
protected function resolveCarbonPeriod($period, ...$arguments)
|
||||
{
|
||||
if ($period instanceof self) {
|
||||
return $period;
|
||||
}
|
||||
|
||||
return $period instanceof DatePeriod
|
||||
? static::instance($period)
|
||||
: static::create($period, ...$arguments);
|
||||
}
|
||||
|
||||
private function orderCouple($first, $second): array
|
||||
{
|
||||
return $first > $second ? [$second, $first] : [$first, $second];
|
||||
}
|
||||
|
||||
private function makeDateTime($value): ?DateTimeInterface
|
||||
{
|
||||
if ($value instanceof DateTimeInterface) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (\is_string($value)) {
|
||||
$value = trim($value);
|
||||
|
||||
if (!preg_match('/^P[0-9T]/', $value) &&
|
||||
!preg_match('/^R[0-9]/', $value) &&
|
||||
preg_match('/[a-z0-9]/i', $value)
|
||||
) {
|
||||
return Carbon::parse($value, $this->tzName);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+306
@@ -0,0 +1,306 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon;
|
||||
|
||||
use Carbon\Exceptions\InvalidCastException;
|
||||
use Carbon\Exceptions\InvalidTimeZoneException;
|
||||
use DateTimeInterface;
|
||||
use DateTimeZone;
|
||||
|
||||
class CarbonTimeZone extends DateTimeZone
|
||||
{
|
||||
public function __construct($timezone = null)
|
||||
{
|
||||
parent::__construct(static::getDateTimeZoneNameFromMixed($timezone));
|
||||
}
|
||||
|
||||
protected static function parseNumericTimezone($timezone)
|
||||
{
|
||||
if ($timezone <= -100 || $timezone >= 100) {
|
||||
throw new InvalidTimeZoneException('Absolute timezone offset cannot be greater than 100.');
|
||||
}
|
||||
|
||||
return ($timezone >= 0 ? '+' : '').$timezone.':00';
|
||||
}
|
||||
|
||||
protected static function getDateTimeZoneNameFromMixed($timezone)
|
||||
{
|
||||
if ($timezone === null) {
|
||||
return date_default_timezone_get();
|
||||
}
|
||||
|
||||
if (\is_string($timezone)) {
|
||||
$timezone = preg_replace('/^\s*([+-]\d+)(\d{2})\s*$/', '$1:$2', $timezone);
|
||||
}
|
||||
|
||||
if (is_numeric($timezone)) {
|
||||
return static::parseNumericTimezone($timezone);
|
||||
}
|
||||
|
||||
return $timezone;
|
||||
}
|
||||
|
||||
protected static function getDateTimeZoneFromName(&$name)
|
||||
{
|
||||
return @timezone_open($name = (string) static::getDateTimeZoneNameFromMixed($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast the current instance into the given class.
|
||||
*
|
||||
* @param string $className The $className::instance() method will be called to cast the current object.
|
||||
*
|
||||
* @return DateTimeZone
|
||||
*/
|
||||
public function cast(string $className)
|
||||
{
|
||||
if (!method_exists($className, 'instance')) {
|
||||
if (is_a($className, DateTimeZone::class, true)) {
|
||||
return new $className($this->getName());
|
||||
}
|
||||
|
||||
throw new InvalidCastException("$className has not the instance() method needed to cast the date.");
|
||||
}
|
||||
|
||||
return $className::instance($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a CarbonTimeZone from mixed input.
|
||||
*
|
||||
* @param DateTimeZone|string|int|null $object original value to get CarbonTimeZone from it.
|
||||
* @param DateTimeZone|string|int|null $objectDump dump of the object for error messages.
|
||||
*
|
||||
* @throws InvalidTimeZoneException
|
||||
*
|
||||
* @return false|static
|
||||
*/
|
||||
public static function instance($object = null, $objectDump = null)
|
||||
{
|
||||
$tz = $object;
|
||||
|
||||
if ($tz instanceof static) {
|
||||
return $tz;
|
||||
}
|
||||
|
||||
if ($tz === null) {
|
||||
return new static();
|
||||
}
|
||||
|
||||
if (!$tz instanceof DateTimeZone) {
|
||||
$tz = static::getDateTimeZoneFromName($object);
|
||||
}
|
||||
|
||||
if ($tz === false) {
|
||||
if (Carbon::isStrictModeEnabled()) {
|
||||
throw new InvalidTimeZoneException('Unknown or bad timezone ('.($objectDump ?: $object).')');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return new static($tz->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns abbreviated name of the current timezone according to DST setting.
|
||||
*
|
||||
* @param bool $dst
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAbbreviatedName($dst = false)
|
||||
{
|
||||
$name = $this->getName();
|
||||
|
||||
foreach ($this->listAbbreviations() as $abbreviation => $zones) {
|
||||
foreach ($zones as $zone) {
|
||||
if ($zone['timezone_id'] === $name && $zone['dst'] == $dst) {
|
||||
return $abbreviation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
/**
|
||||
* @alias getAbbreviatedName
|
||||
*
|
||||
* Returns abbreviated name of the current timezone according to DST setting.
|
||||
*
|
||||
* @param bool $dst
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAbbr($dst = false)
|
||||
{
|
||||
return $this->getAbbreviatedName($dst);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offset as string "sHH:MM" (such as "+00:00" or "-12:30").
|
||||
*
|
||||
* @param DateTimeInterface|null $date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toOffsetName(DateTimeInterface $date = null)
|
||||
{
|
||||
return static::getOffsetNameFromMinuteOffset(
|
||||
$this->getOffset($date ?: Carbon::now($this)) / 60
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new CarbonTimeZone object using the offset string instead of region string.
|
||||
*
|
||||
* @param DateTimeInterface|null $date
|
||||
*
|
||||
* @return CarbonTimeZone
|
||||
*/
|
||||
public function toOffsetTimeZone(DateTimeInterface $date = null)
|
||||
{
|
||||
return new static($this->toOffsetName($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first region string (such as "America/Toronto") that matches the current timezone or
|
||||
* false if no match is found.
|
||||
*
|
||||
* @see timezone_name_from_abbr native PHP function.
|
||||
*
|
||||
* @param DateTimeInterface|null $date
|
||||
* @param int $isDst
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public function toRegionName(DateTimeInterface $date = null, $isDst = 1)
|
||||
{
|
||||
$name = $this->getName();
|
||||
$firstChar = substr($name, 0, 1);
|
||||
|
||||
if ($firstChar !== '+' && $firstChar !== '-') {
|
||||
return $name;
|
||||
}
|
||||
|
||||
$date = $date ?: Carbon::now($this);
|
||||
|
||||
// Integer construction no longer supported since PHP 8
|
||||
// @codeCoverageIgnoreStart
|
||||
try {
|
||||
$offset = @$this->getOffset($date) ?: 0;
|
||||
} catch (\Throwable $e) {
|
||||
$offset = 0;
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
$name = @timezone_name_from_abbr('', $offset, $isDst);
|
||||
|
||||
if ($name) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
foreach (timezone_identifiers_list() as $timezone) {
|
||||
if (Carbon::instance($date)->tz($timezone)->getOffset() === $offset) {
|
||||
return $timezone;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new CarbonTimeZone object using the region string instead of offset string.
|
||||
*
|
||||
* @param DateTimeInterface|null $date
|
||||
*
|
||||
* @return CarbonTimeZone|false
|
||||
*/
|
||||
public function toRegionTimeZone(DateTimeInterface $date = null)
|
||||
{
|
||||
$tz = $this->toRegionName($date);
|
||||
|
||||
if ($tz === false) {
|
||||
if (Carbon::isStrictModeEnabled()) {
|
||||
throw new InvalidTimeZoneException('Unknown timezone for offset '.$this->getOffset($date ?: Carbon::now($this)).' seconds.');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return new static($tz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast to string (get timezone name).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a CarbonTimeZone from mixed input.
|
||||
*
|
||||
* @param DateTimeZone|string|int|null $object
|
||||
*
|
||||
* @return false|static
|
||||
*/
|
||||
public static function create($object = null)
|
||||
{
|
||||
return static::instance($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a CarbonTimeZone from int/float hour offset.
|
||||
*
|
||||
* @param float $hourOffset number of hour of the timezone shift (can be decimal).
|
||||
*
|
||||
* @return false|static
|
||||
*/
|
||||
public static function createFromHourOffset(float $hourOffset)
|
||||
{
|
||||
return static::createFromMinuteOffset($hourOffset * Carbon::MINUTES_PER_HOUR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a CarbonTimeZone from int/float minute offset.
|
||||
*
|
||||
* @param float $minuteOffset number of total minutes of the timezone shift.
|
||||
*
|
||||
* @return false|static
|
||||
*/
|
||||
public static function createFromMinuteOffset(float $minuteOffset)
|
||||
{
|
||||
return static::instance(static::getOffsetNameFromMinuteOffset($minuteOffset));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a total minutes offset into a standardized timezone offset string.
|
||||
*
|
||||
* @param float $minutes number of total minutes of the timezone shift.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getOffsetNameFromMinuteOffset(float $minutes): string
|
||||
{
|
||||
$minutes = round($minutes);
|
||||
$unsignedMinutes = abs($minutes);
|
||||
|
||||
return ($minutes < 0 ? '-' : '+').
|
||||
str_pad((string) floor($unsignedMinutes / 60), 2, '0', STR_PAD_LEFT).
|
||||
':'.
|
||||
str_pad((string) ($unsignedMinutes % 60), 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Carbon\Cli;
|
||||
|
||||
class Invoker
|
||||
{
|
||||
public const CLI_CLASS_NAME = 'Carbon\\Cli';
|
||||
|
||||
protected function runWithCli(string $className, array $parameters): bool
|
||||
{
|
||||
$cli = new $className();
|
||||
|
||||
return $cli(...$parameters);
|
||||
}
|
||||
|
||||
public function __invoke(...$parameters): bool
|
||||
{
|
||||
if (class_exists(self::CLI_CLASS_NAME)) {
|
||||
return $this->runWithCli(self::CLI_CLASS_NAME, $parameters);
|
||||
}
|
||||
|
||||
$function = (($parameters[1] ?? '') === 'install' ? ($parameters[2] ?? null) : null) ?: 'shell_exec';
|
||||
$function('composer require carbon-cli/carbon-cli --no-interaction');
|
||||
|
||||
echo 'Installation succeeded.';
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Thanks to https://github.com/flaushi for his suggestion:
|
||||
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
|
||||
*/
|
||||
namespace Carbon\Doctrine;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
|
||||
interface CarbonDoctrineType
|
||||
{
|
||||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform);
|
||||
|
||||
public function convertToPHPValue($value, AbstractPlatform $platform);
|
||||
|
||||
public function convertToDatabaseValue($value, AbstractPlatform $platform);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Thanks to https://github.com/flaushi for his suggestion:
|
||||
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
|
||||
*/
|
||||
namespace Carbon\Doctrine;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
|
||||
class CarbonImmutableType extends DateTimeImmutableType implements CarbonDoctrineType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'carbon_immutable';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function requiresSQLCommentHint(AbstractPlatform $platform)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Thanks to https://github.com/flaushi for his suggestion:
|
||||
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
|
||||
*/
|
||||
namespace Carbon\Doctrine;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
|
||||
class CarbonType extends DateTimeType implements CarbonDoctrineType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'carbon';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function requiresSQLCommentHint(AbstractPlatform $platform)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Thanks to https://github.com/flaushi for his suggestion:
|
||||
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
|
||||
*/
|
||||
namespace Carbon\Doctrine;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonInterface;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Types\ConversionException;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @template T of CarbonInterface
|
||||
*/
|
||||
trait CarbonTypeConverter
|
||||
{
|
||||
/**
|
||||
* @return class-string<T>
|
||||
*/
|
||||
protected function getCarbonClassName(): string
|
||||
{
|
||||
return Carbon::class;
|
||||
}
|
||||
|
||||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
|
||||
{
|
||||
$precision = ($fieldDeclaration['precision'] ?: 10) === 10
|
||||
? DateTimeDefaultPrecision::get()
|
||||
: $fieldDeclaration['precision'];
|
||||
$type = parent::getSQLDeclaration($fieldDeclaration, $platform);
|
||||
|
||||
if (!$precision) {
|
||||
return $type;
|
||||
}
|
||||
|
||||
if (str_contains($type, '(')) {
|
||||
return preg_replace('/\(\d+\)/', "($precision)", $type);
|
||||
}
|
||||
|
||||
[$before, $after] = explode(' ', "$type ");
|
||||
|
||||
return trim("$before($precision) $after");
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return T|null
|
||||
*/
|
||||
public function convertToPHPValue($value, AbstractPlatform $platform)
|
||||
{
|
||||
$class = $this->getCarbonClassName();
|
||||
|
||||
if ($value === null || is_a($value, $class)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ($value instanceof DateTimeInterface) {
|
||||
return $class::instance($value);
|
||||
}
|
||||
|
||||
$date = null;
|
||||
$error = null;
|
||||
|
||||
try {
|
||||
$date = $class::parse($value);
|
||||
} catch (Exception $exception) {
|
||||
$error = $exception;
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
throw ConversionException::conversionFailedFormat(
|
||||
$value,
|
||||
$this->getName(),
|
||||
'Y-m-d H:i:s.u or any format supported by '.$class.'::parse()',
|
||||
$error
|
||||
);
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function convertToDatabaseValue($value, AbstractPlatform $platform)
|
||||
{
|
||||
if ($value === null) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ($value instanceof DateTimeInterface) {
|
||||
return $value->format('Y-m-d H:i:s.u');
|
||||
}
|
||||
|
||||
throw ConversionException::conversionFailedInvalidType(
|
||||
$value,
|
||||
$this->getName(),
|
||||
['null', 'DateTime', 'Carbon']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Thanks to https://github.com/flaushi for his suggestion:
|
||||
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
|
||||
*/
|
||||
namespace Carbon\Doctrine;
|
||||
|
||||
class DateTimeDefaultPrecision
|
||||
{
|
||||
private static $precision = 6;
|
||||
|
||||
/**
|
||||
* Change the default Doctrine datetime and datetime_immutable precision.
|
||||
*
|
||||
* @param int $precision
|
||||
*/
|
||||
public static function set(int $precision): void
|
||||
{
|
||||
self::$precision = $precision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default Doctrine datetime and datetime_immutable precision.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function get(): int
|
||||
{
|
||||
return self::$precision;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Thanks to https://github.com/flaushi for his suggestion:
|
||||
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
|
||||
*/
|
||||
namespace Carbon\Doctrine;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
use Doctrine\DBAL\Types\VarDateTimeImmutableType;
|
||||
|
||||
class DateTimeImmutableType extends VarDateTimeImmutableType implements CarbonDoctrineType
|
||||
{
|
||||
/** @use CarbonTypeConverter<CarbonImmutable> */
|
||||
use CarbonTypeConverter;
|
||||
|
||||
/**
|
||||
* @return class-string<CarbonImmutable>
|
||||
*/
|
||||
protected function getCarbonClassName(): string
|
||||
{
|
||||
return CarbonImmutable::class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Thanks to https://github.com/flaushi for his suggestion:
|
||||
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
|
||||
*/
|
||||
namespace Carbon\Doctrine;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Doctrine\DBAL\Types\VarDateTimeType;
|
||||
|
||||
class DateTimeType extends VarDateTimeType implements CarbonDoctrineType
|
||||
{
|
||||
/** @use CarbonTypeConverter<Carbon> */
|
||||
use CarbonTypeConverter;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class BadComparisonUnitException extends UnitException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $unit
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($unit, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct("Bad comparison unit: '$unit'", $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use BadMethodCallException as BaseBadMethodCallException;
|
||||
use Exception;
|
||||
|
||||
class BadFluentConstructorException extends BaseBadMethodCallException implements BadMethodCallException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $method
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($method, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct(sprintf("Unknown fluent constructor '%s'.", $method), $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use BadMethodCallException as BaseBadMethodCallException;
|
||||
use Exception;
|
||||
|
||||
class BadFluentSetterException extends BaseBadMethodCallException implements BadMethodCallException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $method
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($method, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct(sprintf("Unknown fluent setter '%s'", $method), $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
interface BadMethodCallException extends Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
interface Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use RuntimeException as BaseRuntimeException;
|
||||
|
||||
class ImmutableException extends BaseRuntimeException implements RuntimeException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $value the immutable type/value
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($value, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct("$value is immutable.", $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
interface InvalidArgumentException extends Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class InvalidCastException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class InvalidDateException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* The invalid field.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $field;
|
||||
|
||||
/**
|
||||
* The invalid value.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($field, $value, $code = 0, Exception $previous = null)
|
||||
{
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
parent::__construct($field.' : '.$value.' is not a valid value.', $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the invalid field.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getField()
|
||||
{
|
||||
return $this->field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the invalid value.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class InvalidFormatException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class InvalidIntervalException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class InvalidPeriodDateException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class InvalidPeriodParameterException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class InvalidTimeZoneException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class InvalidTypeException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Carbon\CarbonInterface;
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class NotACarbonClassException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $className
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($className, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'Given class does not implement %s: %s',
|
||||
CarbonInterface::class,
|
||||
$className
|
||||
), $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class NotAPeriodException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class NotLocaleAwareException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed $object
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($object, $code = 0, Exception $previous = null)
|
||||
{
|
||||
$dump = \is_object($object) ? \get_class($object) : \gettype($object);
|
||||
|
||||
parent::__construct("$dump does neither implements Symfony\Contracts\Translation\LocaleAwareInterface nor getLocale() method.", $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
// This will extends OutOfRangeException instead of InvalidArgumentException since 3.0.0
|
||||
// use OutOfRangeException as BaseOutOfRangeException;
|
||||
|
||||
class OutOfRangeException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* The unit or name of the value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $unit;
|
||||
|
||||
/**
|
||||
* The range minimum.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $min;
|
||||
|
||||
/**
|
||||
* The range maximum.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $max;
|
||||
|
||||
/**
|
||||
* The invalid value.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $unit
|
||||
* @param mixed $min
|
||||
* @param mixed $max
|
||||
* @param mixed $value
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($unit, $min, $max, $value, $code = 0, Exception $previous = null)
|
||||
{
|
||||
$this->unit = $unit;
|
||||
$this->min = $min;
|
||||
$this->max = $max;
|
||||
$this->value = $value;
|
||||
|
||||
parent::__construct("$unit must be between $min and $max, $value given", $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMax()
|
||||
{
|
||||
return $this->max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMin()
|
||||
{
|
||||
return $this->min;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUnit()
|
||||
{
|
||||
return $this->unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class ParseErrorException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $actual
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($expected, $actual, $help = '', $code = 0, Exception $previous = null)
|
||||
{
|
||||
$actual = $actual === '' ? 'data is missing' : "get '$actual'";
|
||||
|
||||
parent::__construct(trim("Format expected $expected but $actual\n$help"), $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
interface RuntimeException extends Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class UnitException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class UnitNotConfiguredException extends UnitException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $unit
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($unit, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct("Unit $unit have no configuration to get total from other units.", $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class UnknownGetterException extends BaseInvalidArgumentException implements InvalidArgumentException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name getter name
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($name, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct("Unknown getter '$name'", $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use BadMethodCallException as BaseBadMethodCallException;
|
||||
use Exception;
|
||||
|
||||
class UnknownMethodException extends BaseBadMethodCallException implements BadMethodCallException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $method
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($method, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct("Method $method does not exist.", $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
class UnknownSetterException extends BaseInvalidArgumentException implements BadMethodCallException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name setter name
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($name, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct("Unknown setter '$name'", $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class UnknownUnitException extends UnitException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $unit
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($unit, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct("Unknown unit '$unit'.", $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use RuntimeException as BaseRuntimeException;
|
||||
|
||||
class UnreachableException extends BaseRuntimeException implements RuntimeException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
+311
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon;
|
||||
|
||||
use Closure;
|
||||
use DateTimeInterface;
|
||||
use ReflectionMethod;
|
||||
|
||||
/**
|
||||
* A factory to generate Carbon instances with common settings.
|
||||
*
|
||||
* <autodoc generated by `composer phpdoc`>
|
||||
*
|
||||
* @method bool canBeCreatedFromFormat($date, $format) Checks if the (date)time string is in a given format and valid to create a
|
||||
* new instance.
|
||||
* @method Carbon|false create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) Create a new Carbon instance from a specific date and time.
|
||||
* If any of $year, $month or $day are set to null their now() values will
|
||||
* be used.
|
||||
* If $hour is null it will be set to its now() value and the default
|
||||
* values for $minute and $second will be their now() values.
|
||||
* If $hour is not null then the default values for $minute and $second
|
||||
* will be 0.
|
||||
* @method Carbon createFromDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to now.
|
||||
* @method Carbon|false createFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
|
||||
* @method Carbon|false createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null) Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
|
||||
* @method Carbon|false createFromLocaleFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific format and a string in a given language.
|
||||
* @method Carbon|false createFromLocaleIsoFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific ISO format and a string in a given language.
|
||||
* @method Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null) Create a Carbon instance from just a time. The date portion is set to today.
|
||||
* @method Carbon createFromTimeString($time, $tz = null) Create a Carbon instance from a time string. The date portion is set to today.
|
||||
* @method Carbon createFromTimestamp($timestamp, $tz = null) Create a Carbon instance from a timestamp and set the timezone (use default one if not specified).
|
||||
* Timestamp input can be given as int, float or a string containing one or more numbers.
|
||||
* @method Carbon createFromTimestampMs($timestamp, $tz = null) Create a Carbon instance from a timestamp in milliseconds.
|
||||
* Timestamp input can be given as int, float or a string containing one or more numbers.
|
||||
* @method Carbon createFromTimestampMsUTC($timestamp) Create a Carbon instance from a timestamp in milliseconds.
|
||||
* Timestamp input can be given as int, float or a string containing one or more numbers.
|
||||
* @method Carbon createFromTimestampUTC($timestamp) Create a Carbon instance from an timestamp keeping the timezone to UTC.
|
||||
* Timestamp input can be given as int, float or a string containing one or more numbers.
|
||||
* @method Carbon createMidnightDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to midnight.
|
||||
* @method Carbon|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) Create a new safe Carbon instance from a specific date and time.
|
||||
* If any of $year, $month or $day are set to null their now() values will
|
||||
* be used.
|
||||
* If $hour is null it will be set to its now() value and the default
|
||||
* values for $minute and $second will be their now() values.
|
||||
* If $hour is not null then the default values for $minute and $second
|
||||
* will be 0.
|
||||
* If one of the set values is not valid, an InvalidDateException
|
||||
* will be thrown.
|
||||
* @method CarbonInterface createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null) Create a new Carbon instance from a specific date and time using strict validation.
|
||||
* @method Carbon disableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* @method Carbon enableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* @method mixed executeWithLocale($locale, $func) Set the current locale to the given, execute the passed function, reset the locale to previous one,
|
||||
* then return the result of the closure (or null if the closure was void).
|
||||
* @method Carbon fromSerialized($value) Create an instance from a serialized string.
|
||||
* @method void genericMacro($macro, $priority = 0) Register a custom macro.
|
||||
* @method array getAvailableLocales() Returns the list of internally available locales and already loaded custom locales.
|
||||
* (It will ignore custom translator dynamic loading.)
|
||||
* @method Language[] getAvailableLocalesInfo() Returns list of Language object for each available locale. This object allow you to get the ISO name, native
|
||||
* name, region and variant of the locale.
|
||||
* @method array getDays() Get the days of the week
|
||||
* @method string|null getFallbackLocale() Get the fallback locale.
|
||||
* @method array getFormatsToIsoReplacements() List of replacements from date() format to isoFormat().
|
||||
* @method int getHumanDiffOptions() Return default humanDiff() options (merged flags as integer).
|
||||
* @method array getIsoUnits() Returns list of locale units for ISO formatting.
|
||||
* @method Carbon getLastErrors() {@inheritdoc}
|
||||
* @method string getLocale() Get the current translator locale.
|
||||
* @method callable|null getMacro($name) Get the raw callable macro registered globally for a given name.
|
||||
* @method int getMidDayAt() get midday/noon hour
|
||||
* @method Closure|Carbon getTestNow() Get the Carbon instance (real or mock) to be returned when a "now"
|
||||
* instance is created.
|
||||
* @method string getTimeFormatByPrecision($unitPrecision) Return a format from H:i to H:i:s.u according to given unit precision.
|
||||
* @method string getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null) Returns raw translation message for a given key.
|
||||
* @method \Symfony\Component\Translation\TranslatorInterface getTranslator() Get the default translator instance in use.
|
||||
* @method int getWeekEndsAt() Get the last day of week
|
||||
* @method int getWeekStartsAt() Get the first day of week
|
||||
* @method array getWeekendDays() Get weekend days
|
||||
* @method bool hasFormat($date, $format) Checks if the (date)time string is in a given format.
|
||||
* @method bool hasFormatWithModifiers($date, $format) Checks if the (date)time string is in a given format.
|
||||
* @method bool hasMacro($name) Checks if macro is registered globally.
|
||||
* @method bool hasRelativeKeywords($time) Determine if a time string will produce a relative date.
|
||||
* @method bool hasTestNow() Determine if there is a valid test instance set. A valid test instance
|
||||
* is anything that is not null.
|
||||
* @method Carbon instance($date) Create a Carbon instance from a DateTime one.
|
||||
* @method bool isImmutable() Returns true if the current class/instance is immutable.
|
||||
* @method bool isModifiableUnit($unit) Returns true if a property can be changed via setter.
|
||||
* @method bool isMutable() Returns true if the current class/instance is mutable.
|
||||
* @method bool isStrictModeEnabled() Returns true if the strict mode is globally in use, false else.
|
||||
* (It can be overridden in specific instances.)
|
||||
* @method bool localeHasDiffOneDayWords($locale) Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
|
||||
* Support is considered enabled if the 3 words are translated in the given locale.
|
||||
* @method bool localeHasDiffSyntax($locale) Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
|
||||
* Support is considered enabled if the 4 sentences are translated in the given locale.
|
||||
* @method bool localeHasDiffTwoDayWords($locale) Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
|
||||
* Support is considered enabled if the 2 words are translated in the given locale.
|
||||
* @method bool localeHasPeriodSyntax($locale) Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
|
||||
* Support is considered enabled if the 4 sentences are translated in the given locale.
|
||||
* @method bool localeHasShortUnits($locale) Returns true if the given locale is internally supported and has short-units support.
|
||||
* Support is considered enabled if either year, day or hour has a short variant translated.
|
||||
* @method void macro($name, $macro) Register a custom macro.
|
||||
* @method Carbon|null make($var) Make a Carbon instance from given variable if possible.
|
||||
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
|
||||
* and recurrences). Throw an exception for invalid format, but otherwise return null.
|
||||
* @method Carbon maxValue() Create a Carbon instance for the greatest supported date.
|
||||
* @method Carbon minValue() Create a Carbon instance for the lowest supported date.
|
||||
* @method void mixin($mixin) Mix another object into the class.
|
||||
* @method Carbon now($tz = null) Get a Carbon instance for the current date and time.
|
||||
* @method Carbon parse($time = null, $tz = null) Create a carbon instance from a string.
|
||||
* This is an alias for the constructor that allows better fluent syntax
|
||||
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
|
||||
* than (new Carbon('Monday next week'))->fn().
|
||||
* @method Carbon parseFromLocale($time, $locale = null, $tz = null) Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
|
||||
* @method string pluralUnit(string $unit) Returns standardized plural of a given singular/plural unit name (in English).
|
||||
* @method Carbon|false rawCreateFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
|
||||
* @method Carbon rawParse($time = null, $tz = null) Create a carbon instance from a string.
|
||||
* This is an alias for the constructor that allows better fluent syntax
|
||||
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
|
||||
* than (new Carbon('Monday next week'))->fn().
|
||||
* @method Carbon resetMacros() Remove all macros and generic macros.
|
||||
* @method void resetMonthsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
|
||||
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
|
||||
* @method void resetToStringFormat() Reset the format used to the default when type juggling a Carbon instance to a string
|
||||
* @method void resetYearsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
|
||||
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
|
||||
* @method void serializeUsing($callback) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather transform Carbon object before the serialization.
|
||||
* JSON serialize all Carbon instances using the given callback.
|
||||
* @method Carbon setFallbackLocale($locale) Set the fallback locale.
|
||||
* @method Carbon setHumanDiffOptions($humanDiffOptions) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* @method bool setLocale($locale) Set the current translator locale and indicate if the source locale file exists.
|
||||
* Pass 'auto' as locale to use closest language from the current LC_TIME locale.
|
||||
* @method void setMidDayAt($hour) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather consider mid-day is always 12pm, then if you need to test if it's an other
|
||||
* hour, test it explicitly:
|
||||
* $date->format('G') == 13
|
||||
* or to set explicitly to a given hour:
|
||||
* $date->setTime(13, 0, 0, 0)
|
||||
* Set midday/noon hour
|
||||
* @method Carbon setTestNow($testNow = null) Set a Carbon instance (real or mock) to be returned when a "now"
|
||||
* instance is created. The provided instance will be returned
|
||||
* specifically under the following conditions:
|
||||
* - A call to the static now() method, ex. Carbon::now()
|
||||
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
|
||||
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
|
||||
* - When a string containing the desired time is passed to Carbon::parse().
|
||||
* Note the timezone parameter was left out of the examples above and
|
||||
* has no affect as the mock value will be returned regardless of its value.
|
||||
* To clear the test instance call this method using the default
|
||||
* parameter of null.
|
||||
* /!\ Use this method for unit tests only.
|
||||
* @method void setToStringFormat($format) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and
|
||||
* use other method or custom format passed to format() method if you need to dump an other string
|
||||
* format.
|
||||
* Set the default format used when type juggling a Carbon instance to a string
|
||||
* @method void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator) Set the default translator instance to use.
|
||||
* @method Carbon setUtf8($utf8) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use UTF-8 language packages on every machine.
|
||||
* Set if UTF8 will be used for localized date/time.
|
||||
* @method void setWeekEndsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek
|
||||
* or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the
|
||||
* start of week according to current locale selected and implicitly the end of week.
|
||||
* Set the last day of week
|
||||
* @method void setWeekStartsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the
|
||||
* 'first_day_of_week' locale setting to change the start of week according to current locale
|
||||
* selected and implicitly the end of week.
|
||||
* Set the first day of week
|
||||
* @method void setWeekendDays($days) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather consider week-end is always saturday and sunday, and if you have some custom
|
||||
* week-end days to handle, give to those days an other name and create a macro for them:
|
||||
* ```
|
||||
* Carbon::macro('isDayOff', function ($date) {
|
||||
* return $date->isSunday() || $date->isMonday();
|
||||
* });
|
||||
* Carbon::macro('isNotDayOff', function ($date) {
|
||||
* return !$date->isDayOff();
|
||||
* });
|
||||
* if ($someDate->isDayOff()) ...
|
||||
* if ($someDate->isNotDayOff()) ...
|
||||
* // Add 5 not-off days
|
||||
* $count = 5;
|
||||
* while ($someDate->isDayOff() || ($count-- > 0)) {
|
||||
* $someDate->addDay();
|
||||
* }
|
||||
* ```
|
||||
* Set weekend days
|
||||
* @method bool shouldOverflowMonths() Get the month overflow global behavior (can be overridden in specific instances).
|
||||
* @method bool shouldOverflowYears() Get the month overflow global behavior (can be overridden in specific instances).
|
||||
* @method string singularUnit(string $unit) Returns standardized singular of a given singular/plural unit name (in English).
|
||||
* @method Carbon today($tz = null) Create a Carbon instance for today.
|
||||
* @method Carbon tomorrow($tz = null) Create a Carbon instance for tomorrow.
|
||||
* @method string translateTimeString($timeString, $from = null, $to = null, $mode = CarbonInterface::TRANSLATE_ALL) Translate a time string from a locale to an other.
|
||||
* @method string translateWith(\Symfony\Component\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null) Translate using translation string or callback available.
|
||||
* @method void useMonthsOverflow($monthsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
|
||||
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
|
||||
* @method Carbon useStrictMode($strictModeEnabled = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* @method void useYearsOverflow($yearsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
|
||||
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
|
||||
* @method mixed withTestNow($testNow = null, $callback = null) Temporarily sets a static date to be used within the callback.
|
||||
* Using setTestNow to set the date, executing the callback, then
|
||||
* clearing the test instance.
|
||||
* /!\ Use this method for unit tests only.
|
||||
* @method Carbon yesterday($tz = null) Create a Carbon instance for yesterday.
|
||||
*
|
||||
* </autodoc>
|
||||
*/
|
||||
class Factory
|
||||
{
|
||||
protected $className = Carbon::class;
|
||||
|
||||
protected $settings = [];
|
||||
|
||||
public function __construct(array $settings = [], ?string $className = null)
|
||||
{
|
||||
if ($className) {
|
||||
$this->className = $className;
|
||||
}
|
||||
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
public function getClassName()
|
||||
{
|
||||
return $this->className;
|
||||
}
|
||||
|
||||
public function setClassName(string $className)
|
||||
{
|
||||
$this->className = $className;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function className(string $className = null)
|
||||
{
|
||||
return $className === null ? $this->getClassName() : $this->setClassName($className);
|
||||
}
|
||||
|
||||
public function getSettings()
|
||||
{
|
||||
return $this->settings;
|
||||
}
|
||||
|
||||
public function setSettings(array $settings)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function settings(array $settings = null)
|
||||
{
|
||||
return $settings === null ? $this->getSettings() : $this->setSettings($settings);
|
||||
}
|
||||
|
||||
public function mergeSettings(array $settings)
|
||||
{
|
||||
$this->settings = array_merge($this->settings, $settings);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
$method = new ReflectionMethod($this->className, $name);
|
||||
$settings = $this->settings;
|
||||
|
||||
if ($settings && isset($settings['timezone'])) {
|
||||
$tzParameters = array_filter($method->getParameters(), function ($parameter) {
|
||||
return \in_array($parameter->getName(), ['tz', 'timezone'], true);
|
||||
});
|
||||
|
||||
if (isset($arguments[0]) && \in_array($name, ['instance', 'make', 'create', 'parse'], true)) {
|
||||
if ($arguments[0] instanceof DateTimeInterface) {
|
||||
$settings['innerTimezone'] = $settings['timezone'];
|
||||
} elseif (\is_string($arguments[0]) && date_parse($arguments[0])['is_localtime']) {
|
||||
unset($settings['timezone'], $settings['innerTimezone']);
|
||||
}
|
||||
} elseif (\count($tzParameters)) {
|
||||
array_splice($arguments, key($tzParameters), 0, [$settings['timezone']]);
|
||||
unset($settings['timezone']);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->className::$name(...$arguments);
|
||||
|
||||
return $result instanceof CarbonInterface && !empty($settings)
|
||||
? $result->settings($settings)
|
||||
: $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Carbon;
|
||||
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* A factory to generate CarbonImmutable instances with common settings.
|
||||
*
|
||||
* <autodoc generated by `composer phpdoc`>
|
||||
*
|
||||
* @method bool canBeCreatedFromFormat($date, $format) Checks if the (date)time string is in a given format and valid to create a
|
||||
* new instance.
|
||||
* @method CarbonImmutable|false create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) Create a new Carbon instance from a specific date and time.
|
||||
* If any of $year, $month or $day are set to null their now() values will
|
||||
* be used.
|
||||
* If $hour is null it will be set to its now() value and the default
|
||||
* values for $minute and $second will be their now() values.
|
||||
* If $hour is not null then the default values for $minute and $second
|
||||
* will be 0.
|
||||
* @method CarbonImmutable createFromDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to now.
|
||||
* @method CarbonImmutable|false createFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
|
||||
* @method CarbonImmutable|false createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null) Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
|
||||
* @method CarbonImmutable|false createFromLocaleFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific format and a string in a given language.
|
||||
* @method CarbonImmutable|false createFromLocaleIsoFormat($format, $locale, $time, $tz = null) Create a Carbon instance from a specific ISO format and a string in a given language.
|
||||
* @method CarbonImmutable createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null) Create a Carbon instance from just a time. The date portion is set to today.
|
||||
* @method CarbonImmutable createFromTimeString($time, $tz = null) Create a Carbon instance from a time string. The date portion is set to today.
|
||||
* @method CarbonImmutable createFromTimestamp($timestamp, $tz = null) Create a Carbon instance from a timestamp and set the timezone (use default one if not specified).
|
||||
* Timestamp input can be given as int, float or a string containing one or more numbers.
|
||||
* @method CarbonImmutable createFromTimestampMs($timestamp, $tz = null) Create a Carbon instance from a timestamp in milliseconds.
|
||||
* Timestamp input can be given as int, float or a string containing one or more numbers.
|
||||
* @method CarbonImmutable createFromTimestampMsUTC($timestamp) Create a Carbon instance from a timestamp in milliseconds.
|
||||
* Timestamp input can be given as int, float or a string containing one or more numbers.
|
||||
* @method CarbonImmutable createFromTimestampUTC($timestamp) Create a Carbon instance from an timestamp keeping the timezone to UTC.
|
||||
* Timestamp input can be given as int, float or a string containing one or more numbers.
|
||||
* @method CarbonImmutable createMidnightDate($year = null, $month = null, $day = null, $tz = null) Create a Carbon instance from just a date. The time portion is set to midnight.
|
||||
* @method CarbonImmutable|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) Create a new safe Carbon instance from a specific date and time.
|
||||
* If any of $year, $month or $day are set to null their now() values will
|
||||
* be used.
|
||||
* If $hour is null it will be set to its now() value and the default
|
||||
* values for $minute and $second will be their now() values.
|
||||
* If $hour is not null then the default values for $minute and $second
|
||||
* will be 0.
|
||||
* If one of the set values is not valid, an InvalidDateException
|
||||
* will be thrown.
|
||||
* @method CarbonInterface createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null) Create a new Carbon instance from a specific date and time using strict validation.
|
||||
* @method CarbonImmutable disableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* @method CarbonImmutable enableHumanDiffOption($humanDiffOption) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* @method mixed executeWithLocale($locale, $func) Set the current locale to the given, execute the passed function, reset the locale to previous one,
|
||||
* then return the result of the closure (or null if the closure was void).
|
||||
* @method CarbonImmutable fromSerialized($value) Create an instance from a serialized string.
|
||||
* @method void genericMacro($macro, $priority = 0) Register a custom macro.
|
||||
* @method array getAvailableLocales() Returns the list of internally available locales and already loaded custom locales.
|
||||
* (It will ignore custom translator dynamic loading.)
|
||||
* @method Language[] getAvailableLocalesInfo() Returns list of Language object for each available locale. This object allow you to get the ISO name, native
|
||||
* name, region and variant of the locale.
|
||||
* @method array getDays() Get the days of the week
|
||||
* @method string|null getFallbackLocale() Get the fallback locale.
|
||||
* @method array getFormatsToIsoReplacements() List of replacements from date() format to isoFormat().
|
||||
* @method int getHumanDiffOptions() Return default humanDiff() options (merged flags as integer).
|
||||
* @method array getIsoUnits() Returns list of locale units for ISO formatting.
|
||||
* @method CarbonImmutable getLastErrors() {@inheritdoc}
|
||||
* @method string getLocale() Get the current translator locale.
|
||||
* @method callable|null getMacro($name) Get the raw callable macro registered globally for a given name.
|
||||
* @method int getMidDayAt() get midday/noon hour
|
||||
* @method Closure|CarbonImmutable getTestNow() Get the Carbon instance (real or mock) to be returned when a "now"
|
||||
* instance is created.
|
||||
* @method string getTimeFormatByPrecision($unitPrecision) Return a format from H:i to H:i:s.u according to given unit precision.
|
||||
* @method string getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null) Returns raw translation message for a given key.
|
||||
* @method \Symfony\Component\Translation\TranslatorInterface getTranslator() Get the default translator instance in use.
|
||||
* @method int getWeekEndsAt() Get the last day of week
|
||||
* @method int getWeekStartsAt() Get the first day of week
|
||||
* @method array getWeekendDays() Get weekend days
|
||||
* @method bool hasFormat($date, $format) Checks if the (date)time string is in a given format.
|
||||
* @method bool hasFormatWithModifiers($date, $format) Checks if the (date)time string is in a given format.
|
||||
* @method bool hasMacro($name) Checks if macro is registered globally.
|
||||
* @method bool hasRelativeKeywords($time) Determine if a time string will produce a relative date.
|
||||
* @method bool hasTestNow() Determine if there is a valid test instance set. A valid test instance
|
||||
* is anything that is not null.
|
||||
* @method CarbonImmutable instance($date) Create a Carbon instance from a DateTime one.
|
||||
* @method bool isImmutable() Returns true if the current class/instance is immutable.
|
||||
* @method bool isModifiableUnit($unit) Returns true if a property can be changed via setter.
|
||||
* @method bool isMutable() Returns true if the current class/instance is mutable.
|
||||
* @method bool isStrictModeEnabled() Returns true if the strict mode is globally in use, false else.
|
||||
* (It can be overridden in specific instances.)
|
||||
* @method bool localeHasDiffOneDayWords($locale) Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
|
||||
* Support is considered enabled if the 3 words are translated in the given locale.
|
||||
* @method bool localeHasDiffSyntax($locale) Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
|
||||
* Support is considered enabled if the 4 sentences are translated in the given locale.
|
||||
* @method bool localeHasDiffTwoDayWords($locale) Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
|
||||
* Support is considered enabled if the 2 words are translated in the given locale.
|
||||
* @method bool localeHasPeriodSyntax($locale) Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
|
||||
* Support is considered enabled if the 4 sentences are translated in the given locale.
|
||||
* @method bool localeHasShortUnits($locale) Returns true if the given locale is internally supported and has short-units support.
|
||||
* Support is considered enabled if either year, day or hour has a short variant translated.
|
||||
* @method void macro($name, $macro) Register a custom macro.
|
||||
* @method CarbonImmutable|null make($var) Make a Carbon instance from given variable if possible.
|
||||
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
|
||||
* and recurrences). Throw an exception for invalid format, but otherwise return null.
|
||||
* @method CarbonImmutable maxValue() Create a Carbon instance for the greatest supported date.
|
||||
* @method CarbonImmutable minValue() Create a Carbon instance for the lowest supported date.
|
||||
* @method void mixin($mixin) Mix another object into the class.
|
||||
* @method CarbonImmutable now($tz = null) Get a Carbon instance for the current date and time.
|
||||
* @method CarbonImmutable parse($time = null, $tz = null) Create a carbon instance from a string.
|
||||
* This is an alias for the constructor that allows better fluent syntax
|
||||
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
|
||||
* than (new Carbon('Monday next week'))->fn().
|
||||
* @method CarbonImmutable parseFromLocale($time, $locale = null, $tz = null) Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
|
||||
* @method string pluralUnit(string $unit) Returns standardized plural of a given singular/plural unit name (in English).
|
||||
* @method CarbonImmutable|false rawCreateFromFormat($format, $time, $tz = null) Create a Carbon instance from a specific format.
|
||||
* @method CarbonImmutable rawParse($time = null, $tz = null) Create a carbon instance from a string.
|
||||
* This is an alias for the constructor that allows better fluent syntax
|
||||
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
|
||||
* than (new Carbon('Monday next week'))->fn().
|
||||
* @method CarbonImmutable resetMacros() Remove all macros and generic macros.
|
||||
* @method void resetMonthsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
|
||||
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
|
||||
* @method void resetToStringFormat() Reset the format used to the default when type juggling a Carbon instance to a string
|
||||
* @method void resetYearsOverflow() @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
|
||||
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
|
||||
* @method void serializeUsing($callback) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather transform Carbon object before the serialization.
|
||||
* JSON serialize all Carbon instances using the given callback.
|
||||
* @method CarbonImmutable setFallbackLocale($locale) Set the fallback locale.
|
||||
* @method CarbonImmutable setHumanDiffOptions($humanDiffOptions) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* @method bool setLocale($locale) Set the current translator locale and indicate if the source locale file exists.
|
||||
* Pass 'auto' as locale to use closest language from the current LC_TIME locale.
|
||||
* @method void setMidDayAt($hour) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather consider mid-day is always 12pm, then if you need to test if it's an other
|
||||
* hour, test it explicitly:
|
||||
* $date->format('G') == 13
|
||||
* or to set explicitly to a given hour:
|
||||
* $date->setTime(13, 0, 0, 0)
|
||||
* Set midday/noon hour
|
||||
* @method CarbonImmutable setTestNow($testNow = null) Set a Carbon instance (real or mock) to be returned when a "now"
|
||||
* instance is created. The provided instance will be returned
|
||||
* specifically under the following conditions:
|
||||
* - A call to the static now() method, ex. Carbon::now()
|
||||
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
|
||||
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
|
||||
* - When a string containing the desired time is passed to Carbon::parse().
|
||||
* Note the timezone parameter was left out of the examples above and
|
||||
* has no affect as the mock value will be returned regardless of its value.
|
||||
* To clear the test instance call this method using the default
|
||||
* parameter of null.
|
||||
* /!\ Use this method for unit tests only.
|
||||
* @method void setToStringFormat($format) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and
|
||||
* use other method or custom format passed to format() method if you need to dump an other string
|
||||
* format.
|
||||
* Set the default format used when type juggling a Carbon instance to a string
|
||||
* @method void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator) Set the default translator instance to use.
|
||||
* @method CarbonImmutable setUtf8($utf8) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use UTF-8 language packages on every machine.
|
||||
* Set if UTF8 will be used for localized date/time.
|
||||
* @method void setWeekEndsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek
|
||||
* or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the
|
||||
* start of week according to current locale selected and implicitly the end of week.
|
||||
* Set the last day of week
|
||||
* @method void setWeekStartsAt($day) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the
|
||||
* 'first_day_of_week' locale setting to change the start of week according to current locale
|
||||
* selected and implicitly the end of week.
|
||||
* Set the first day of week
|
||||
* @method void setWeekendDays($days) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather consider week-end is always saturday and sunday, and if you have some custom
|
||||
* week-end days to handle, give to those days an other name and create a macro for them:
|
||||
* ```
|
||||
* Carbon::macro('isDayOff', function ($date) {
|
||||
* return $date->isSunday() || $date->isMonday();
|
||||
* });
|
||||
* Carbon::macro('isNotDayOff', function ($date) {
|
||||
* return !$date->isDayOff();
|
||||
* });
|
||||
* if ($someDate->isDayOff()) ...
|
||||
* if ($someDate->isNotDayOff()) ...
|
||||
* // Add 5 not-off days
|
||||
* $count = 5;
|
||||
* while ($someDate->isDayOff() || ($count-- > 0)) {
|
||||
* $someDate->addDay();
|
||||
* }
|
||||
* ```
|
||||
* Set weekend days
|
||||
* @method bool shouldOverflowMonths() Get the month overflow global behavior (can be overridden in specific instances).
|
||||
* @method bool shouldOverflowYears() Get the month overflow global behavior (can be overridden in specific instances).
|
||||
* @method string singularUnit(string $unit) Returns standardized singular of a given singular/plural unit name (in English).
|
||||
* @method CarbonImmutable today($tz = null) Create a Carbon instance for today.
|
||||
* @method CarbonImmutable tomorrow($tz = null) Create a Carbon instance for tomorrow.
|
||||
* @method string translateTimeString($timeString, $from = null, $to = null, $mode = CarbonInterface::TRANSLATE_ALL) Translate a time string from a locale to an other.
|
||||
* @method string translateWith(\Symfony\Component\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null) Translate using translation string or callback available.
|
||||
* @method void useMonthsOverflow($monthsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants
|
||||
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
|
||||
* @method CarbonImmutable useStrictMode($strictModeEnabled = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* @method void useYearsOverflow($yearsOverflow = true) @deprecated To avoid conflict between different third-party libraries, static setters should not be used.
|
||||
* You should rather use the ->settings() method.
|
||||
* Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants
|
||||
* are available for quarters, years, decade, centuries, millennia (singular and plural forms).
|
||||
* @method mixed withTestNow($testNow = null, $callback = null) Temporarily sets a static date to be used within the callback.
|
||||
* Using setTestNow to set the date, executing the callback, then
|
||||
* clearing the test instance.
|
||||
* /!\ Use this method for unit tests only.
|
||||
* @method CarbonImmutable yesterday($tz = null) Create a Carbon instance for yesterday.
|
||||
*
|
||||
* </autodoc>
|
||||
*/
|
||||
class FactoryImmutable extends Factory
|
||||
{
|
||||
protected $className = CarbonImmutable::class;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Unknown default region, use the first alphabetically.
|
||||
*/
|
||||
return require __DIR__.'/aa_DJ.php';
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Ge'ez Frontier Foundation locales@geez.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD.MM.YYYY',
|
||||
],
|
||||
'months' => ['Qunxa Garablu', 'Kudo', 'Ciggilta Kudo', 'Agda Baxisso', 'Caxah Alsa', 'Qasa Dirri', 'Qado Dirri', 'Liiqen', 'Waysu', 'Diteli', 'Ximoli', 'Kaxxa Garablu'],
|
||||
'months_short' => ['qun', 'nah', 'cig', 'agd', 'cax', 'qas', 'qad', 'leq', 'way', 'dit', 'xim', 'kax'],
|
||||
'weekdays' => ['Acaada', 'Etleeni', 'Talaata', 'Arbaqa', 'Kamiisi', 'Gumqata', 'Sabti'],
|
||||
'weekdays_short' => ['aca', 'etl', 'tal', 'arb', 'kam', 'gum', 'sab'],
|
||||
'weekdays_min' => ['aca', 'etl', 'tal', 'arb', 'kam', 'gum', 'sab'],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'meridiem' => ['saaku', 'carra'],
|
||||
|
||||
'year' => ':count gaqambo', // less reliable
|
||||
'y' => ':count gaqambo', // less reliable
|
||||
'a_year' => ':count gaqambo', // less reliable
|
||||
|
||||
'month' => ':count àlsa',
|
||||
'm' => ':count àlsa',
|
||||
'a_month' => ':count àlsa',
|
||||
|
||||
'day' => ':count saaku', // less reliable
|
||||
'd' => ':count saaku', // less reliable
|
||||
'a_day' => ':count saaku', // less reliable
|
||||
|
||||
'hour' => ':count ayti', // less reliable
|
||||
'h' => ':count ayti', // less reliable
|
||||
'a_hour' => ':count ayti', // less reliable
|
||||
]);
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Ge'ez Frontier Foundation locales@geez.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD/MM/YYYY',
|
||||
],
|
||||
'months' => ['Qunxa Garablu', 'Naharsi Kudo', 'Ciggilta Kudo', 'Agda Baxisso', 'Caxah Alsa', 'Qasa Dirri', 'Qado Dirri', 'Leqeeni', 'Waysu', 'Diteli', 'Ximoli', 'Kaxxa Garablu'],
|
||||
'months_short' => ['Qun', 'Nah', 'Cig', 'Agd', 'Cax', 'Qas', 'Qad', 'Leq', 'Way', 'Dit', 'Xim', 'Kax'],
|
||||
'weekdays' => ['Acaada', 'Etleeni', 'Talaata', 'Arbaqa', 'Kamiisi', 'Gumqata', 'Sabti'],
|
||||
'weekdays_short' => ['Aca', 'Etl', 'Tal', 'Arb', 'Kam', 'Gum', 'Sab'],
|
||||
'weekdays_min' => ['Aca', 'Etl', 'Tal', 'Arb', 'Kam', 'Gum', 'Sab'],
|
||||
'first_day_of_week' => 1,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'meridiem' => ['saaku', 'carra'],
|
||||
]);
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Ge'ez Frontier Foundation locales@geez.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD/MM/YYYY',
|
||||
],
|
||||
'months' => ['Qunxa Garablu', 'Naharsi Kudo', 'Ciggilta Kudo', 'Agda Baxisso', 'Caxah Alsa', 'Qasa Dirri', 'Qado Dirri', 'Leqeeni', 'Waysu', 'Diteli', 'Ximoli', 'Kaxxa Garablu'],
|
||||
'months_short' => ['Qun', 'Nah', 'Cig', 'Agd', 'Cax', 'Qas', 'Qad', 'Leq', 'Way', 'Dit', 'Xim', 'Kax'],
|
||||
'weekdays' => ['Naba Sambat', 'Sani', 'Salus', 'Rabuq', 'Camus', 'Jumqata', 'Qunxa Sambat'],
|
||||
'weekdays_short' => ['Nab', 'San', 'Sal', 'Rab', 'Cam', 'Jum', 'Qun'],
|
||||
'weekdays_min' => ['Nab', 'San', 'Sal', 'Rab', 'Cam', 'Jum', 'Qun'],
|
||||
'first_day_of_week' => 1,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'meridiem' => ['saaku', 'carra'],
|
||||
]);
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Ge'ez Frontier Foundation locales@geez.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD/MM/YYYY',
|
||||
],
|
||||
'months' => ['Qunxa Garablu', 'Kudo', 'Ciggilta Kudo', 'Agda Baxisso', 'Caxah Alsa', 'Qasa Dirri', 'Qado Dirri', 'Liiqen', 'Waysu', 'Diteli', 'Ximoli', 'Kaxxa Garablu'],
|
||||
'months_short' => ['Qun', 'Kud', 'Cig', 'Agd', 'Cax', 'Qas', 'Qad', 'Leq', 'Way', 'Dit', 'Xim', 'Kax'],
|
||||
'weekdays' => ['Acaada', 'Etleeni', 'Talaata', 'Arbaqa', 'Kamiisi', 'Gumqata', 'Sabti'],
|
||||
'weekdays_short' => ['Aca', 'Etl', 'Tal', 'Arb', 'Kam', 'Gum', 'Sab'],
|
||||
'weekdays_min' => ['Aca', 'Etl', 'Tal', 'Arb', 'Kam', 'Gum', 'Sab'],
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'meridiem' => ['saaku', 'carra'],
|
||||
]);
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - François B
|
||||
* - JD Isaacks
|
||||
* - Pierre du Plessis
|
||||
*/
|
||||
return [
|
||||
'year' => ':count jaar',
|
||||
'a_year' => '\'n jaar|:count jaar',
|
||||
'y' => ':count j.',
|
||||
'month' => ':count maand|:count maande',
|
||||
'a_month' => '\'n maand|:count maande',
|
||||
'm' => ':count maa.',
|
||||
'week' => ':count week|:count weke',
|
||||
'a_week' => '\'n week|:count weke',
|
||||
'w' => ':count w.',
|
||||
'day' => ':count dag|:count dae',
|
||||
'a_day' => '\'n dag|:count dae',
|
||||
'd' => ':count d.',
|
||||
'hour' => ':count uur',
|
||||
'a_hour' => '\'n uur|:count uur',
|
||||
'h' => ':count u.',
|
||||
'minute' => ':count minuut|:count minute',
|
||||
'a_minute' => '\'n minuut|:count minute',
|
||||
'min' => ':count min.',
|
||||
'second' => ':count sekond|:count sekondes',
|
||||
'a_second' => '\'n paar sekondes|:count sekondes',
|
||||
's' => ':count s.',
|
||||
'ago' => ':time gelede',
|
||||
'from_now' => 'oor :time',
|
||||
'after' => ':time na',
|
||||
'before' => ':time voor',
|
||||
'diff_now' => 'Nou',
|
||||
'diff_today' => 'Vandag',
|
||||
'diff_today_regexp' => 'Vandag(?:\\s+om)?',
|
||||
'diff_yesterday' => 'Gister',
|
||||
'diff_yesterday_regexp' => 'Gister(?:\\s+om)?',
|
||||
'diff_tomorrow' => 'Môre',
|
||||
'diff_tomorrow_regexp' => 'Môre(?:\\s+om)?',
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'DD/MM/YYYY',
|
||||
'LL' => 'D MMMM YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd, D MMMM YYYY HH:mm',
|
||||
],
|
||||
'calendar' => [
|
||||
'sameDay' => '[Vandag om] LT',
|
||||
'nextDay' => '[Môre om] LT',
|
||||
'nextWeek' => 'dddd [om] LT',
|
||||
'lastDay' => '[Gister om] LT',
|
||||
'lastWeek' => '[Laas] dddd [om] LT',
|
||||
'sameElse' => 'L',
|
||||
],
|
||||
'ordinal' => function ($number) {
|
||||
return $number.(($number === 1 || $number === 8 || $number >= 20) ? 'ste' : 'de');
|
||||
},
|
||||
'meridiem' => ['VM', 'NM'],
|
||||
'months' => ['Januarie', 'Februarie', 'Maart', 'April', 'Mei', 'Junie', 'Julie', 'Augustus', 'September', 'Oktober', 'November', 'Desember'],
|
||||
'months_short' => ['Jan', 'Feb', 'Mrt', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'],
|
||||
'weekdays' => ['Sondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrydag', 'Saterdag'],
|
||||
'weekdays_short' => ['Son', 'Maa', 'Din', 'Woe', 'Don', 'Vry', 'Sat'],
|
||||
'weekdays_min' => ['So', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Sa'],
|
||||
'first_day_of_week' => 1,
|
||||
'day_of_first_week_of_year' => 4,
|
||||
'list' => [', ', ' en '],
|
||||
];
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/af.php', [
|
||||
'meridiem' => ['v', 'n'],
|
||||
'weekdays' => ['Sondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrydag', 'Saterdag'],
|
||||
'weekdays_short' => ['So.', 'Ma.', 'Di.', 'Wo.', 'Do.', 'Vr.', 'Sa.'],
|
||||
'weekdays_min' => ['So.', 'Ma.', 'Di.', 'Wo.', 'Do.', 'Vr.', 'Sa.'],
|
||||
'months' => ['Januarie', 'Februarie', 'Maart', 'April', 'Mei', 'Junie', 'Julie', 'Augustus', 'September', 'Oktober', 'November', 'Desember'],
|
||||
'months_short' => ['Jan.', 'Feb.', 'Mrt.', 'Apr.', 'Mei', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Okt.', 'Nov.', 'Des.'],
|
||||
'first_day_of_week' => 1,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'YYYY-MM-DD',
|
||||
'LL' => 'DD MMM YYYY',
|
||||
'LLL' => 'DD MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd, DD MMMM YYYY HH:mm',
|
||||
],
|
||||
]);
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return require __DIR__.'/af.php';
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'meridiem' => ['a.g', 'a.k'],
|
||||
'weekdays' => ['tsuʔntsɨ', 'tsuʔukpà', 'tsuʔughɔe', 'tsuʔutɔ̀mlò', 'tsuʔumè', 'tsuʔughɨ̂m', 'tsuʔndzɨkɔʔɔ'],
|
||||
'weekdays_short' => ['nts', 'kpa', 'ghɔ', 'tɔm', 'ume', 'ghɨ', 'dzk'],
|
||||
'weekdays_min' => ['nts', 'kpa', 'ghɔ', 'tɔm', 'ume', 'ghɨ', 'dzk'],
|
||||
'months' => ['ndzɔ̀ŋɔ̀nùm', 'ndzɔ̀ŋɔ̀kƗ̀zùʔ', 'ndzɔ̀ŋɔ̀tƗ̀dʉ̀ghà', 'ndzɔ̀ŋɔ̀tǎafʉ̄ghā', 'ndzɔ̀ŋèsèe', 'ndzɔ̀ŋɔ̀nzùghò', 'ndzɔ̀ŋɔ̀dùmlo', 'ndzɔ̀ŋɔ̀kwîfɔ̀e', 'ndzɔ̀ŋɔ̀tƗ̀fʉ̀ghàdzughù', 'ndzɔ̀ŋɔ̀ghǔuwelɔ̀m', 'ndzɔ̀ŋɔ̀chwaʔàkaa wo', 'ndzɔ̀ŋèfwòo'],
|
||||
'months_short' => ['nùm', 'kɨz', 'tɨd', 'taa', 'see', 'nzu', 'dum', 'fɔe', 'dzu', 'lɔm', 'kaa', 'fwo'],
|
||||
'first_day_of_week' => 1,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'D/M/YYYY',
|
||||
'LL' => 'D MMM, YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd D MMMM YYYY HH:mm',
|
||||
],
|
||||
]);
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Unknown default region, use the first alphabetically.
|
||||
*/
|
||||
return require __DIR__.'/agr_PE.php';
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - somosazucar.org libc-alpha@sourceware.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD/MM/YY',
|
||||
],
|
||||
'months' => ['Petsatin', 'Kupitin', 'Uyaitin', 'Tayutin', 'Kegketin', 'Tegmatin', 'Kuntutin', 'Yagkujutin', 'Daiktatin', 'Ipamtatin', 'Shinutin', 'Sakamtin'],
|
||||
'months_short' => ['Pet', 'Kup', 'Uya', 'Tay', 'Keg', 'Teg', 'Kun', 'Yag', 'Dait', 'Ipam', 'Shin', 'Sak'],
|
||||
'weekdays' => ['Tuntuamtin', 'Achutin', 'Kugkuktin', 'Saketin', 'Shimpitin', 'Imaptin', 'Bataetin'],
|
||||
'weekdays_short' => ['Tun', 'Ach', 'Kug', 'Sak', 'Shim', 'Im', 'Bat'],
|
||||
'weekdays_min' => ['Tun', 'Ach', 'Kug', 'Sak', 'Shim', 'Im', 'Bat'],
|
||||
'first_day_of_week' => 0,
|
||||
'day_of_first_week_of_year' => 7,
|
||||
'meridiem' => ['VM', 'NM'],
|
||||
|
||||
'year' => ':count yaya', // less reliable
|
||||
'y' => ':count yaya', // less reliable
|
||||
'a_year' => ':count yaya', // less reliable
|
||||
|
||||
'month' => ':count nantu', // less reliable
|
||||
'm' => ':count nantu', // less reliable
|
||||
'a_month' => ':count nantu', // less reliable
|
||||
|
||||
'day' => ':count nayaim', // less reliable
|
||||
'd' => ':count nayaim', // less reliable
|
||||
'a_day' => ':count nayaim', // less reliable
|
||||
|
||||
'hour' => ':count kuwiš', // less reliable
|
||||
'h' => ':count kuwiš', // less reliable
|
||||
'a_hour' => ':count kuwiš', // less reliable
|
||||
]);
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Unknown default region, use the first alphabetically.
|
||||
*/
|
||||
return require __DIR__.'/ak_GH.php';
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Sugar Labs // OLPC sugarlabs.org libc-alpha@sourceware.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'formats' => [
|
||||
'L' => 'YYYY/MM/DD',
|
||||
],
|
||||
'months' => ['Sanda-Ɔpɛpɔn', 'Kwakwar-Ɔgyefuo', 'Ebɔw-Ɔbenem', 'Ebɔbira-Oforisuo', 'Esusow Aketseaba-Kɔtɔnimba', 'Obirade-Ayɛwohomumu', 'Ayɛwoho-Kitawonsa', 'Difuu-Ɔsandaa', 'Fankwa-Ɛbɔ', 'Ɔbɛsɛ-Ahinime', 'Ɔberɛfɛw-Obubuo', 'Mumu-Ɔpɛnimba'],
|
||||
'months_short' => ['S-Ɔ', 'K-Ɔ', 'E-Ɔ', 'E-O', 'E-K', 'O-A', 'A-K', 'D-Ɔ', 'F-Ɛ', 'Ɔ-A', 'Ɔ-O', 'M-Ɔ'],
|
||||
'weekdays' => ['Kwesida', 'Dwowda', 'Benada', 'Wukuda', 'Yawda', 'Fida', 'Memeneda'],
|
||||
'weekdays_short' => ['Kwe', 'Dwo', 'Ben', 'Wuk', 'Yaw', 'Fia', 'Mem'],
|
||||
'weekdays_min' => ['Kwe', 'Dwo', 'Ben', 'Wuk', 'Yaw', 'Fia', 'Mem'],
|
||||
'first_day_of_week' => 1,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'meridiem' => ['AN', 'EW'],
|
||||
|
||||
'year' => ':count afe',
|
||||
'y' => ':count afe',
|
||||
'a_year' => ':count afe',
|
||||
|
||||
'month' => ':count bosume',
|
||||
'm' => ':count bosume',
|
||||
'a_month' => ':count bosume',
|
||||
|
||||
'day' => ':count ɛda',
|
||||
'd' => ':count ɛda',
|
||||
'a_day' => ':count ɛda',
|
||||
]);
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Unknown default region, use the first alphabetically.
|
||||
*/
|
||||
return require __DIR__.'/am_ET.php';
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Ge'ez Frontier Foundation locales@geez.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD/MM/YYYY',
|
||||
],
|
||||
'months' => ['ጃንዩወሪ', 'ፌብሩወሪ', 'ማርች', 'ኤፕሪል', 'ሜይ', 'ጁን', 'ጁላይ', 'ኦገስት', 'ሴፕቴምበር', 'ኦክቶበር', 'ኖቬምበር', 'ዲሴምበር'],
|
||||
'months_short' => ['ጃንዩ', 'ፌብሩ', 'ማርች', 'ኤፕረ', 'ሜይ ', 'ጁን ', 'ጁላይ', 'ኦገስ', 'ሴፕቴ', 'ኦክተ', 'ኖቬም', 'ዲሴም'],
|
||||
'weekdays' => ['እሑድ', 'ሰኞ', 'ማክሰኞ', 'ረቡዕ', 'ሐሙስ', 'ዓርብ', 'ቅዳሜ'],
|
||||
'weekdays_short' => ['እሑድ', 'ሰኞ ', 'ማክሰ', 'ረቡዕ', 'ሐሙስ', 'ዓርብ', 'ቅዳሜ'],
|
||||
'weekdays_min' => ['እሑድ', 'ሰኞ ', 'ማክሰ', 'ረቡዕ', 'ሐሙስ', 'ዓርብ', 'ቅዳሜ'],
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'meridiem' => ['ጡዋት', 'ከሰዓት'],
|
||||
|
||||
'year' => ':count አመት',
|
||||
'y' => ':count አመት',
|
||||
'a_year' => ':count አመት',
|
||||
|
||||
'month' => ':count ወር',
|
||||
'm' => ':count ወር',
|
||||
'a_month' => ':count ወር',
|
||||
|
||||
'week' => ':count ሳምንት',
|
||||
'w' => ':count ሳምንት',
|
||||
'a_week' => ':count ሳምንት',
|
||||
|
||||
'day' => ':count ቀን',
|
||||
'd' => ':count ቀን',
|
||||
'a_day' => ':count ቀን',
|
||||
|
||||
'hour' => ':count ሰዓት',
|
||||
'h' => ':count ሰዓት',
|
||||
'a_hour' => ':count ሰዓት',
|
||||
|
||||
'minute' => ':count ደቂቃ',
|
||||
'min' => ':count ደቂቃ',
|
||||
'a_minute' => ':count ደቂቃ',
|
||||
|
||||
'second' => ':count ሴኮንድ',
|
||||
's' => ':count ሴኮንድ',
|
||||
'a_second' => ':count ሴኮንድ',
|
||||
|
||||
'ago' => 'ከ:time በፊት',
|
||||
'from_now' => 'በ:time ውስጥ',
|
||||
]);
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Unknown default region, use the first alphabetically.
|
||||
*/
|
||||
return require __DIR__.'/an_ES.php';
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Softaragones Jordi Mallach Pérez, Juan Pablo Martínez bug-glibc-locales@gnu.org, softaragones@softaragones.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD/MM/YYYY',
|
||||
],
|
||||
'months' => ['chinero', 'febrero', 'marzo', 'abril', 'mayo', 'chunyo', 'chuliol', 'agosto', 'setiembre', 'octubre', 'noviembre', 'aviento'],
|
||||
'months_short' => ['chi', 'feb', 'mar', 'abr', 'may', 'chn', 'chl', 'ago', 'set', 'oct', 'nov', 'avi'],
|
||||
'weekdays' => ['domingo', 'luns', 'martes', 'mierques', 'chueves', 'viernes', 'sabado'],
|
||||
'weekdays_short' => ['dom', 'lun', 'mar', 'mie', 'chu', 'vie', 'sab'],
|
||||
'weekdays_min' => ['dom', 'lun', 'mar', 'mie', 'chu', 'vie', 'sab'],
|
||||
'first_day_of_week' => 1,
|
||||
'day_of_first_week_of_year' => 4,
|
||||
|
||||
'year' => ':count año',
|
||||
'y' => ':count año',
|
||||
'a_year' => ':count año',
|
||||
|
||||
'month' => ':count mes',
|
||||
'm' => ':count mes',
|
||||
'a_month' => ':count mes',
|
||||
|
||||
'week' => ':count semana',
|
||||
'w' => ':count semana',
|
||||
'a_week' => ':count semana',
|
||||
|
||||
'day' => ':count día',
|
||||
'd' => ':count día',
|
||||
'a_day' => ':count día',
|
||||
|
||||
'hour' => ':count reloch', // less reliable
|
||||
'h' => ':count reloch', // less reliable
|
||||
'a_hour' => ':count reloch', // less reliable
|
||||
|
||||
'minute' => ':count minuto',
|
||||
'min' => ':count minuto',
|
||||
'a_minute' => ':count minuto',
|
||||
|
||||
'second' => ':count segundo',
|
||||
's' => ':count segundo',
|
||||
'a_second' => ':count segundo',
|
||||
]);
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Unknown default region, use the first alphabetically.
|
||||
*/
|
||||
return require __DIR__.'/anp_IN.php';
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - bhashaghar@googlegroups.com
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'formats' => [
|
||||
'L' => 'D/M/YY',
|
||||
],
|
||||
'months' => ['जनवरी', 'फरवरी', 'मार्च', 'अप्रैल', 'मई', 'जून', 'जुलाई', 'अगस्त', 'सितंबर', 'अक्टूबर', 'नवंबर', 'दिसंबर"'],
|
||||
'months_short' => ['जनवरी', 'फरवरी', 'मार्च', 'अप्रैल', 'मई', 'जून', 'जुलाई', 'अगस्त', 'सितंबर', 'अक्टूबर', 'नवंबर', 'दिसंबर'],
|
||||
'weekdays' => ['रविवार', 'सोमवार', 'मंगलवार', 'बुधवार', 'बृहस्पतिवार', 'शुक्रवार', 'शनिवार'],
|
||||
'weekdays_short' => ['रवि', 'सोम', 'मंगल', 'बुध', 'बृहस्पति', 'शुक्र', 'शनि'],
|
||||
'weekdays_min' => ['रवि', 'सोम', 'मंगल', 'बुध', 'बृहस्पति', 'शुक्र', 'शनि'],
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'meridiem' => ['पूर्वाह्न', 'अपराह्न'],
|
||||
]);
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Atef Ben Ali (atefBB)
|
||||
* - Ibrahim AshShohail
|
||||
* - MLTDev
|
||||
* - Mohamed Sabil (mohamedsabil83)
|
||||
* - Yazan Alnugnugh (yazan-alnugnugh)
|
||||
*/
|
||||
$months = [
|
||||
'يناير',
|
||||
'فبراير',
|
||||
'مارس',
|
||||
'أبريل',
|
||||
'مايو',
|
||||
'يونيو',
|
||||
'يوليو',
|
||||
'أغسطس',
|
||||
'سبتمبر',
|
||||
'أكتوبر',
|
||||
'نوفمبر',
|
||||
'ديسمبر',
|
||||
];
|
||||
|
||||
return [
|
||||
'year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'a_year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'a_month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'a_week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'a_day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'a_hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'a_minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'a_second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'ago' => 'منذ :time',
|
||||
'from_now' => ':time من الآن',
|
||||
'after' => 'بعد :time',
|
||||
'before' => 'قبل :time',
|
||||
'diff_now' => 'الآن',
|
||||
'diff_today' => 'اليوم',
|
||||
'diff_today_regexp' => 'اليوم(?:\\s+عند)?(?:\\s+الساعة)?',
|
||||
'diff_yesterday' => 'أمس',
|
||||
'diff_yesterday_regexp' => 'أمس(?:\\s+عند)?(?:\\s+الساعة)?',
|
||||
'diff_tomorrow' => 'غداً',
|
||||
'diff_tomorrow_regexp' => 'غدًا(?:\\s+عند)?(?:\\s+الساعة)?',
|
||||
'diff_before_yesterday' => 'قبل الأمس',
|
||||
'diff_after_tomorrow' => 'بعد غد',
|
||||
'period_recurrences' => implode('|', ['{0}مرة', '{1}مرة', '{2}:count مرتين', ']2,11[:count مرات', ']10,Inf[:count مرة']),
|
||||
'period_interval' => 'كل :interval',
|
||||
'period_start_date' => 'من :date',
|
||||
'period_end_date' => 'إلى :date',
|
||||
'months' => $months,
|
||||
'months_short' => $months,
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
'weekdays_min' => ['ح', 'اث', 'ثل', 'أر', 'خم', 'ج', 'س'],
|
||||
'list' => ['، ', ' و '],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'D/M/YYYY',
|
||||
'LL' => 'D MMMM YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd D MMMM YYYY HH:mm',
|
||||
],
|
||||
'calendar' => [
|
||||
'sameDay' => '[اليوم عند الساعة] LT',
|
||||
'nextDay' => '[غدًا عند الساعة] LT',
|
||||
'nextWeek' => 'dddd [عند الساعة] LT',
|
||||
'lastDay' => '[أمس عند الساعة] LT',
|
||||
'lastWeek' => 'dddd [عند الساعة] LT',
|
||||
'sameElse' => 'L',
|
||||
],
|
||||
'meridiem' => ['ص', 'م'],
|
||||
'weekend' => [5, 6],
|
||||
];
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
|
||||
'months_short' => ['ينا', 'فبر', 'مار', 'أبر', 'ماي', 'يون', 'يول', 'أغس', 'سبت', 'أكت', 'نوف', 'ديس'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت '],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
|
||||
'months_short' => ['ينا', 'فبر', 'مار', 'أبر', 'ماي', 'يون', 'يول', 'أغس', 'سبت', 'أكت', 'نوف', 'ديس'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
]);
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Authors:
|
||||
* - Josh Soref
|
||||
* - Noureddine LOUAHEDJ
|
||||
* - JD Isaacks
|
||||
* - Atef Ben Ali (atefBB)
|
||||
* - Mohamed Sabil (mohamedsabil83)
|
||||
*/
|
||||
$months = [
|
||||
'جانفي',
|
||||
'فيفري',
|
||||
'مارس',
|
||||
'أفريل',
|
||||
'ماي',
|
||||
'جوان',
|
||||
'جويلية',
|
||||
'أوت',
|
||||
'سبتمبر',
|
||||
'أكتوبر',
|
||||
'نوفمبر',
|
||||
'ديسمبر',
|
||||
];
|
||||
|
||||
return [
|
||||
'year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'a_year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'a_month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'a_week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'a_day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'a_hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'a_minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'a_second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'ago' => 'منذ :time',
|
||||
'from_now' => 'في :time',
|
||||
'after' => 'بعد :time',
|
||||
'before' => 'قبل :time',
|
||||
'diff_now' => 'الآن',
|
||||
'diff_today' => 'اليوم',
|
||||
'diff_today_regexp' => 'اليوم(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_yesterday' => 'أمس',
|
||||
'diff_yesterday_regexp' => 'أمس(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_tomorrow' => 'غداً',
|
||||
'diff_tomorrow_regexp' => 'غدا(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_before_yesterday' => 'قبل الأمس',
|
||||
'diff_after_tomorrow' => 'بعد غد',
|
||||
'period_recurrences' => implode('|', ['{0}مرة', '{1}مرة', '{2}:count مرتين', ']2,11[:count مرات', ']10,Inf[:count مرة']),
|
||||
'period_interval' => 'كل :interval',
|
||||
'period_start_date' => 'من :date',
|
||||
'period_end_date' => 'إلى :date',
|
||||
'months' => $months,
|
||||
'months_short' => $months,
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
'weekdays_min' => ['أح', 'إث', 'ثلا', 'أر', 'خم', 'جم', 'سب'],
|
||||
'list' => ['، ', ' و '],
|
||||
'first_day_of_week' => 0,
|
||||
'day_of_first_week_of_year' => 4,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'DD/MM/YYYY',
|
||||
'LL' => 'D MMMM YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd D MMMM YYYY HH:mm',
|
||||
],
|
||||
'calendar' => [
|
||||
'sameDay' => '[اليوم على الساعة] LT',
|
||||
'nextDay' => '[غدا على الساعة] LT',
|
||||
'nextWeek' => 'dddd [على الساعة] LT',
|
||||
'lastDay' => '[أمس على الساعة] LT',
|
||||
'lastWeek' => 'dddd [على الساعة] LT',
|
||||
'sameElse' => 'L',
|
||||
],
|
||||
'meridiem' => ['ص', 'م'],
|
||||
];
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
|
||||
'months_short' => ['ينا', 'فبر', 'مار', 'أبر', 'ماي', 'يون', 'يول', 'أغس', 'سبت', 'أكت', 'نوف', 'ديس'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
]);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
]);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
]);
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'D/M/YY',
|
||||
],
|
||||
'months' => ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
|
||||
'months_short' => ['ينا', 'فبر', 'مار', 'أبر', 'ماي', 'يون', 'يول', 'أغس', 'سبت', 'أكت', 'نوف', 'ديس'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'أيار', 'حزيران', 'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
|
||||
'months_short' => ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'أيار', 'حزيران', 'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'أيار', 'حزيران', 'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
|
||||
'months_short' => ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'أيار', 'حزيران', 'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
]);
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Authors:
|
||||
* - Josh Soref
|
||||
* - Nusret Parlak
|
||||
* - JD Isaacks
|
||||
* - Atef Ben Ali (atefBB)
|
||||
* - Mohamed Sabil (mohamedsabil83)
|
||||
*/
|
||||
$months = [
|
||||
'يناير',
|
||||
'فبراير',
|
||||
'مارس',
|
||||
'أبريل',
|
||||
'ماي',
|
||||
'يونيو',
|
||||
'يوليوز',
|
||||
'غشت',
|
||||
'شتنبر',
|
||||
'أكتوبر',
|
||||
'نونبر',
|
||||
'دجنبر',
|
||||
];
|
||||
|
||||
return [
|
||||
'year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'a_year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'a_month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'a_week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'a_day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'a_hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'a_minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'a_second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'ago' => 'منذ :time',
|
||||
'from_now' => 'في :time',
|
||||
'after' => 'بعد :time',
|
||||
'before' => 'قبل :time',
|
||||
'diff_now' => 'الآن',
|
||||
'diff_today' => 'اليوم',
|
||||
'diff_today_regexp' => 'اليوم(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_yesterday' => 'أمس',
|
||||
'diff_yesterday_regexp' => 'أمس(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_tomorrow' => 'غداً',
|
||||
'diff_tomorrow_regexp' => 'غدا(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_before_yesterday' => 'قبل الأمس',
|
||||
'diff_after_tomorrow' => 'بعد غد',
|
||||
'period_recurrences' => implode('|', ['{0}مرة', '{1}مرة', '{2}:count مرتين', ']2,11[:count مرات', ']10,Inf[:count مرة']),
|
||||
'period_interval' => 'كل :interval',
|
||||
'period_start_date' => 'من :date',
|
||||
'period_end_date' => 'إلى :date',
|
||||
'months' => $months,
|
||||
'months_short' => $months,
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'list' => ['، ', ' و '],
|
||||
'first_day_of_week' => 0,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'DD/MM/YYYY',
|
||||
'LL' => 'D MMMM YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd D MMMM YYYY HH:mm',
|
||||
],
|
||||
'calendar' => [
|
||||
'sameDay' => '[اليوم على الساعة] LT',
|
||||
'nextDay' => '[غدا على الساعة] LT',
|
||||
'nextWeek' => 'dddd [على الساعة] LT',
|
||||
'lastDay' => '[أمس على الساعة] LT',
|
||||
'lastWeek' => 'dddd [على الساعة] LT',
|
||||
'sameElse' => 'L',
|
||||
],
|
||||
'meridiem' => ['ص', 'م'],
|
||||
'weekend' => [5, 6],
|
||||
];
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'أيار', 'حزيران', 'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
|
||||
'months_short' => ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'أيار', 'حزيران', 'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 1,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Atef Ben Ali (atefBB)
|
||||
* - Ibrahim AshShohail
|
||||
* - MLTDev
|
||||
*/
|
||||
|
||||
$months = [
|
||||
'يناير',
|
||||
'فبراير',
|
||||
'مارس',
|
||||
'أبريل',
|
||||
'مايو',
|
||||
'يونيو',
|
||||
'يوليو',
|
||||
'أغسطس',
|
||||
'سبتمبر',
|
||||
'أكتوبر',
|
||||
'نوفمبر',
|
||||
'ديسمبر',
|
||||
];
|
||||
|
||||
return [
|
||||
'year' => implode('|', [':count سنة', 'سنة', 'سنتين', ':count سنوات', ':count سنة']),
|
||||
'a_year' => implode('|', [':count سنة', 'سنة', 'سنتين', ':count سنوات', ':count سنة']),
|
||||
'month' => implode('|', [':count شهر', 'شهر', 'شهرين', ':count أشهر', ':count شهر']),
|
||||
'a_month' => implode('|', [':count شهر', 'شهر', 'شهرين', ':count أشهر', ':count شهر']),
|
||||
'week' => implode('|', [':count أسبوع', 'أسبوع', 'أسبوعين', ':count أسابيع', ':count أسبوع']),
|
||||
'a_week' => implode('|', [':count أسبوع', 'أسبوع', 'أسبوعين', ':count أسابيع', ':count أسبوع']),
|
||||
'day' => implode('|', [':count يوم', 'يوم', 'يومين', ':count أيام', ':count يوم']),
|
||||
'a_day' => implode('|', [':count يوم', 'يوم', 'يومين', ':count أيام', ':count يوم']),
|
||||
'hour' => implode('|', [':count ساعة', 'ساعة', 'ساعتين', ':count ساعات', ':count ساعة']),
|
||||
'a_hour' => implode('|', [':count ساعة', 'ساعة', 'ساعتين', ':count ساعات', ':count ساعة']),
|
||||
'minute' => implode('|', [':count دقيقة', 'دقيقة', 'دقيقتين', ':count دقائق', ':count دقيقة']),
|
||||
'a_minute' => implode('|', [':count دقيقة', 'دقيقة', 'دقيقتين', ':count دقائق', ':count دقيقة']),
|
||||
'second' => implode('|', [':count ثانية', 'ثانية', 'ثانيتين', ':count ثواني', ':count ثانية']),
|
||||
'a_second' => implode('|', [':count ثانية', 'ثانية', 'ثانيتين', ':count ثواني', ':count ثانية']),
|
||||
'ago' => 'منذ :time',
|
||||
'from_now' => ':time من الآن',
|
||||
'after' => 'بعد :time',
|
||||
'before' => 'قبل :time',
|
||||
'diff_now' => 'الآن',
|
||||
'diff_today' => 'اليوم',
|
||||
'diff_today_regexp' => 'اليوم(?:\\s+عند)?(?:\\s+الساعة)?',
|
||||
'diff_yesterday' => 'أمس',
|
||||
'diff_yesterday_regexp' => 'أمس(?:\\s+عند)?(?:\\s+الساعة)?',
|
||||
'diff_tomorrow' => 'غداً',
|
||||
'diff_tomorrow_regexp' => 'غدًا(?:\\s+عند)?(?:\\s+الساعة)?',
|
||||
'diff_before_yesterday' => 'قبل الأمس',
|
||||
'diff_after_tomorrow' => 'بعد غد',
|
||||
'period_recurrences' => implode('|', ['مرة', 'مرة', ':count مرتين', ':count مرات', ':count مرة']),
|
||||
'period_interval' => 'كل :interval',
|
||||
'period_start_date' => 'من :date',
|
||||
'period_end_date' => 'إلى :date',
|
||||
'months' => $months,
|
||||
'months_short' => $months,
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
'weekdays_min' => ['ح', 'اث', 'ثل', 'أر', 'خم', 'ج', 'س'],
|
||||
'list' => ['، ', ' و '],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'D/M/YYYY',
|
||||
'LL' => 'D MMMM YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd D MMMM YYYY HH:mm',
|
||||
],
|
||||
'calendar' => [
|
||||
'sameDay' => '[اليوم عند الساعة] LT',
|
||||
'nextDay' => '[غدًا عند الساعة] LT',
|
||||
'nextWeek' => 'dddd [عند الساعة] LT',
|
||||
'lastDay' => '[أمس عند الساعة] LT',
|
||||
'lastWeek' => 'dddd [عند الساعة] LT',
|
||||
'sameElse' => 'L',
|
||||
],
|
||||
'meridiem' => ['ص', 'م'],
|
||||
'weekend' => [5, 6],
|
||||
];
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Authors:
|
||||
* - Josh Soref
|
||||
* - JD Isaacks
|
||||
* - Atef Ben Ali (atefBB)
|
||||
* - Mohamed Sabil (mohamedsabil83)
|
||||
*/
|
||||
$months = [
|
||||
'يناير',
|
||||
'فبراير',
|
||||
'مارس',
|
||||
'أبريل',
|
||||
'ماي',
|
||||
'يونيو',
|
||||
'يوليوز',
|
||||
'غشت',
|
||||
'شتنبر',
|
||||
'أكتوبر',
|
||||
'نونبر',
|
||||
'دجنبر',
|
||||
];
|
||||
|
||||
return [
|
||||
'year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'a_year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'a_month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'a_week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'a_day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'a_hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'a_minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'a_second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'ago' => 'منذ :time',
|
||||
'from_now' => 'في :time',
|
||||
'after' => 'بعد :time',
|
||||
'before' => 'قبل :time',
|
||||
'diff_now' => 'الآن',
|
||||
'diff_today' => 'اليوم',
|
||||
'diff_today_regexp' => 'اليوم(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_yesterday' => 'أمس',
|
||||
'diff_yesterday_regexp' => 'أمس(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_tomorrow' => 'غداً',
|
||||
'diff_tomorrow_regexp' => 'غدا(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_before_yesterday' => 'قبل الأمس',
|
||||
'diff_after_tomorrow' => 'بعد غد',
|
||||
'period_recurrences' => implode('|', ['{0}مرة', '{1}مرة', '{2}:count مرتين', ']2,11[:count مرات', ']10,Inf[:count مرة']),
|
||||
'period_interval' => 'كل :interval',
|
||||
'period_start_date' => 'من :date',
|
||||
'period_end_date' => 'إلى :date',
|
||||
'months' => $months,
|
||||
'months_short' => $months,
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'list' => ['، ', ' و '],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'DD/MM/YYYY',
|
||||
'LL' => 'D MMMM YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd D MMMM YYYY HH:mm',
|
||||
],
|
||||
'calendar' => [
|
||||
'sameDay' => '[اليوم على الساعة] LT',
|
||||
'nextDay' => '[غدا على الساعة] LT',
|
||||
'nextWeek' => 'dddd [على الساعة] LT',
|
||||
'lastDay' => '[أمس على الساعة] LT',
|
||||
'lastWeek' => 'dddd [على الساعة] LT',
|
||||
'sameElse' => 'L',
|
||||
],
|
||||
'meridiem' => ['ص', 'م'],
|
||||
'weekend' => [5, 6],
|
||||
];
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
]);
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
|
||||
'months_short' => ['ينا', 'فبر', 'مار', 'أبر', 'ماي', 'يون', 'يول', 'أغس', 'سبت', 'أكت', 'نوف', 'ديس'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
]);
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
|
||||
'months_short' => ['ينا', 'فبر', 'مار', 'أبر', 'ماي', 'يون', 'يول', 'أغس', 'سبت', 'أكت', 'نوف', 'ديس'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Authors:
|
||||
* - Josh Soref
|
||||
* - JD Isaacks
|
||||
* - Atef Ben Ali (atefBB)
|
||||
* - Mohamed Sabil (mohamedsabil83)
|
||||
*/
|
||||
$months = [
|
||||
'يناير',
|
||||
'فبراير',
|
||||
'مارس',
|
||||
'أبريل',
|
||||
'مايو',
|
||||
'يونيو',
|
||||
'يوليو',
|
||||
'أغسطس',
|
||||
'سبتمبر',
|
||||
'أكتوبر',
|
||||
'نوفمبر',
|
||||
'ديسمبر',
|
||||
];
|
||||
|
||||
return [
|
||||
'year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'a_year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'a_month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'a_week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'a_day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'a_hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'a_minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'a_second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'ago' => 'منذ :time',
|
||||
'from_now' => 'في :time',
|
||||
'after' => 'بعد :time',
|
||||
'before' => 'قبل :time',
|
||||
'diff_now' => 'الآن',
|
||||
'diff_today' => 'اليوم',
|
||||
'diff_today_regexp' => 'اليوم(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_yesterday' => 'أمس',
|
||||
'diff_yesterday_regexp' => 'أمس(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_tomorrow' => 'غداً',
|
||||
'diff_tomorrow_regexp' => 'غدا(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_before_yesterday' => 'قبل الأمس',
|
||||
'diff_after_tomorrow' => 'بعد غد',
|
||||
'period_recurrences' => implode('|', ['{0}مرة', '{1}مرة', '{2}:count مرتين', ']2,11[:count مرات', ']10,Inf[:count مرة']),
|
||||
'period_interval' => 'كل :interval',
|
||||
'period_start_date' => 'من :date',
|
||||
'period_end_date' => 'إلى :date',
|
||||
'months' => $months,
|
||||
'months_short' => $months,
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'list' => ['، ', ' و '],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'DD/MM/YYYY',
|
||||
'LL' => 'D MMMM YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd D MMMM YYYY HH:mm',
|
||||
],
|
||||
'calendar' => [
|
||||
'sameDay' => '[اليوم على الساعة] LT',
|
||||
'nextDay' => '[غدا على الساعة] LT',
|
||||
'nextWeek' => 'dddd [على الساعة] LT',
|
||||
'lastDay' => '[أمس على الساعة] LT',
|
||||
'lastWeek' => 'dddd [على الساعة] LT',
|
||||
'sameElse' => 'L',
|
||||
],
|
||||
'meridiem' => ['ص', 'م'],
|
||||
'weekend' => [5, 6],
|
||||
];
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
|
||||
'months_short' => ['ينا', 'فبر', 'مار', 'أبر', 'ماي', 'يون', 'يول', 'أغس', 'سبت', 'أكت', 'نوف', 'ديس'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
]);
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
|
||||
'months_short' => ['ينا', 'فبر', 'مار', 'أبر', 'ماي', 'يون', 'يول', 'أغس', 'سبت', 'أكت', 'نوف', 'ديس'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 1,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'أيار', 'حزيران', 'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
|
||||
'months_short' => ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'أيار', 'حزيران', 'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Abdellah Chadidi
|
||||
* - Atef Ben Ali (atefBB)
|
||||
* - Mohamed Sabil (mohamedsabil83)
|
||||
*/
|
||||
// Same for long and short
|
||||
$months = [
|
||||
// @TODO add shakl to months
|
||||
'يناير',
|
||||
'فبراير',
|
||||
'مارس',
|
||||
'أبريل',
|
||||
'مايو',
|
||||
'يونيو',
|
||||
'يوليو',
|
||||
'أغسطس',
|
||||
'سبتمبر',
|
||||
'أكتوبر',
|
||||
'نوفمبر',
|
||||
'ديسمبر',
|
||||
];
|
||||
|
||||
return [
|
||||
'year' => implode('|', ['{0}:count سَنَة', '{1}سَنَة', '{2}سَنَتَيْن', ']2,11[:count سَنَوَات', ']10,Inf[:count سَنَة']),
|
||||
'a_year' => implode('|', ['{0}:count سَنَة', '{1}سَنَة', '{2}سَنَتَيْن', ']2,11[:count سَنَوَات', ']10,Inf[:count سَنَة']),
|
||||
'month' => implode('|', ['{0}:count شَهْرَ', '{1}شَهْرَ', '{2}شَهْرَيْن', ']2,11[:count أَشْهُر', ']10,Inf[:count شَهْرَ']),
|
||||
'a_month' => implode('|', ['{0}:count شَهْرَ', '{1}شَهْرَ', '{2}شَهْرَيْن', ']2,11[:count أَشْهُر', ']10,Inf[:count شَهْرَ']),
|
||||
'week' => implode('|', ['{0}:count أُسْبُوع', '{1}أُسْبُوع', '{2}أُسْبُوعَيْن', ']2,11[:count أَسَابِيع', ']10,Inf[:count أُسْبُوع']),
|
||||
'a_week' => implode('|', ['{0}:count أُسْبُوع', '{1}أُسْبُوع', '{2}أُسْبُوعَيْن', ']2,11[:count أَسَابِيع', ']10,Inf[:count أُسْبُوع']),
|
||||
'day' => implode('|', ['{0}:count يَوْم', '{1}يَوْم', '{2}يَوْمَيْن', ']2,11[:count أَيَّام', ']10,Inf[:count يَوْم']),
|
||||
'a_day' => implode('|', ['{0}:count يَوْم', '{1}يَوْم', '{2}يَوْمَيْن', ']2,11[:count أَيَّام', ']10,Inf[:count يَوْم']),
|
||||
'hour' => implode('|', ['{0}:count سَاعَة', '{1}سَاعَة', '{2}سَاعَتَيْن', ']2,11[:count سَاعَات', ']10,Inf[:count سَاعَة']),
|
||||
'a_hour' => implode('|', ['{0}:count سَاعَة', '{1}سَاعَة', '{2}سَاعَتَيْن', ']2,11[:count سَاعَات', ']10,Inf[:count سَاعَة']),
|
||||
'minute' => implode('|', ['{0}:count دَقِيقَة', '{1}دَقِيقَة', '{2}دَقِيقَتَيْن', ']2,11[:count دَقَائِق', ']10,Inf[:count دَقِيقَة']),
|
||||
'a_minute' => implode('|', ['{0}:count دَقِيقَة', '{1}دَقِيقَة', '{2}دَقِيقَتَيْن', ']2,11[:count دَقَائِق', ']10,Inf[:count دَقِيقَة']),
|
||||
'second' => implode('|', ['{0}:count ثَانِيَة', '{1}ثَانِيَة', '{2}ثَانِيَتَيْن', ']2,11[:count ثَوَان', ']10,Inf[:count ثَانِيَة']),
|
||||
'a_second' => implode('|', ['{0}:count ثَانِيَة', '{1}ثَانِيَة', '{2}ثَانِيَتَيْن', ']2,11[:count ثَوَان', ']10,Inf[:count ثَانِيَة']),
|
||||
'ago' => 'مُنْذُ :time',
|
||||
'from_now' => 'مِنَ الْآن :time',
|
||||
'after' => 'بَعْدَ :time',
|
||||
'before' => 'قَبْلَ :time',
|
||||
|
||||
// @TODO add shakl to translations below
|
||||
'diff_now' => 'الآن',
|
||||
'diff_today' => 'اليوم',
|
||||
'diff_today_regexp' => 'اليوم(?:\\s+عند)?(?:\\s+الساعة)?',
|
||||
'diff_yesterday' => 'أمس',
|
||||
'diff_yesterday_regexp' => 'أمس(?:\\s+عند)?(?:\\s+الساعة)?',
|
||||
'diff_tomorrow' => 'غداً',
|
||||
'diff_tomorrow_regexp' => 'غدًا(?:\\s+عند)?(?:\\s+الساعة)?',
|
||||
'diff_before_yesterday' => 'قبل الأمس',
|
||||
'diff_after_tomorrow' => 'بعد غد',
|
||||
'period_recurrences' => implode('|', ['{0}مرة', '{1}مرة', '{2}:count مرتين', ']2,11[:count مرات', ']10,Inf[:count مرة']),
|
||||
'period_interval' => 'كل :interval',
|
||||
'period_start_date' => 'من :date',
|
||||
'period_end_date' => 'إلى :date',
|
||||
'months' => $months,
|
||||
'months_short' => $months,
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
'weekdays_min' => ['ح', 'اث', 'ثل', 'أر', 'خم', 'ج', 'س'],
|
||||
'list' => ['، ', ' و '],
|
||||
'first_day_of_week' => 6,
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'D/M/YYYY',
|
||||
'LL' => 'D MMMM YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd D MMMM YYYY HH:mm',
|
||||
],
|
||||
'calendar' => [
|
||||
'sameDay' => '[اليوم عند الساعة] LT',
|
||||
'nextDay' => '[غدًا عند الساعة] LT',
|
||||
'nextWeek' => 'dddd [عند الساعة] LT',
|
||||
'lastDay' => '[أمس عند الساعة] LT',
|
||||
'lastWeek' => 'dddd [عند الساعة] LT',
|
||||
'sameElse' => 'L',
|
||||
],
|
||||
'meridiem' => ['ص', 'م'],
|
||||
'weekend' => [5, 6],
|
||||
];
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
]);
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Authors:
|
||||
* - JD Isaacks
|
||||
* - Atef Ben Ali (atefBB)
|
||||
* - Mohamed Sabil (mohamedsabil83)
|
||||
*/
|
||||
$months = [
|
||||
'جانفي',
|
||||
'فيفري',
|
||||
'مارس',
|
||||
'أفريل',
|
||||
'ماي',
|
||||
'جوان',
|
||||
'جويلية',
|
||||
'أوت',
|
||||
'سبتمبر',
|
||||
'أكتوبر',
|
||||
'نوفمبر',
|
||||
'ديسمبر',
|
||||
];
|
||||
|
||||
return [
|
||||
'year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'a_year' => implode('|', ['{0}:count سنة', '{1}سنة', '{2}سنتين', ']2,11[:count سنوات', ']10,Inf[:count سنة']),
|
||||
'month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'a_month' => implode('|', ['{0}:count شهر', '{1}شهر', '{2}شهرين', ']2,11[:count أشهر', ']10,Inf[:count شهر']),
|
||||
'week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'a_week' => implode('|', ['{0}:count أسبوع', '{1}أسبوع', '{2}أسبوعين', ']2,11[:count أسابيع', ']10,Inf[:count أسبوع']),
|
||||
'day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'a_day' => implode('|', ['{0}:count يوم', '{1}يوم', '{2}يومين', ']2,11[:count أيام', ']10,Inf[:count يوم']),
|
||||
'hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'a_hour' => implode('|', ['{0}:count ساعة', '{1}ساعة', '{2}ساعتين', ']2,11[:count ساعات', ']10,Inf[:count ساعة']),
|
||||
'minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'a_minute' => implode('|', ['{0}:count دقيقة', '{1}دقيقة', '{2}دقيقتين', ']2,11[:count دقائق', ']10,Inf[:count دقيقة']),
|
||||
'second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'a_second' => implode('|', ['{0}:count ثانية', '{1}ثانية', '{2}ثانيتين', ']2,11[:count ثواني', ']10,Inf[:count ثانية']),
|
||||
'ago' => 'منذ :time',
|
||||
'from_now' => 'في :time',
|
||||
'after' => 'بعد :time',
|
||||
'before' => 'قبل :time',
|
||||
'diff_now' => 'الآن',
|
||||
'diff_today' => 'اليوم',
|
||||
'diff_today_regexp' => 'اليوم(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_yesterday' => 'أمس',
|
||||
'diff_yesterday_regexp' => 'أمس(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_tomorrow' => 'غداً',
|
||||
'diff_tomorrow_regexp' => 'غدا(?:\\s+على)?(?:\\s+الساعة)?',
|
||||
'diff_before_yesterday' => 'قبل الأمس',
|
||||
'diff_after_tomorrow' => 'بعد غد',
|
||||
'period_recurrences' => implode('|', ['{0}مرة', '{1}مرة', '{2}:count مرتين', ']2,11[:count مرات', ']10,Inf[:count مرة']),
|
||||
'period_interval' => 'كل :interval',
|
||||
'period_start_date' => 'من :date',
|
||||
'period_end_date' => 'إلى :date',
|
||||
'months' => $months,
|
||||
'months_short' => $months,
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'list' => ['، ', ' و '],
|
||||
'first_day_of_week' => 1,
|
||||
'day_of_first_week_of_year' => 4,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'DD/MM/YYYY',
|
||||
'LL' => 'D MMMM YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd D MMMM YYYY HH:mm',
|
||||
],
|
||||
'calendar' => [
|
||||
'sameDay' => '[اليوم على الساعة] LT',
|
||||
'nextDay' => '[غدا على الساعة] LT',
|
||||
'nextWeek' => 'dddd [على الساعة] LT',
|
||||
'lastDay' => '[أمس على الساعة] LT',
|
||||
'lastWeek' => 'dddd [على الساعة] LT',
|
||||
'sameElse' => 'L',
|
||||
],
|
||||
'meridiem' => ['ص', 'م'],
|
||||
'weekend' => [5, 6],
|
||||
];
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/ar.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD MMM, YYYY',
|
||||
],
|
||||
'months' => ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
|
||||
'months_short' => ['ينا', 'فبر', 'مار', 'أبر', 'ماي', 'يون', 'يول', 'أغس', 'سبت', 'أكت', 'نوف', 'ديس'],
|
||||
'weekdays' => ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
'day_of_first_week_of_year' => 1,
|
||||
]);
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Unknown default region, use the first alphabetically.
|
||||
*/
|
||||
return require __DIR__.'/as_IN.php';
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Amitakhya Phukan, Red Hat bug-glibc@gnu.org
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'formats' => [
|
||||
'L' => 'D-MM-YYYY',
|
||||
],
|
||||
'months' => ['জানুৱাৰী', 'ফেব্ৰুৱাৰী', 'মাৰ্চ', 'এপ্ৰিল', 'মে', 'জুন', 'জুলাই', 'আগষ্ট', 'ছেপ্তেম্বৰ', 'অক্টোবৰ', 'নৱেম্বৰ', 'ডিচেম্বৰ'],
|
||||
'months_short' => ['জানু', 'ফেব্ৰু', 'মাৰ্চ', 'এপ্ৰিল', 'মে', 'জুন', 'জুলাই', 'আগ', 'সেপ্ট', 'অক্টো', 'নভে', 'ডিসে'],
|
||||
'weekdays' => ['দেওবাৰ', 'সোমবাৰ', 'মঙ্গলবাৰ', 'বুধবাৰ', 'বৃহষ্পতিবাৰ', 'শুক্ৰবাৰ', 'শনিবাৰ'],
|
||||
'weekdays_short' => ['দেও', 'সোম', 'মঙ্গল', 'বুধ', 'বৃহষ্পতি', 'শুক্ৰ', 'শনি'],
|
||||
'weekdays_min' => ['দেও', 'সোম', 'মঙ্গল', 'বুধ', 'বৃহষ্পতি', 'শুক্ৰ', 'শনি'],
|
||||
'day_of_first_week_of_year' => 1,
|
||||
'meridiem' => ['পূৰ্ব্বাহ্ন', 'অপৰাহ্ন'],
|
||||
|
||||
'year' => ':count বছৰ',
|
||||
'y' => ':count বছৰ',
|
||||
'a_year' => ':count বছৰ',
|
||||
|
||||
'month' => ':count মাহ',
|
||||
'm' => ':count মাহ',
|
||||
'a_month' => ':count মাহ',
|
||||
|
||||
'week' => ':count সপ্তাহ',
|
||||
'w' => ':count সপ্তাহ',
|
||||
'a_week' => ':count সপ্তাহ',
|
||||
|
||||
'day' => ':count বাৰ',
|
||||
'd' => ':count বাৰ',
|
||||
'a_day' => ':count বাৰ',
|
||||
|
||||
'hour' => ':count ঘণ্টা',
|
||||
'h' => ':count ঘণ্টা',
|
||||
'a_hour' => ':count ঘণ্টা',
|
||||
|
||||
'minute' => ':count মিনিট',
|
||||
'min' => ':count মিনিট',
|
||||
'a_minute' => ':count মিনিট',
|
||||
|
||||
'second' => ':count দ্বিতীয়',
|
||||
's' => ':count দ্বিতীয়',
|
||||
'a_second' => ':count দ্বিতীয়',
|
||||
]);
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/en.php', [
|
||||
'meridiem' => ['icheheavo', 'ichamthi'],
|
||||
'weekdays' => ['Jumapili', 'Jumatatu', 'Jumanne', 'Jumatano', 'Alhamisi', 'Ijumaa', 'Jumamosi'],
|
||||
'weekdays_short' => ['Jpi', 'Jtt', 'Jnn', 'Jtn', 'Alh', 'Ijm', 'Jmo'],
|
||||
'weekdays_min' => ['Jpi', 'Jtt', 'Jnn', 'Jtn', 'Alh', 'Ijm', 'Jmo'],
|
||||
'months' => ['Januari', 'Februari', 'Machi', 'Aprili', 'Mei', 'Juni', 'Julai', 'Agosti', 'Septemba', 'Oktoba', 'Novemba', 'Desemba'],
|
||||
'months_short' => ['Jan', 'Feb', 'Mac', 'Apr', 'Mei', 'Jun', 'Jul', 'Ago', 'Sep', 'Okt', 'Nov', 'Dec'],
|
||||
'first_day_of_week' => 1,
|
||||
'formats' => [
|
||||
'LT' => 'HH:mm',
|
||||
'LTS' => 'HH:mm:ss',
|
||||
'L' => 'DD/MM/YYYY',
|
||||
'LL' => 'D MMM YYYY',
|
||||
'LLL' => 'D MMMM YYYY HH:mm',
|
||||
'LLLL' => 'dddd, D MMMM YYYY HH:mm',
|
||||
],
|
||||
]);
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* - Jordi Mallach jordi@gnu.org
|
||||
* - Adolfo Jayme-Barrientos (fitojb)
|
||||
*/
|
||||
return array_replace_recursive(require __DIR__.'/es.php', [
|
||||
'formats' => [
|
||||
'L' => 'DD/MM/YY',
|
||||
],
|
||||
'months' => ['de xineru', 'de febreru', 'de marzu', 'd’abril', 'de mayu', 'de xunu', 'de xunetu', 'd’agostu', 'de setiembre', 'd’ochobre', 'de payares', 'd’avientu'],
|
||||
'months_short' => ['xin', 'feb', 'mar', 'abr', 'may', 'xun', 'xnt', 'ago', 'set', 'och', 'pay', 'avi'],
|
||||
'weekdays' => ['domingu', 'llunes', 'martes', 'miércoles', 'xueves', 'vienres', 'sábadu'],
|
||||
'weekdays_short' => ['dom', 'llu', 'mar', 'mié', 'xue', 'vie', 'sáb'],
|
||||
'weekdays_min' => ['dom', 'llu', 'mar', 'mié', 'xue', 'vie', 'sáb'],
|
||||
|
||||
'year' => ':count añu|:count años',
|
||||
'y' => ':count añu|:count años',
|
||||
'a_year' => 'un añu|:count años',
|
||||
|
||||
'month' => ':count mes',
|
||||
'm' => ':count mes',
|
||||
'a_month' => 'un mes|:count mes',
|
||||
|
||||
'week' => ':count selmana|:count selmanes',
|
||||
'w' => ':count selmana|:count selmanes',
|
||||
'a_week' => 'una selmana|:count selmanes',
|
||||
|
||||
'day' => ':count día|:count díes',
|
||||
'd' => ':count día|:count díes',
|
||||
'a_day' => 'un día|:count díes',
|
||||
|
||||
'hour' => ':count hora|:count hores',
|
||||
'h' => ':count hora|:count hores',
|
||||
'a_hour' => 'una hora|:count hores',
|
||||
|
||||
'minute' => ':count minutu|:count minutos',
|
||||
'min' => ':count minutu|:count minutos',
|
||||
'a_minute' => 'un minutu|:count minutos',
|
||||
|
||||
'second' => ':count segundu|:count segundos',
|
||||
's' => ':count segundu|:count segundos',
|
||||
'a_second' => 'un segundu|:count segundos',
|
||||
|
||||
'ago' => 'hai :time',
|
||||
'from_now' => 'en :time',
|
||||
'after' => ':time dempués',
|
||||
'before' => ':time enantes',
|
||||
]);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
return require __DIR__.'/ast.php';
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Unknown default region, use the first alphabetically.
|
||||
*/
|
||||
return require __DIR__.'/ayc_PE.php';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user