-
-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Document that naïve datetime objects represent local time #91384
Comments
Currently, the
This was accurate in Python 2.7, but as of Python 3, the picture is a bit more nuanced. We make reference to this in the documentation for I have written a blog post about why this is the case: https://blog.ganssle.io/articles/2022/04/naive-local-datetimes.html and made reference to this behavior in an earlier blog post about |
There is any number of "systems" that a naïve datetime can refer to: A database value, something received over the wire or read from a file, or indeed, the local time of the computer on which the program is currently running. You cannot know which point in time it refers to or what its timezone is without some sort of out-of-band knowledge. That The underlying problem is that |
@AndersMunch I'm not raising this issue to suggest that we change anything about the nature of As I noted in my article on the subject, the design that we already have is probably about as good as we can do. We cannot have |
@pganssle but it isn't currently true. For example, DBAPI implementations[1] return naïve datetime's that are not in the current program local time. What they mean depends on context and convention, and quite often that convention will be that database times are UTC, or database server time, or some stipulated "server local time". The one thing it won't be is the system time of whatever database client that is currently connecting, because that would be broken. Naïve datetime's, as found in the wild, don't obey your mental model. Take care that you distinguish between times that are local in the sense of being an imprecise notation for a single precise point in time, like [1] Not all of them, databases these days have datatypes with timezone information, but I've mostly encountered the other form. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: