Date.php 8.2 KB

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