timezone aware publish datetime

also as datetime over just date
This commit is contained in:
Corban-Lee Jones 2024-07-11 23:35:04 +01:00
parent 5f805f60a8
commit 65586d7859

View File

@ -4,7 +4,7 @@ import json
import copy
import logging
from dataclasses import dataclass
from datetime import datetime
from datetime import datetime, timezone
from abc import ABC, abstractmethod
import aiohttp
@ -55,7 +55,7 @@ class RSSItem:
description = entry.get('description', None)
pub_date = entry.get('published_parsed', None)
pub_date = datetime(*pub_date[0:-2] if pub_date else None)
pub_date = datetime(*pub_date[0:6], tzinfo=timezone.utc)
image_url = entry.get("media_content", [{}])[0].get("url")
@ -293,7 +293,7 @@ class Subscription(DjangoDataModel):
"title": item.pop("article_title_mutators"),
"description": item.pop("article_desc_mutators")
}
item["published_threshold"] = datetime.strptime(item["published_threshold"], "%Y-%m-%d")
item["published_threshold"] = datetime.strptime(item["published_threshold"], "%Y-%m-%dT%H:%M:%S%z")
return item