aboutsummaryrefslogtreecommitdiffstats
path: root/app/utils.py
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2023-09-04 13:12:14 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2023-09-10 19:01:00 +0300
commit3b32b14f44476f2b4a450f7226523321e69c0c08 (patch)
treecfb93d411ce7938f03403790abffbd1c4d04ed54 /app/utils.py
parent70607eeb1fc4d3fb259ad7a9c07cb26afe1493cd (diff)
Improve DigestPlugin
Diffstat (limited to 'app/utils.py')
-rw-r--r--app/utils.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/utils.py b/app/utils.py
index 77ea775..626ee24 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -1,4 +1,4 @@
-import time
+from datetime import datetime
from typing import TypeAlias, Union
from app.Item import Item
from dataclasses import asdict
@@ -17,9 +17,11 @@ def get_param(key: str, params: Params) -> str:
def item_to_dict(item: Item) -> ItemDict:
- return asdict(item)
+ d = asdict(item)
+ d["pub_date"] = datetime.isoformat(d["pub_date"]) if d["pub_date"] else None
+ return d
def dict_to_item(d: ItemDict) -> Item:
pub_date, rest = (lambda pub_date, **rest: (pub_date, rest))(**d) # type: ignore
- return Item(pub_date=time.struct_time(pub_date), **rest) # type: ignore
+ return Item(pub_date=datetime.fromisoformat(pub_date), **rest) # type: ignore