diff --git a/src/Date.php b/src/Date.php index bffccc4..9db7ca0 100644 --- a/src/Date.php +++ b/src/Date.php @@ -58,78 +58,37 @@ public function __toString(): string public function isEqualTo(self $date): bool { - return $this->day === $date->day - && $this->month->isEqualTo($date->month); + return $this->toDateTimeImmutable() == $date->toDateTimeImmutable(); } public function isNotEqualTo(self $date): bool { - return !$this->isEqualTo($date); + return $this->toDateTimeImmutable() != $date->toDateTimeImmutable(); } public function isBefore(self $date): bool { - if ($this->month->isBefore($date->month)) { - return true; - } - - if ($this->month->isAfter($date->month)) { - return false; - } - - return $this->day < $date->day; + return $this->toDateTimeImmutable() < $date->toDateTimeImmutable(); } public function isBeforeOrEqualTo(self $date): bool { - if ($this->month->isBefore($date->month)) { - return true; - } - - if ($this->month->isAfter($date->month)) { - return false; - } - - return $this->day <= $date->day; + return $this->toDateTimeImmutable() <= $date->toDateTimeImmutable(); } public function isAfter(self $date): bool { - if ($this->month->isAfter($date->month)) { - return true; - } - - if ($this->month->isBefore($date->month)) { - return false; - } - - return $this->day > $date->day; + return $this->toDateTimeImmutable() > $date->toDateTimeImmutable(); } public function isNotAfter(self $date): bool { - if ($this->month->isBefore($date->month)) { - return true; - } - - if ($this->month->isAfter($date->month)) { - return false; - } - - return $this->day <= $date->day; + return $this->toDateTimeImmutable() <= $date->toDateTimeImmutable(); } public function isAfterOrEqualTo(self $date): bool { - if ($this->month->isAfter($date->month)) { - return true; - } - - if ($this->month->isBefore($date->month)) { - return false; - } - - return $this->day >= $date->day; + return $this->toDateTimeImmutable() >= $date->toDateTimeImmutable(); } public function compareTo(self $date): int