Skip to content

Commit 5f75f47

Browse files
(PC-38798)[BO] feat: better format one-day datespan
1 parent 820f5a7 commit 5f75f47

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

api/src/pcapi/routes/backoffice/filters.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,14 @@ def format_timespan(timespan: psycopg2.extras.DateTimeRange) -> str:
297297
def format_datespan(datespan: psycopg2.extras.DateRange) -> str:
298298
if not datespan:
299299
return ""
300-
start = datespan.lower.strftime("%d/%m/%Y")
300+
start_date = datespan.lower
301+
start = start_date.strftime("%d/%m/%Y")
301302
if datespan.upper:
302303
# upper bound is exclusive, and we want to show the last day included in the date range
303-
end = (datespan.upper - datetime.timedelta(days=1)).strftime("%d/%m/%Y")
304+
end_date = datespan.upper - datetime.timedelta(days=1)
305+
if start_date == end_date:
306+
return start
307+
end = end_date.strftime("%d/%m/%Y")
304308
else:
305309
end = "∞"
306310
return f"{start}{end}"

0 commit comments

Comments
 (0)