From 19eaa2c532d027a683dd046e4fb518469f2a8340 Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Fri, 6 Oct 2017 21:36:13 +0200 Subject: [PATCH] Fix timezone awareness for account creation time (#378) --- nyaa/models.py | 5 +++++ nyaa/templates/user.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/nyaa/models.py b/nyaa/models.py index 1f1ba10..cc19114 100644 --- a/nyaa/models.py +++ b/nyaa/models.py @@ -606,6 +606,11 @@ class User(db.Model): '''Account age in seconds''' return (datetime.utcnow() - self.created_time).total_seconds() + @property + def created_utc_timestamp(self): + ''' Returns a UTC POSIX timestamp, as seconds ''' + return (self.created_time - UTC_EPOCH).total_seconds() + class AdminLogBase(DeclarativeHelperBase): __tablename_base__ = 'adminlog' diff --git a/nyaa/templates/user.html b/nyaa/templates/user.html index 0de97d3..8526c34 100644 --- a/nyaa/templates/user.html +++ b/nyaa/templates/user.html @@ -24,7 +24,7 @@
User ID:
{{ user.id }}
Account created on:
-
{{ user.created_time }}
+
{{ user.created_time.strftime('%Y-%m-%d %H:%M UTC') }}
Email address:
{{ user.email }}
User class: