185 files
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import UTC, datetime
|
||||
from html import unescape
|
||||
import json
|
||||
import logging
|
||||
import posixpath
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from datetime import UTC, datetime
|
||||
from html import unescape
|
||||
from typing import Any
|
||||
from urllib.parse import unquote, urlsplit
|
||||
|
||||
@@ -158,7 +158,7 @@ def _parse_page_date(html: str) -> str | None:
|
||||
|
||||
page_date = re.sub(r"(\d+)(st|nd|rd|th)", r"\1", match.group(1))
|
||||
try:
|
||||
return datetime.strptime(page_date, "%A %d %B, %Y").date().isoformat()
|
||||
return datetime.strptime(page_date, "%A %d %B, %Y").date().isoformat() # noqa: DTZ007 - date-only value, timezone is irrelevant
|
||||
except ValueError:
|
||||
_LOGGER.debug("Failed to parse page date from %s", page_date)
|
||||
return None
|
||||
@@ -194,7 +194,8 @@ def _parse_trend_chart(html: str) -> tuple[list[str] | None, list[float] | None,
|
||||
return None, None, None
|
||||
|
||||
points.sort(key=lambda point: point[0])
|
||||
labels = [datetime.fromtimestamp(ts, UTC).strftime("%m-%d") for ts, _ in points]
|
||||
# ISO calendar dates: the card must not have to guess the year from "MM-DD".
|
||||
labels = [datetime.fromtimestamp(ts, UTC).strftime("%Y-%m-%d") for ts, _ in points]
|
||||
temps = [temp for _, temp in points]
|
||||
|
||||
latest_timestamp = points[-1][0]
|
||||
|
||||
Reference in New Issue
Block a user