2024-06-19 14:55:39 +02:00
|
|
|
from model.TimeSlot import TimeSlot
|
2024-06-13 10:38:43 +02:00
|
|
|
|
|
|
|
|
|
2024-06-19 15:49:20 +02:00
|
|
|
def convert_to_table(time_slot_list: list[TimeSlot]) -> str:
|
2024-06-13 11:59:46 +02:00
|
|
|
widths = [30, 26, 26]
|
2024-06-13 10:38:43 +02:00
|
|
|
|
|
|
|
|
r_str = f"+{'-'*(widths[0]+2)}+{'-'*(widths[1]+2)}+{'-'*(widths[2]+2)}+\n"
|
2024-06-13 11:59:46 +02:00
|
|
|
r_str += f"| {'Name':<30} | {'Startzeitpunkt':<26} | {'Endzeitpunkt':<26} |\n"
|
2024-06-13 10:38:43 +02:00
|
|
|
r_str += f"+{'-'*(widths[0]+2)}+{'-'*(widths[1]+2)}+{'-'*(widths[2]+2)}+\n"
|
|
|
|
|
|
|
|
|
|
for time_slot in time_slot_list:
|
2024-06-13 11:59:46 +02:00
|
|
|
r_str += f"| {time_slot.name:<30} | {str(time_slot.start):<26} | {str(time_slot.end):<26} |\n"
|
2024-06-13 10:38:43 +02:00
|
|
|
|
|
|
|
|
r_str += f"+{'-'*(widths[0]+2)}+{'-'*(widths[1]+2)}+{'-'*(widths[2]+2)}+"
|
|
|
|
|
|
|
|
|
|
return r_str
|