Use timedelta to deal with negative unix timestamps.
This commit is contained in:
parent
fa66719f97
commit
442e42c7ea
1 changed files with 8 additions and 2 deletions
|
@ -1397,6 +1397,9 @@ class News(ObjectBase):
|
||||||
@property
|
@property
|
||||||
def published_string(self):
|
def published_string(self):
|
||||||
published = self.published
|
published = self.published
|
||||||
|
if published < 0:
|
||||||
|
published = datetime.datetime.utcfromtimestamp(0) + datetime.timedelta(seconds=published)
|
||||||
|
else:
|
||||||
published = datetime.datetime.utcfromtimestamp(published)
|
published = datetime.datetime.utcfromtimestamp(published)
|
||||||
published = published.strftime('%Y-%m-%d %H:%M')
|
published = published.strftime('%Y-%m-%d %H:%M')
|
||||||
return published
|
return published
|
||||||
|
@ -1404,6 +1407,9 @@ class News(ObjectBase):
|
||||||
@property
|
@property
|
||||||
def published_string_local(self):
|
def published_string_local(self):
|
||||||
published = self.published
|
published = self.published
|
||||||
|
if published < 0:
|
||||||
|
published = datetime.datetime.fromtimestamp(0) + datetime.timedelta(seconds=published)
|
||||||
|
else:
|
||||||
published = datetime.datetime.fromtimestamp(published)
|
published = datetime.datetime.fromtimestamp(published)
|
||||||
published = published.strftime('%Y-%m-%d %H:%M')
|
published = published.strftime('%Y-%m-%d %H:%M')
|
||||||
return published
|
return published
|
||||||
|
|
Loading…
Reference in a new issue