Opened 5 years ago

Closed 5 years ago

#30922 closed Bug (fixed)

Admin's date_hierarchy excludes 31 october when using timezone with DST in northern hemisphere.

Reported by: Erwin Junge Owned by: Erwin Junge
Component: contrib.admin Version: dev
Severity: Normal Keywords: date_hierarchy
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://code.djangoproject.com/ticket/28933 introduced a subtle bug where it accidentally excludes 31 october in the admin date_hierarchy filter after selecting october. The underlying reason is that the generated sql has < 2019-10-31 as opposed to < 2019-11-01 as it should be. This in turn is caused by applying the timezone for 2019-10-01 (with DST in countries in the northern hemisphere) to the date used for 2019-11-01. This causes the date conversion to actually operate on 2019-10-31 23:00 instead of 2019-11-01 00:00. It's a bit hard to explain in words, PR incoming that hopefully explains better in code.

Change History (11)

comment:1 by Erwin Junge, 5 years ago

Owner: changed from nobody to Erwin Junge
Status: newassigned

comment:3 by Erwin Junge, 5 years ago

Has patch: set

comment:4 by Erwin Junge, 5 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Mariusz Felisiak, 5 years ago

Triage Stage: AcceptedUnreviewed

Please don't accept your own tickets.

comment:6 by Mariusz Felisiak, 5 years ago

Summary: admin date_hierarchy excludes 31 october when using timezone with DST in northern hemisphereAdmin's date_hierarchy excludes 31 october when using timezone with DST in northern hemisphere.
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug
Version: 2.2master

Great catch.

comment:7 by Carlton Gibson, 5 years ago

Resolution: duplicate
Status: assignedclosed

I think this is a Duplicate of #29724. (I'm going to close as such. Erwin please review and re-open/reply here/there if that's incorrect.)

comment:8 by Mariusz Felisiak, 5 years ago

I don't think that it's a duplicate. This one is strictly related with DST, i.e. date_hierarchy uses date 2019-11-01+03:00 instead of 2019-11-01+02:00 (that doesn't exist in this timezone) because date_to is in DST and date_from is not.

comment:9 by Carlton Gibson, 5 years ago

Resolution: duplicate
Status: closednew

OK, happy to re-open if you think they're separate.

comment:10 by Mariusz Felisiak, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: newclosed

In a6cb8ec:

Fixed #30922 -- Fixed ModelAdmin.date_hierarchy queries with DST changes.

There was an issue where admin date_hierarchy didn't render last day of
a month in DST-switch month.

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