Open shribe opened 2 years ago
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.