Skip to content

Commit

Permalink
Remove custom code in date
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Kolb committed Sep 20, 2023
1 parent d4c2633 commit e254761
Showing 1 changed file with 7 additions and 48 deletions.
55 changes: 7 additions & 48 deletions src/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e254761

Please sign in to comment.