From 79d134cea895c7a77d73c0a6a794c89a38e601c8 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 14 Nov 2022 11:59:59 +0700 Subject: [PATCH] clean format comments date string --- tubearchivist/home/src/index/comments.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tubearchivist/home/src/index/comments.py b/tubearchivist/home/src/index/comments.py index a7423ee4..e06b9737 100644 --- a/tubearchivist/home/src/index/comments.py +++ b/tubearchivist/home/src/index/comments.py @@ -74,7 +74,13 @@ class Comments: def clean_comment(self, comment): """parse metadata from comment for indexing""" time_text_datetime = datetime.utcfromtimestamp(comment["timestamp"]) - time_text = time_text_datetime.strftime("%Y-%m-%d %H:%M:%S") + + if time_text_datetime.hour == 0 and time_text_datetime.minute == 0: + format_string = "%Y-%m-%d" + else: + format_string = "%Y-%m-%d %H:%M" + + time_text = time_text_datetime.strftime(format_string) cleaned_comment = { "comment_id": comment["id"],