diff --git a/app/__init__.py b/app/__init__.py index 46faa17..752409a 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -7,6 +7,7 @@ from .constants import ( PermissionLevel, InfoboxKind, InfoboxIcons, InfoboxHTMLClass ) +from datetime import datetime import os import time import secrets @@ -92,4 +93,8 @@ def create_app(): def inject_auth(): return {"is_logged_in": is_logged_in, "get_active_user": get_active_user, "active_user": get_active_user()} + @app.template_filter("ts_datetime") + def ts_datetime(ts, format): + return datetime.utcfromtimestamp(ts).strftime(format) + return app diff --git a/app/templates/base.html b/app/templates/base.html index 0e95ef9..ce2fc9b 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -25,4 +25,5 @@ + diff --git a/app/templates/common/macros.html b/app/templates/common/macros.html index fba810c..51875a6 100644 --- a/app/templates/common/macros.html +++ b/app/templates/common/macros.html @@ -38,3 +38,7 @@ {% endmacro %} + +{% macro timestamp(unix_ts) %} +{{ unix_ts | ts_datetime('%Y-%m-%d %H:%M')}} ST +{% endmacro %} diff --git a/app/templates/topics/topic.html b/app/templates/topics/topic.html index 70bf947..2c95f34 100644 --- a/app/templates/topics/topic.html +++ b/app/templates/topics/topic.html @@ -1,4 +1,4 @@ -{% from 'common/macros.html' import pager %} +{% from 'common/macros.html' import pager, timestamp %} {% extends "base.html" %} {% block title %}browsing topic {{ topic['name'] }}{% endblock %} {% block content %} @@ -30,11 +30,11 @@ {{thread['title']}} • - Started by {{ thread['started_by'] }} on ... + Started by {{ thread['started_by'] }} on {{ timestamp(thread['created_at'])}} Latest post by {{ thread['latest_post_username'] }} - on ... + on on {{ timestamp(thread['latest_post_created_at'] )}}: {{ thread['latest_post_content'] }} diff --git a/app/templates/users/user.html b/app/templates/users/user.html index a645f85..fd571c0 100644 --- a/app/templates/users/user.html +++ b/app/templates/users/user.html @@ -1,3 +1,4 @@ +{% from 'common/macros.html' import timestamp %} {% extends 'base.html' %} {% block title %}{{ target_user.username }}'s profile{% endblock %} {% block content %} @@ -17,9 +18,9 @@ {% if active_user and active_user.is_mod() and not target_user.is_system() %}

Moderation controls

{% if target_user.is_guest() %} -

This user is a guest. They signed up on ...

+

This user is a guest. They signed up on {{ timestamp(target_user['created_at']) }}

{% else %} -

This user signed up on ... and was confirmed on ...

+

This user signed up on {{ timestamp(target_user['created_at']) }} and was confirmed on {{ timestamp(target_user['confirmed_on']) }}

{% endif %} {% endif %}