adding current date as default for cli args

This commit is contained in:
2024-06-19 15:49:20 +02:00
parent 6fa1c5a4c3
commit bb5364d021
4 changed files with 25 additions and 9 deletions

19
util/str_to_datetime.py Normal file
View File

@@ -0,0 +1,19 @@
from datetime import datetime as dt
def datetime(s: str) -> dt:
s = s.strip()
try:
return dt.strptime(s, '%d.%m.%y %H:%M')
except ValueError:
pass
try:
tim = dt.strptime(s, '%H:%M').time()
dat = dt.now().date()
return dt.combine(dat, tim)
except ValueError:
pass
raise ValueError("The given string can not be interpreted as a datetime.")