MVP ready. Fully functional (registration? moderation, profiles vew)
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
15
services/bot/app/utils/common.py
Normal file
15
services/bot/app/utils/common.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from __future__ import annotations
|
||||
from datetime import date
|
||||
from typing import List, Optional
|
||||
|
||||
def csv_to_list(s: Optional[str]) -> List[str]:
|
||||
return [x.strip() for x in (s or "").split(",") if x.strip()]
|
||||
|
||||
def list_to_csv(items: List[str]) -> str:
|
||||
return ", ".join([i.strip() for i in items if i.strip()])
|
||||
|
||||
def calc_age(born: Optional[date]) -> Optional[int]:
|
||||
if not born:
|
||||
return None
|
||||
today = date.today()
|
||||
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
|
||||
Reference in New Issue
Block a user