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

View File

@@ -28,4 +28,3 @@ def create_parser():
parser_end.add_argument("-e", "--end", help="End datetime")
return parser

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.")

View File

@@ -1,7 +1,7 @@
from model.TimeSlot import TimeSlot
def convert_to_table(time_slot_list: list[TimeSlot]):
def convert_to_table(time_slot_list: list[TimeSlot]) -> str:
widths = [30, 26, 26]
r_str = f"+{'-'*(widths[0]+2)}+{'-'*(widths[1]+2)}+{'-'*(widths[2]+2)}+\n"