-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Naive datetime should be treated as local timezone. UTC datetimes should be timezone aware. #1658
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
Comments
As of #1621 (released in v12.7), |
I disagree, that pull request only addressees the second sentence from the issue title. Using aware datetimes removes the need to use "naive-utc", but at the moment naive datetimes are still treated as utc by the library. On a side note: |
Sorry, I don't really understand what you mean by "but at the moment naive datetimes are still treated as utc by the library." Or are you talking about JobQueue? I'll update the changelog. |
I'm talking about datetime objects being provided by a user. I guess it's only relevant to job queue stuff at the moment. It also affects any future methods that will accept a datetime/time from a user, since those methods will probably use the same helpers. |
Mh okay. E.g. Just FYI: We're planning on adding |
We discussed this again internally and decided to stick with the way it is now, i.e. tread naive datetimes as UTC by default. |
Caused by #1506(#1505) #1485(#1362)
I believe local timezone is the expected default for naive datetime objects. Breaking those expectations will lead to unnecessary surprises for the users. It will also lead to awkward conversions if another library that does follow this convention is used.
Python's
datetime.fromtimestamp
anddatetime.astimezone
assume local timezone for naive objects. There are three warnings in datetime docs that start with "Because naive datetime objects are treated by many datetime methods as local times, it is preferred to use aware datetimes to represent times in UTC."Using utc time is surely more sane than using local time, but the better way to do that is timezone aware datetimes, not naive-utc datetimes. For example Message.date should be timezone aware.
The text was updated successfully, but these errors were encountered: