mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Refs #32365 -- Allowed use of non-pytz timezone implementations.
This commit is contained in:
parent
73ffc73b68
commit
10d1261984
11 changed files with 477 additions and 306 deletions
|
@ -943,21 +943,24 @@ appropriate entities.
|
|||
:class:`~datetime.datetime`. If ``timezone`` is set to ``None``, it
|
||||
defaults to the :ref:`current time zone <default-current-time-zone>`.
|
||||
|
||||
The ``pytz.AmbiguousTimeError`` exception is raised if you try to make
|
||||
``value`` aware during a DST transition where the same time occurs twice
|
||||
(when reverting from DST). Setting ``is_dst`` to ``True`` or ``False`` will
|
||||
avoid the exception by choosing if the time is pre-transition or
|
||||
post-transition respectively.
|
||||
When using ``pytz``, the ``pytz.AmbiguousTimeError`` exception is raised if
|
||||
you try to make ``value`` aware during a DST transition where the same time
|
||||
occurs twice (when reverting from DST). Setting ``is_dst`` to ``True`` or
|
||||
``False`` will avoid the exception by choosing if the time is
|
||||
pre-transition or post-transition respectively.
|
||||
|
||||
The ``pytz.NonExistentTimeError`` exception is raised if you try to make
|
||||
``value`` aware during a DST transition such that the time never occurred.
|
||||
For example, if the 2:00 hour is skipped during a DST transition, trying to
|
||||
make 2:30 aware in that time zone will raise an exception. To avoid that
|
||||
you can use ``is_dst`` to specify how ``make_aware()`` should interpret
|
||||
such a nonexistent time. If ``is_dst=True`` then the above time would be
|
||||
interpreted as 2:30 DST time (equivalent to 1:30 local time). Conversely,
|
||||
if ``is_dst=False`` the time would be interpreted as 2:30 standard time
|
||||
(equivalent to 3:30 local time).
|
||||
When using ``pytz``, the ``pytz.NonExistentTimeError`` exception is raised
|
||||
if you try to make ``value`` aware during a DST transition such that the
|
||||
time never occurred. For example, if the 2:00 hour is skipped during a DST
|
||||
transition, trying to make 2:30 aware in that time zone will raise an
|
||||
exception. To avoid that you can use ``is_dst`` to specify how
|
||||
``make_aware()`` should interpret such a nonexistent time. If
|
||||
``is_dst=True`` then the above time would be interpreted as 2:30 DST time
|
||||
(equivalent to 1:30 local time). Conversely, if ``is_dst=False`` the time
|
||||
would be interpreted as 2:30 standard time (equivalent to 3:30 local time).
|
||||
|
||||
The ``is_dst`` parameter has no effect when using non-``pytz`` timezone
|
||||
implementations.
|
||||
|
||||
.. function:: make_naive(value, timezone=None)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue