Opened 10 years ago
Closed 10 years ago
#26317 closed Bug (invalid)
django.utils.duration.duration_string() doesn't support negative durations
| Reported by: | Nikolas N | Owned by: | nobody |
|---|---|---|---|
| Component: | Utilities | Version: | 1.9 |
| Severity: | Normal | Keywords: | duration, timedelta |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
duration_string() formats timedeltas like this:
duration_string(timedelta(hours=1)) '01:00:00'
Given a negative hour, I would expect duration_string() to return something like "-01:00:00". Instead, you get this:
duration_string(timedelta(hours=-1)) '-1 23:00:00'
Note:
See TracTickets
for help on using tickets.
The behavior seems consistent with
str(timedelta(hours=-1))which gives'-1 day, 23:00:00'. See Python's docs that explains normalization of negative values.