Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#30749 closed Bug (duplicate)

Admin date_hierarchy filter by month of October 2019 does not include October 31th when TZ is set to Europe/Paris (UTC+2)

Reported by: yab Owned by: nobody
Component: contrib.admin Version: 2.2
Severity: Normal Keywords: timezone daylight saving time
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Steps to reproduces:

  • set USE_TZ = True and TIME_ZONE = 'Europe/Paris' in settings
  • use sqlite db
  • Create a model (Event) with a datefield
  • Create modelAdmin (EventAdmin) with date_hierarchy on that datefield
  • Create an Event on 2019-10-31 (or 2018-10-31)
  • Filter by date_hierarchy on Admin list page : it does not include that Event.

Probably linked to the fact that the DST in Paris is in october (Sunday 2019-10-27) while in others Timezones it is in November (Sunday 2019-03-11).
Bug maybe due to pytz ?
Bug maybe due to the way date_hierarchy calculates date range in django/contrib/admin/views/main.py (lines 164-167)

                elif month:
                    # In this branch, from_date will always be the first of a
                    # month, so advancing 32 days gives the next month.
                    to_date = (from_date + timedelta(days=32)).replace(day=1)

can be uncorrectly fixed by setting:

 to_date = (from_date + timedelta(days=32, hours = XXX)).replace(day=1)

where XXX = 3 (or something like that)

Change History (6)

comment:1 by Carlton Gibson, 5 years ago

Duplicate of #29724.

comment:2 by Carlton Gibson, 5 years ago

Resolution: duplicate
Status: newclosed

in reply to:  2 comment:3 by yab, 5 years ago

Replying to Carlton Gibson:
Hello, thanks for reading this ticket. It may be a different problem than the #29724 ticket. I just told it to ahbk on github (/django/pull/10380).

comment:4 by Carlton Gibson, 5 years ago

Hi yab.

Seems similar enough: both have a incorrect result on the boundary condition. If you can add a test case showing your particular case to the other ticket, or the PR on GitHub, we can make sure that it passes for any proposed solution. Happy to re-open a separate ticket if we can pin down that there are actually two bugs, but it doesn't look that way with what we have right now. (I think 🙂)

in reply to:  4 comment:5 by yab, 5 years ago

Hi Carlton,
Below ticket #29724, I just proposed two solutions to those two distinct (I think) issues, one in templatestags/admin_list.py and one views/mains.py.

Replying to Carlton Gibson

comment:6 by Mariusz Felisiak, 4 years ago

That's rather a duplicate of #30922.

Note: See TracTickets for help on using tickets.
Back to Top