Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why are we making DateRangeField timezone aware? #1659

Open
Thutmose3 opened this issue May 14, 2024 · 3 comments
Open

Why are we making DateRangeField timezone aware? #1659

Thutmose3 opened this issue May 14, 2024 · 3 comments

Comments

@Thutmose3
Copy link

Dates in Django do not have timezones, as they are just dates, only DateTime has this, which makes sence.

Here we make DateRangeField timezone aware:

class DateRangeField(RangeField):

Why is that? It's causing really strange behaviour.

And when removing the timezone code for this, all is good with any timezone i try.

@Thutmose3
Copy link
Author

I created a PR for this here: #1660

@groetzbachc
Copy link

I would really appreciate if this could be looked into by the maintainers. For me this is not just "strange behaviour" but a straight up bug. I would even go as far and argue that the input should be left as datetime.date and not turned into datetime.datetime. Even the official Django docs argue for not mixing dates and datetimes.

To specify why I classify this issue as bug:
Consider the input "2024-06-27" which is currently transformed to datetime value.start=datetime.datetime(2024, 8, 27, 0, 0, tzinfo=<current time zone>).
In a query, field_name__range=(value.start, value.end) includes instances with field_name = datetime.date(2024, 08, 26) (one day before).
This does not happen when removing either timezones as done in #1660 or leaving the inputs as date.

@carltongibson
Copy link
Owner

Sorry, PR had no tests. I've commented asking for such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants