From e633b834c6874c610e06d06748dc183a9db9bb8e Mon Sep 17 00:00:00 2001 From: Inga Kirschnick Date: Wed, 21 Dec 2022 15:23:59 +0100 Subject: [PATCH] Adding date and time to news content --- app/models.py | 4 ++-- app/templates/main/news.html.j2 | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models.py b/app/models.py index ca492dc3..8ab09e6d 100644 --- a/app/models.py +++ b/app/models.py @@ -548,9 +548,9 @@ class User(HashidMixin, UserMixin, db.Model): 'email': self.email, 'last_seen': ( None if self.last_seen is None - else f'{self.last_seen.isoformat()}Z' + else self.last_seen.strftime('%Y-%m-%d %H:%M') ), - 'member_since': f'{self.member_since.isoformat()}Z', + 'member_since': self.member_since.strftime('%Y-%m-%d'), 'username': self.username, 'full_name': self.full_name, 'about_me': self.about_me, diff --git a/app/templates/main/news.html.j2 b/app/templates/main/news.html.j2 index 90872657..3c8069f6 100644 --- a/app/templates/main/news.html.j2 +++ b/app/templates/main/news.html.j2 @@ -197,13 +197,16 @@ } function mastodonStatusToHtml(status) { + let date = new Date(status.created_at).toLocaleString('en-US') return htmlString = `
New Actitvity on Mastodon - ${status.content} +

Published on ${date}

+
+

${status.content}

@@ -213,10 +216,10 @@ `.trim(); } function bisBlogsEntryToHtml(entry) { + let date = new Date(entry.published).toLocaleString('en-US') let bisBlogHTMLElement = document.createElement('div'); bisBlogHTMLElement.classList.add('row'); bisBlogHTMLElement.innerHTML = ` -
Bielefeld University Blogs
@@ -224,11 +227,12 @@
${entry.title['#text']} - ${entry.content['#text']} +

Published on ${date}

+
+

${entry.content['#text']}

-
`.trim(); let bisBlogImages = bisBlogHTMLElement.querySelectorAll('img'); bisBlogImages.forEach((img) => {