From 517c760d4f5295dd6d3fb2192280091b8532560a Mon Sep 17 00:00:00 2001 From: Igor Elpin Date: Thu, 13 Oct 2022 19:15:20 +0300 Subject: [PATCH] fix age --- humans/__init__.py | 3 ++- templates/index.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/humans/__init__.py b/humans/__init__.py index d7bb016..e004fbf 100644 --- a/humans/__init__.py +++ b/humans/__init__.py @@ -18,7 +18,8 @@ class AbstractHuman: @property def age(self) -> int: - age=datetime.now().year-self.birthday.year + today=datetime.now() + age=today.year-self.birthday.year -((today.month, today.day) < (self.birthday.month, self.birthday.day)) if age>0: return int(age) else: diff --git a/templates/index.html b/templates/index.html index ea51449..915431c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -51,7 +51,7 @@

Игорь Ельпин(говорит): - Игорь Ельпин. Мужчина 1989-11-16 (33 полных лет) + Игорь Ельпин. Мужчина 1989-11-16