n($date)->{$unit} === $this->{$unit}; } if ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) { throw new BadComparisonUnitException($unit); } return \false; } public function isCurrentUnit($unit) { return $this->{'isSame' . \ucfirst($unit)}(); } public function isSameQuarter($date = null, $ofSameYear = \true) { $date = $this->resolveCarbon($date); return $this->quarter === $date->quarter && (!$ofSameYear || $this->isSameYear($date)); } public function isSameMonth($date = null, $ofSameYear = \true) { return $this->isSameAs($ofSameYear ? 'Y-m' : 'm', $date); } public function isDayOfWeek($dayOfWeek) { if (\is_string($dayOfWeek) && \defined($constant = static::class . '::' . \strtoupper($dayOfWeek))) { $dayOfWeek = \constant($constant); } return $this->dayOfWeek === $dayOfWeek; } public function isBirthday($date = null) { return $this->isSameAs('md', $date); } public function isLastOfMonth() { return $this->day === $this->daysInMonth; } public function isStartOfDay($checkMicroseconds = \false) { return $checkMicroseconds ? $this->rawFormat('H:i:s.u') === '00:00:00.000000' : $this->rawFormat('H:i:s') === '00:00:00'; } public function isEndOfDay($checkMicroseconds = \false) { return $checkMicroseconds ? $this->rawFormat('H:i:s.u') === '23:59:59.999999' : $this->rawFormat('H:i:s') === '23:59:59'; } public function isMidnight() { return $this->isStartOfDay(); } public function isMidday() { return $this->rawFormat('G:i:s') === static::$midDayAt . ':00:00'; } public static function hasFormat($date, $format) { // createFromFormat() is known to handle edge cases silently. // E.g. "1975-5-1" (Y-n-j) will still be parsed correctly when "Y-m-d" is supplied as the format. // To ensure we're really testing against our desired format, perform an additional regex validation. return self::matchFormatPattern((string) $date, \preg_quote((string) $format, '/'), static::$regexFormats); } public static function hasFormatWithModifiers($date, $format) : bool { return self::matchFormatPattern((string) $date, (string) $format, \array_merge(static::$regexFormats, static::$regexFormatModifiers)); } public static function canBeCreatedFromFormat($date, $format) { try { // Try to create a DateTime object. Throws an InvalidArgumentException if the provided time string // doesn't match the format in any way. if (!static::rawCreateFromFormat($format, $date)) { return \false; } } catch (InvalidArgumentException $e) { return \false; } return static::hasFormatWithModifiers($date, $format); } public function is(string $tester) { $tester = \trim($tester); if (\preg_match('/^\\d+$/', $tester)) { return $this->year === (int) $tester; } if (\preg_match('/^\\d{3,}-\\d{1,2}$/', $tester)) { return $this->isSameMonth(static::parse($tester)); } if (\preg_match('/^\\d{1,2}-\\d{1,2}$/', $tester)) { return $this->isSameDay(static::parse($this->year . '-' . $tester)); } $modifier = \preg_replace('/(\\d)h$/i', '$1:00', $tester); $median = static::parse('5555-06-15 12:30:30.555555')->modify($modifier); $current = $this->avoidMutation(); $other = $this->avoidMutation()->modify($modifier); if ($current->eq($other)) { return \true; } if (\preg_match('/\\d:\\d{1,2}:\\d{1,2}$/', $tester)) { return $current->startOfSecond()->eq($other); } if (\preg_match('/\\d:\\d{1,2}$/', $tester)) { return $current->startOfMinute()->eq($other); } if (\preg_match('/\\d(h|am|pm)$/', $tester)) { return $current->startOfHour()->eq($other); } if (\preg_match('/^(january|february|march|april|may|june|july|august|september|october|november|december)\\s+\\d+$/i', $tester)) { return $current->startOfMonth()->eq($other->startOfMonth()); } $units = ['month' => [1, 'year'], 'day' => [1, 'month'], 'hour' => [0, 'day'], 'minute' => [0, 'hour'], 'second' => [0, 'minute'], 'microsecond' => [0, 'second']]; foreach ($units as $unit => [$minimum, $startUnit]) { if ($minimum === $median->{$unit}) { $current = $current->startOf($startUnit); break; } } return $current->eq($other); } private static function matchFormatPattern(string $date, string $format, array $replacements) : bool { // Preg quote, but remove escaped backslashes since we'll deal with escaped characters in the format string. $regex = \str_replace('\\\\', '\\', $format); // Replace not-escaped letters $regex = \preg_replace_callback('/(?startOfTime ?? \false; } public function isEndOfTime() : bool { return $this->endOfTime ?? \false; } private function discourageNull($value) : void { if ($value === null) { @\trigger_error("Since 2.61.0, it's deprecated to compare a date to null, meaning of such comparison is ambiguous and will no longer be possible in 3.0.0, you should explicitly pass 'now' or make an other check to eliminate null values.", \E_USER_DEPRECATED); } } private function discourageBoolean($value) : void { if (\is_bool($value)) { @\trigger_error("Since 2.61.0, it's deprecated to compare a date to true or false, meaning of such comparison is ambiguous and will no longer be possible in 3.0.0, you should explicitly pass 'now' or make an other check to eliminate boolean values.", \E_USER_DEPRECATED); } } }
Fatal error: Trait "MailPoetVendor\Carbon\Traits\Comparison" not found in /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/nesbot/carbon/src/Carbon/Traits/Date.php on line 524