| 1 | <?php |
| 2 | |
| 3 | namespace Illuminate\Support\Facades; |
| 4 | |
| 5 | use Illuminate\Support\DateFactory; |
| 6 | |
| 7 | /** |
| 8 | * @see https://carbon.nesbot.com/docs/ |
| 9 | * @see https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Factory.php |
| 10 | * |
| 11 | * @method static mixed use(mixed $handler) |
| 12 | * @method static void useDefault() |
| 13 | * @method static void useCallable(callable $callable) |
| 14 | * @method static void useClass(string $dateClass) |
| 15 | * @method static void useFactory(object $factory) |
| 16 | * @method static bool canBeCreatedFromFormat(?string $date, string $format) |
| 17 | * @method static \Illuminate\Support\Carbon|null create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $timezone = null) |
| 18 | * @method static \Illuminate\Support\Carbon createFromDate($year = null, $month = null, $day = null, $timezone = null) |
| 19 | * @method static \Illuminate\Support\Carbon|null createFromFormat($format, $time, $timezone = null) |
| 20 | * @method static \Illuminate\Support\Carbon|null createFromIsoFormat(string $format, string $time, $timezone = null, ?string $locale = 'en', ?\Symfony\Contracts\Translation\TranslatorInterface $translator = null) |
| 21 | * @method static \Illuminate\Support\Carbon|null createFromLocaleFormat(string $format, string $locale, string $time, $timezone = null) |
| 22 | * @method static \Illuminate\Support\Carbon|null createFromLocaleIsoFormat(string $format, string $locale, string $time, $timezone = null) |
| 23 | * @method static \Illuminate\Support\Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $timezone = null) |
| 24 | * @method static \Illuminate\Support\Carbon createFromTimeString(string $time, \DateTimeZone|string|int|null $timezone = null) |
| 25 | * @method static \Illuminate\Support\Carbon createFromTimestamp(string|int|float $timestamp, \DateTimeZone|string|int|null $timezone = null) |
| 26 | * @method static \Illuminate\Support\Carbon createFromTimestampMs(string|int|float $timestamp, \DateTimeZone|string|int|null $timezone = null) |
| 27 | * @method static \Illuminate\Support\Carbon createFromTimestampMsUTC($timestamp) |
| 28 | * @method static \Illuminate\Support\Carbon createFromTimestampUTC(string|int|float $timestamp) |
| 29 | * @method static \Illuminate\Support\Carbon createMidnightDate($year = null, $month = null, $day = null, $timezone = null) |
| 30 | * @method static \Illuminate\Support\Carbon|null createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null) |
| 31 | * @method static \Illuminate\Support\Carbon createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $timezone = null) |
| 32 | * @method static void disableHumanDiffOption($humanDiffOption) |
| 33 | * @method static void enableHumanDiffOption($humanDiffOption) |
| 34 | * @method static mixed executeWithLocale(string $locale, callable $func) |
| 35 | * @method static \Illuminate\Support\Carbon fromSerialized($value) |
| 36 | * @method static array getAvailableLocales() |
| 37 | * @method static array getAvailableLocalesInfo() |
| 38 | * @method static array getDays() |
| 39 | * @method static ?string getFallbackLocale() |
| 40 | * @method static array getFormatsToIsoReplacements() |
| 41 | * @method static int getHumanDiffOptions() |
| 42 | * @method static array getIsoUnits() |
| 43 | * @method static array|false getLastErrors() |
| 44 | * @method static string getLocale() |
| 45 | * @method static int getMidDayAt() |
| 46 | * @method static string getTimeFormatByPrecision(string $unitPrecision) |
| 47 | * @method static string|\Closure|null getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null) |
| 48 | * @method static \Illuminate\Support\Carbon|null getTestNow() |
| 49 | * @method static \Symfony\Contracts\Translation\TranslatorInterface getTranslator() |
| 50 | * @method static int getWeekEndsAt(?string $locale = null) |
| 51 | * @method static int getWeekStartsAt(?string $locale = null) |
| 52 | * @method static array getWeekendDays() |
| 53 | * @method static bool hasFormat(string $date, string $format) |
| 54 | * @method static bool hasFormatWithModifiers(string $date, string $format) |
| 55 | * @method static bool hasMacro($name) |
| 56 | * @method static bool hasRelativeKeywords(?string $time) |
| 57 | * @method static bool hasTestNow() |
| 58 | * @method static \Illuminate\Support\Carbon instance(\DateTimeInterface $date) |
| 59 | * @method static bool isImmutable() |
| 60 | * @method static bool isModifiableUnit($unit) |
| 61 | * @method static bool isMutable() |
| 62 | * @method static bool isStrictModeEnabled() |
| 63 | * @method static bool localeHasDiffOneDayWords(string $locale) |
| 64 | * @method static bool localeHasDiffSyntax(string $locale) |
| 65 | * @method static bool localeHasDiffTwoDayWords(string $locale) |
| 66 | * @method static bool localeHasPeriodSyntax($locale) |
| 67 | * @method static bool localeHasShortUnits(string $locale) |
| 68 | * @method static void macro(string $name, ?callable $macro) |
| 69 | * @method static \Illuminate\Support\Carbon|null make($var, \DateTimeZone|string|null $timezone = null) |
| 70 | * @method static void mixin(object|string $mixin) |
| 71 | * @method static \Illuminate\Support\Carbon now(\DateTimeZone|string|int|null $timezone = null) |
| 72 | * @method static \Illuminate\Support\Carbon parse(\DateTimeInterface|\Carbon\WeekDay|\Carbon\Month|string|int|float|null $time, \DateTimeZone|string|int|null $timezone = null) |
| 73 | * @method static \Illuminate\Support\Carbon parseFromLocale(string $time, ?string $locale = null, \DateTimeZone|string|int|null $timezone = null) |
| 74 | * @method static string pluralUnit(string $unit) |
| 75 | * @method static \Illuminate\Support\Carbon|null rawCreateFromFormat(string $format, string $time, $timezone = null) |
| 76 | * @method static \Illuminate\Support\Carbon rawParse(\DateTimeInterface|\Carbon\WeekDay|\Carbon\Month|string|int|float|null $time, \DateTimeZone|string|int|null $timezone = null) |
| 77 | * @method static void resetMonthsOverflow() |
| 78 | * @method static void resetToStringFormat() |
| 79 | * @method static void resetYearsOverflow() |
| 80 | * @method static void serializeUsing($callback) |
| 81 | * @method static void setFallbackLocale(string $locale) |
| 82 | * @method static void setHumanDiffOptions($humanDiffOptions) |
| 83 | * @method static void setLocale(string $locale) |
| 84 | * @method static void setMidDayAt($hour) |
| 85 | * @method static void setTestNow(mixed $testNow = null) |
| 86 | * @method static void setTestNowAndTimezone(mixed $testNow = null, $timezone = null) |
| 87 | * @method static void setToStringFormat(string|\Closure|null $format) |
| 88 | * @method static void setTranslator(\Symfony\Contracts\Translation\TranslatorInterface $translator) |
| 89 | * @method static void setWeekEndsAt($day) |
| 90 | * @method static void setWeekStartsAt($day) |
| 91 | * @method static void setWeekendDays($days) |
| 92 | * @method static bool shouldOverflowMonths() |
| 93 | * @method static bool shouldOverflowYears() |
| 94 | * @method static string singularUnit(string $unit) |
| 95 | * @method static void sleep(int|float $seconds) |
| 96 | * @method static \Illuminate\Support\Carbon today(\DateTimeZone|string|int|null $timezone = null) |
| 97 | * @method static \Illuminate\Support\Carbon tomorrow(\DateTimeZone|string|int|null $timezone = null) |
| 98 | * @method static string translateTimeString(string $timeString, ?string $from = null, ?string $to = null, int $mode = \Carbon\CarbonInterface::TRANSLATE_ALL) |
| 99 | * @method static string translateWith(\Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null) |
| 100 | * @method static void useMonthsOverflow($monthsOverflow = true) |
| 101 | * @method static void useStrictMode($strictModeEnabled = true) |
| 102 | * @method static void useYearsOverflow($yearsOverflow = true) |
| 103 | * @method static mixed withTestNow(mixed $testNow, callable $callback) |
| 104 | * @method static static withTimeZone(\DateTimeZone|string|int|null $timezone) |
| 105 | * @method static \Illuminate\Support\Carbon yesterday(\DateTimeZone|string|int|null $timezone = null) |
| 106 | * |
| 107 | * @see \Illuminate\Support\DateFactory |
| 108 | */ |
| 109 | class Date extends Facade |
| 110 | { |
| 111 | const DEFAULT_FACADE = DateFactory::class; |
| 112 | |
| 113 | /** |
| 114 | * Get the registered name of the component. |
| 115 | * |
| 116 | * @return string |
| 117 | * |
| 118 | * @throws \RuntimeException |
| 119 | */ |
| 120 | protected static function getFacadeAccessor() |
| 121 | { |
| 122 | return 'date'; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Resolve the facade root instance from the container. |
| 127 | * |
| 128 | * @param string $name |
| 129 | * @return mixed |
| 130 | */ |
| 131 | protected static function resolveFacadeInstance($name) |
| 132 | { |
| 133 | if (! isset(static::$resolvedInstance[$name]) && ! isset(static::$app, static::$app[$name])) { |
| 134 | $class = static::DEFAULT_FACADE; |
| 135 | |
| 136 | static::swap(new $class); |
| 137 | } |
| 138 | |
| 139 | return parent::resolveFacadeInstance($name); |
| 140 | } |
| 141 | } |