allow age calculation on NULL birthdate and allow age to be null

+ improve translation of age
This commit is contained in:
2021-07-20 23:50:31 +02:00
parent 08e396195c
commit 76e7f5b1ee
4 changed files with 16 additions and 6 deletions

View File

@@ -734,9 +734,13 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->birthdate;
}
public function getAge(): int
public function getAge(): ?int
{
return date_diff($this->birthdate, date_create('now'))->format("%y");
if ($this->birthdate instanceof \DateTimeInterface) {
return date_diff($this->birthdate, date_create('now'))->format("%y");
}
return null;
}
/**