#! python3  # noqa: E265

# Standard library
from dataclasses import dataclass
from datetime import datetime

# Plugin
from oslandia.toolbelt.qt_utils import localize_qdatetime


@dataclass
class RssItem:
    """Dataclass describing a RSS channel item."""

    abstract: str | None = None
    authors: list[str | None] | None = None
    categories: list[str | None] | None = None
    date_pub: tuple[int, ...] | None = None
    guid: str | None = None
    image_length: str | None = None
    image_type: str | None = None
    image_url: str | None = None
    title: str | None = None
    url: str | None = None

    def get_date(self):
        """
        Date in readable format
        """
        # date_pub contains tzinfo which datetime doesn't need
        date_pub = datetime(*self.date_pub[:6]).date()
        return localize_qdatetime(date_pub)
