-
Notifications
You must be signed in to change notification settings - Fork 379
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
to_datetime without time zone no longer converts DateTime to UTC #721
Comments
This bit me as well with some old code. I'm assuming the intended behavior is to set TZ to UTC only if it isn't explicitly set in the second argument and can't be inferred from the first. But that's different from treating the second argument as having a default value of "Etc/UTC". The docs only say UTC will be used "If no timezone is provided", which is arguably ambiguous. Of course timezones are already tricky enough as they are, so I'll be avoiding ambiguity in my own code as much as possible from now on. But, some clarification would be appreciated here. |
Steps to reproduce
Updating some old code, I got bitten by this. In Timex 3.3.0, I could parse a timestamp in a known local time zone as follows:
Now, in 3.7.8, the second
to_datetime
call does not change the time zone:There is a simple workaround:
Perhaps it was a deliberate change that
to_datetime
is a noop when passed an existingDateTime
and no time zone argument, but the documentation does not make this clear. Either the old functionality of shifting to UTC needs to be restored, or the documentation needs to clearly cover this exception.The text was updated successfully, but these errors were encountered: