Skip to content
Snippets Groups Projects
Verified Commit b501b333 authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Fix age_at method

parent 3a2f141f
No related branches found
No related tags found
1 merge request!229Add statistics about group to group view
Pipeline #1628 failed
......@@ -181,12 +181,13 @@ class Person(ExtensibleModel):
return self.age_at(timezone.datetime.now().date())
def age_at(self, today):
years = today.year - self.date_of_birth.year
if (self.date_of_birth.month > today.month
or (self.date_of_birth.month == today.month
and self.date_of_birth.day > today.day)):
years -= 1
return years
if self.date_of_birth:
years = today.year - self.date_of_birth.year
if (self.date_of_birth.month > today.month
or (self.date_of_birth.month == today.month
and self.date_of_birth.day > today.day)):
years -= 1
return years
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment