No need for DateOrDateTime type alias
This commit is contained in:
parent
e7ae7123f6
commit
e38e357f63
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
from datetime import date, datetime, timezone
|
from datetime import date, datetime, timezone
|
||||||
|
|
||||||
DateOrDateTime = datetime | date
|
|
||||||
|
|
||||||
|
def as_date(d: datetime | date) -> date:
|
||||||
def as_date(d: DateOrDateTime) -> date:
|
|
||||||
"""Convert datetime to date."""
|
"""Convert datetime to date."""
|
||||||
match d:
|
match d:
|
||||||
case datetime():
|
case datetime():
|
||||||
|
@ -16,7 +14,7 @@ def as_date(d: DateOrDateTime) -> date:
|
||||||
raise TypeError(f"Unsupported type: {type(d)}")
|
raise TypeError(f"Unsupported type: {type(d)}")
|
||||||
|
|
||||||
|
|
||||||
def as_datetime(d: DateOrDateTime) -> datetime:
|
def as_datetime(d: datetime | date) -> datetime:
|
||||||
"""Date/time of event."""
|
"""Date/time of event."""
|
||||||
match d:
|
match d:
|
||||||
case datetime():
|
case datetime():
|
||||||
|
|
Loading…
Reference in a new issue