adding definition for timespans for ls and acc command

This commit is contained in:
2025-11-25 11:52:10 +01:00
parent 0e48ce265c
commit 5f55aa32fa
4 changed files with 46 additions and 16 deletions

12
util/timeslotlist.py Normal file
View File

@@ -0,0 +1,12 @@
import re
from datetime import timedelta
from model.TimeSlot import TimeSlot
def accumulate_duration(timeslots: list[TimeSlot]) -> timedelta:
return sum([ts.duration() for ts in timeslots], start=timedelta(0))
def filter(timeslots: list[TimeSlot], query: str) -> list[TimeSlot]:
pattern = re.compile(query)
return [ts for ts in timeslots if pattern.search(ts.name)]