mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-28 19:40:54 +00:00
enrich for optional tzinfo
This commit is contained in:
parent
c74ac9c225
commit
74d21f011c
1 changed files with 2 additions and 2 deletions
|
@ -47,7 +47,7 @@ else:
|
||||||
TRIGGER = datetime | None
|
TRIGGER = datetime | None
|
||||||
|
|
||||||
|
|
||||||
def date_to_datetime(d: date) -> datetime:
|
def date_to_datetime(d: date, tzinfo=vobject.icalendar.utc) -> datetime:
|
||||||
"""Transform any date to a UTC datetime.
|
"""Transform any date to a UTC datetime.
|
||||||
|
|
||||||
If ``d`` is a datetime without timezone, return as UTC datetime. If ``d``
|
If ``d`` is a datetime without timezone, return as UTC datetime. If ``d``
|
||||||
|
@ -58,7 +58,7 @@ def date_to_datetime(d: date) -> datetime:
|
||||||
d = datetime.combine(d, datetime.min.time())
|
d = datetime.combine(d, datetime.min.time())
|
||||||
if not d.tzinfo:
|
if not d.tzinfo:
|
||||||
# NOTE: using vobject's UTC as it wasn't playing well with datetime's.
|
# NOTE: using vobject's UTC as it wasn't playing well with datetime's.
|
||||||
d = d.replace(tzinfo=vobject.icalendar.utc)
|
d = d.replace(tzinfo=tzinfo)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue