Add common converters date_to_datetime & to_just_number

master
Felix Stupp 11 months ago
parent 5b4dd2e18b
commit 90600abf4a
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -1,3 +1,7 @@
from ._converter import (
date_to_datetime,
to_just_number,
)
from ._itertools import ( from ._itertools import (
all_same, all_same,
fix_iter, fix_iter,
@ -15,8 +19,10 @@ from ._subprocess import (
__all__ = [ __all__ = [
"all_same", "all_same",
"call", "call",
"date_to_datetime",
"fix_iter", "fix_iter",
"iter_lookahead", "iter_lookahead",
"limit_iter", "limit_iter",
"to_just_number",
"update_bool_value", "update_bool_value",
] ]

@ -0,0 +1,15 @@
from datetime import date, datetime
from typing import (
Optional,
)
def date_to_datetime(d: date) -> datetime:
return datetime(d.year, d.month, d.day)
def to_just_number(name: str) -> Optional[int]:
try:
return int(name)
except ValueError:
return None
Loading…
Cancel
Save