Change pybind11_abseil `absl::Time` to-python conversion to return a datetime…
Change pybind11_abseil `absl::Time` to-python conversion to return a datetime object with UTC timezone. The original motivation for this change was to achieve compatibility with absl/python behavior (currently only used Google-internally), but it is a good change in its own right: `absl::Time` does not carry any timezone information, using the local timezone in the to-python conversion is far more complicated than using the UTC timezone, in particular because 1. it makes the to-python conversion dependent on zoneinfo or equivalent. 2. potentially (and confusingly) 3 instead of 2 timezones can appear in a from-python - to-python conversion roundtrip, e.g. starting with a non-local timezone in Python, implicit UTC timezone in C++, then the local timezone when converted back to Python. If this CL causes a breakage ---------------------------- The most likely root cause is a latent inconistency/bug in handling timezones, most notably due to a "naive" datetime object in the mix: * https://docs.python.org/3/library/datetime.html#aware-and-naive-objects In such a case, callers need to be updated to pass "aware" datetime objects instead. In the general case, this is the only way to ensure system-wide consistency. As a side-effect, such fixes are likely to prevent or resolve issues during DST transitions. PiperOrigin-RevId: 538240189
Showing
Please
register
or
sign in
to comment