22
33import asyncio
44import colorsys
5+ import datetime
56import json
67import logging
78import os
89import pathlib
910import struct
1011import sys
1112from collections .abc import Callable
12- from datetime import UTC , datetime
1313from functools import wraps
1414from typing import TYPE_CHECKING , Any , Generic , Self , TypeVar , cast
1515from urllib .parse import quote
4040 "MISSING" ,
4141 "handle_user_ids" ,
4242 "_is_submodule" ,
43+ "date_to_datetime_with_z" ,
4344)
4445
4546T_co = TypeVar ("T_co" , covariant = True )
@@ -90,7 +91,7 @@ def stream_supports_rgb(stream: Any) -> bool:
9091 return False
9192
9293
93- def parse_timestamp (timestamp : str ) -> datetime :
94+ def parse_timestamp (timestamp : str ) -> datetime . datetime :
9495 """
9596 Parses a timestamp in ISO8601 format to a datetime object.
9697
@@ -104,7 +105,7 @@ def parse_timestamp(timestamp: str) -> datetime:
104105 datetime.datetime
105106 The parsed datetime object.
106107 """
107- return datetime .fromisoformat (timestamp )
108+ return datetime .datetime . fromisoformat (timestamp )
108109
109110
110111class ColourFormatter (logging .Formatter ):
@@ -733,7 +734,7 @@ def chunk_list(sequence: list[Any], n: int) -> Generator[Any, Any, Any]:
733734 yield sequence [i : i + n ]
734735
735736
736- def url_encode_datetime (dt : datetime ) -> str :
737+ def url_encode_datetime (dt : datetime . datetime ) -> str :
737738 """
738739 Formats a datetime object to an RFC 3339 compliant string and URL-encodes it.
739740 If the datetime object does not have a timezone, it is converted to UTC first.
@@ -748,7 +749,7 @@ def url_encode_datetime(dt: datetime) -> str:
748749 str
749750 The URL encoded parsed datetime object.
750751 """
751- formatted_dt = dt .replace (tzinfo = UTC ).isoformat () if dt .tzinfo is None else dt .isoformat ()
752+ formatted_dt = dt .replace (tzinfo = datetime . UTC ).isoformat () if dt .tzinfo is None else dt .isoformat ()
752753
753754 return quote (formatted_dt )
754755
@@ -841,4 +842,8 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
841842
842843
843844def _is_submodule (parent : str , child : str ) -> bool :
844- return parent == child or child .startswith (parent + "." )
845+ return parent == child or child .startswith (f"{ parent } ." )
846+
847+
848+ def date_to_datetime_with_z (date : datetime .date ) -> str :
849+ return f"{ datetime .datetime .combine (date , datetime .time (0 , 0 )).isoformat ()} Z"
0 commit comments