Yeah, sorry I didn't get around to this until so close to the
deadline. December was a lot crazier for me than I had hoped. ☹
One thing I'll note is that this PR to allow using zoneinfo
timezones is mostly just adding tests. The substantive
changes to the codebase are very light, and there should be no
behavioral change for users of pytz or current users of other time
zone providers (assuming such people exist). There appears to be a
nominal attempt to support non-pytz zones in
django.utils.timezones, so possibly this PR just improves support
that was already intended to be present in the first place.
I do think it would be good to make it possible for people to do some
conversion over ahead of time if possible, particularly since no
deprecation warnings will be issued prior to the change away from
pytz.
Best,
Paul
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/cc28eb1d-3f24-4103-8a57-6835e775b11an%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/7e22fc29-d4eb-1141-e389-56d2ace9a0af%40ganssle.io.
1. Implement is_dst mostly like it's implemented in pytz-deprecation-shim, where explicitly passing `is_dst=None` will raise an exception on ambiguous and imaginary times, leaving it blank is a no-op, and specifying `True` or `False` sets the `fold` parameter to match what `pytz` would give you. If people are already able to use `make_aware` with non-pytz zones, this may introduce new exceptions into their code, which would not necessarily be backwards compatible. Depending on how broken support for non-pytz zones is "on the ground", this may not matter at all, since making theoretically backwards-incompatible changes to an otherwise broken function is not really backwards incompatible...
2. Implement is_dst, but require opt-in for the error-raising behavior: `is_dst=None` would raise errors only in the `pytz` case, `is_dst='error'` would always raise errors, and `is_dst=True` and `is_dst=False` would set the `fold` parameter to match what `pytz` would give you. This should be effectively backwards compatible, since leaving `is_dst` unspecified would keep the behavior as-is and specifying True/False with a non-pytz zone never worked anyway (and as such might be considered a bug anyway).
3. Leave as-is. External users who want to replicate `is_dst`-style behavior can use wrapper functions or subclasses to accomplish this anyway. I think the most annoying one to replicate would be date truncation logic. People who want truncation with `is_dst` support would either want to wrap the output of their `.annotate` calls (e.g. `model = DTModel.objects.annotate(truncated_start=TruncDay('start_datetime')).get(); model.truncated_start = apply_is_dst(model.truncated_start, is_dst=True)`), or they would want to create a parallel truncation hierarchy subclassing from TruncBase, where is_dst support is added in convert_value (or TruncBase is monkey-patched to this effect).
4. Leave `make_aware` as is, but add `is_dst` support into TruncBase.convert_value, similar to what I'm doing in `django.forms.utils.from_current_timezone` — in that case we're just raising exceptions on error and not trying to re-implement `is_dst` in terms of `fold`, which is trickier than you'd think, but the implementation in pytz_deprecation_shim is pretty well-tested, so I am not too worried about it.
Let me know what y'all want to do. I can also do this as a separate PR, as I think the "support zoneinfo" PR works as a standalone.
One thing to consider is that even if we don't do this for 3.2, if 4.0 comes with a "hard switch" to zoneinfo, we'll need to decide what the behavior of `is_dst` is going to be, and what the future if `is_dst` looks like. One advantage that pytz_deprecation_shim has over Django is that it's replicating pytz's implementation, so it already needs a similar exception hierarchy to pytz's. Django would need to introduce its own exception hierarchy for "what happens when you try and create a datetime that is ambiguous or doesn't exist." There's also the problem that not all folds or gaps are created by DST transitions, and it's not entirely clear what `is_dst` should do in that case. Probably the easiest thing is to leave it in place and make it well-defined, or to deprecate `is_dst` in favor of a new argument like `preferred_fold` that uses the semantics of folds instead of the semantics of DST.
Best,
Paul
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAKFO%2Bx7sbbZCeJmPGmaf%2BfS8ASCYm-WVxS37nKZAEKFsJ%2BgxXA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAJwKpyRVDFG%3DUhA2uzmoCPN0BM%2BQS0oGQgmtJiZQdG1Oc1mjZw%40mail.gmail.com.