updated underage to function
This commit is contained in:
parent
dd5443a961
commit
d275acde9f
@ -27,14 +27,13 @@ class PersonModel(FiberBaseModel):
|
|||||||
date_of_birth: date | None = None
|
date_of_birth: date | None = None
|
||||||
|
|
||||||
|
|
||||||
@computed_field # type: ignore[prop-decorator]
|
def is_underage(self, ref_date: date | None = None) -> bool | None:
|
||||||
@property
|
|
||||||
def underage(self) -> bool:
|
|
||||||
if self.date_of_birth is None:
|
if self.date_of_birth is None:
|
||||||
return False
|
return False
|
||||||
today = date.today()
|
if ref_date is None:
|
||||||
age = ( today.year - self.date_of_birth.year
|
ref_data = date.today()
|
||||||
- ( (today.month, today.day)
|
age = ( ref_date.year - self.date_of_birth.year
|
||||||
|
- ( (ref_date.month, ref_date.day)
|
||||||
< (self.date_of_birth.month, self.date_of_birth.day) )
|
< (self.date_of_birth.month, self.date_of_birth.day) )
|
||||||
)
|
)
|
||||||
return age < 18
|
return age < 18
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user