mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
fix for Python < 3.10
This commit is contained in:
parent
63ea229865
commit
4bbbc3c384
1 changed files with 8 additions and 2 deletions
|
@ -21,11 +21,12 @@
|
|||
|
||||
|
||||
import math
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
from datetime import date, datetime, timedelta, timezone
|
||||
from itertools import chain
|
||||
from typing import (Callable, Iterable, Iterator, List, Optional, Sequence,
|
||||
Tuple)
|
||||
Tuple, Union)
|
||||
|
||||
import vobject
|
||||
|
||||
|
@ -39,6 +40,11 @@ DATETIME_MAX: datetime = datetime.max.replace(tzinfo=timezone.utc)
|
|||
TIMESTAMP_MIN: int = math.floor(DATETIME_MIN.timestamp())
|
||||
TIMESTAMP_MAX: int = math.ceil(DATETIME_MAX.timestamp())
|
||||
|
||||
if sys.version_info < (3, 10):
|
||||
TRIGGER = Union[datetime, None]
|
||||
else:
|
||||
TRIGGER = datetime | None
|
||||
|
||||
|
||||
def date_to_datetime(d: date) -> datetime:
|
||||
"""Transform any date to a UTC datetime.
|
||||
|
@ -184,7 +190,7 @@ def prop_match(vobject_item: vobject.base.Component,
|
|||
|
||||
|
||||
def time_range_match(vobject_item: vobject.base.Component,
|
||||
filter_: ET.Element, child_name: str, trigger: datetime | None) -> bool:
|
||||
filter_: ET.Element, child_name: str, trigger: TRIGGER) -> bool:
|
||||
"""Check whether the component/property ``child_name`` of
|
||||
``vobject_item`` matches the time-range ``filter_``."""
|
||||
# supporting since 3.5.4 now optional trigger (either absolute or relative offset)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue