typing for jinja2 filters
This commit is contained in:
parent
120be8eaa5
commit
a916041021
1 changed files with 3 additions and 3 deletions
|
@ -16,16 +16,16 @@ portal = Blueprint("portal", __name__, template_folder="templates", static_folde
|
|||
|
||||
|
||||
@portal.app_template_filter("mirror_expiry")
|
||||
def calculate_mirror_expiry(s):
|
||||
def calculate_mirror_expiry(s: datetime) -> str:
|
||||
expiry = s + timedelta(days=3)
|
||||
countdown = expiry - datetime.now(timezone.utc)
|
||||
countdown = expiry - datetime.utcnow()
|
||||
if countdown.days == 0:
|
||||
return f"{countdown.seconds // 3600} hours"
|
||||
return f"{countdown.days} days"
|
||||
|
||||
|
||||
@portal.app_template_filter("format_datetime")
|
||||
def format_datetime(s):
|
||||
def format_datetime(s: datetime) -> str:
|
||||
if s is None:
|
||||
return "Unknown"
|
||||
return s.strftime("%a, %d %b %Y %H:%M:%S")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue