From 442e42c7eaec0cfe1ba95e93eb08ce962b563322 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 3 Dec 2023 21:04:57 -0800 Subject: [PATCH] Use timedelta to deal with negative unix timestamps. --- bringrss/objects.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bringrss/objects.py b/bringrss/objects.py index e892fb0..92d0917 100644 --- a/bringrss/objects.py +++ b/bringrss/objects.py @@ -1397,14 +1397,20 @@ class News(ObjectBase): @property def published_string(self): published = self.published - published = datetime.datetime.utcfromtimestamp(published) + if published < 0: + published = datetime.datetime.utcfromtimestamp(0) + datetime.timedelta(seconds=published) + else: + published = datetime.datetime.utcfromtimestamp(published) published = published.strftime('%Y-%m-%d %H:%M') return published @property def published_string_local(self): published = self.published - published = datetime.datetime.fromtimestamp(published) + if published < 0: + published = datetime.datetime.fromtimestamp(0) + datetime.timedelta(seconds=published) + else: + published = datetime.datetime.fromtimestamp(published) published = published.strftime('%Y-%m-%d %H:%M') return published