Skip to content
This repository has been archived by the owner on Apr 1, 2021. It is now read-only.

Commit

Permalink
Fix negative time error in Update news
Browse files Browse the repository at this point in the history
  • Loading branch information
takidog committed Oct 11, 2019
1 parent efc6609 commit 1f8c005
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/news/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,13 @@ def update_news(news_id=None, **kwargs):
if kwargs.get('expireTime', origin_news.get('expireTime', False)):
utc = time_format(kwargs.get(
'expireTime', origin_news.get('expireTime', False)))
expire_time_seconds = (utc-datetime.datetime.utcnow()).seconds
expire_time_seconds = int(
(utc-datetime.datetime.utcnow()).total_seconds())
if expire_time_seconds < 0:
expire_time_seconds = None
else:
news_data["expireTime"] = time_format(kwargs.get(
'expireTime', False)).isoformat(timespec="seconds")+"Z"
data_dumps = json.dumps(news_data, ensure_ascii=False)

red_news.set(name=news_name,
Expand Down

0 comments on commit 1f8c005

Please sign in to comment.