Skip to content

Commit

Permalink
Improve start end dates check
Browse files Browse the repository at this point in the history
  • Loading branch information
lcfd committed Dec 1, 2023
1 parent 52eac7d commit f01f017
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cli/trakcli/report/commands/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ def report(
actual_month = datetime.today().month
actual_year = datetime.today().year

start_date = datetime.today()
end_date = datetime.today()
try:
datetime.fromisoformat(start).date()
datetime.fromisoformat(end).date()
if start:
start_date = datetime.fromisoformat(start).date()
if end:
end_date = datetime.fromisoformat(end).date()
except ValueError:
rprint(
Panel(
Expand Down Expand Up @@ -172,17 +176,14 @@ def report(
records = [
record
for record in records
if datetime.fromisoformat(record["end"]).date()
== datetime.fromisoformat(start).date()
if datetime.fromisoformat(record["end"]).date() == start_date
]
elif start and end:
records = [
record
for record in records
if datetime.fromisoformat(record["end"]).date()
>= datetime.fromisoformat(start).date()
and datetime.fromisoformat(record["end"]).date()
<= datetime.fromisoformat(end).date()
if datetime.fromisoformat(record["end"]).date() >= start_date
and datetime.fromisoformat(record["end"]).date() <= end_date
]

acc_seconds = 0
Expand Down

0 comments on commit f01f017

Please sign in to comment.