Fakultas Ilmu Komputer UI

Commit 37f638be authored by Nabila Febri Viola's avatar Nabila Febri Viola
Browse files

[REFACTOR] Fix age property in profile model

parent 7c284880
Pipeline #50090 passed with stages
in 1 minute and 47 seconds
......@@ -93,6 +93,8 @@ class Profile(models.Model):
@property
def age(self):
if self.birthdate is None:
return 0
born = self.birthdate
today = date.today()
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment