summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCarlton Gibson <carlton.gibson@noumenal.es>2022-03-23 12:15:36 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-03-24 06:29:50 +0100
commitbb61f0186d5c490caa44f3e3672d81e14414d33c (patch)
tree71e682d415e4640fd1e950af0e4921b2af57ea60 /docs
parent1cf60ce6017d904024ee132f7edae0b4b821a954 (diff)
Refs #32365 -- Removed internal uses of utils.timezone.utc alias.
Remaining test case ensures that uses of the alias are mapped canonically by the migration writer.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/database-functions.txt16
-rw-r--r--docs/topics/i18n/timezones.txt2
2 files changed, 7 insertions, 11 deletions
diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt
index 28d489d256..acca4a7c68 100644
--- a/docs/ref/models/database-functions.txt
+++ b/docs/ref/models/database-functions.txt
@@ -358,8 +358,7 @@ as ``__(lookup_name)``, e.g. ``__year``.
Since ``DateField``\s don't have a time component, only ``Extract`` subclasses
that deal with date-parts can be used with ``DateField``::
- >>> from datetime import datetime
- >>> from django.utils import timezone
+ >>> from datetime import datetime, timezone
>>> from django.db.models.functions import (
... ExtractDay, ExtractMonth, ExtractQuarter, ExtractWeek,
... ExtractIsoWeekDay, ExtractWeekDay, ExtractIsoYear, ExtractYear,
@@ -409,8 +408,7 @@ Each class is also a ``Transform`` registered on ``DateTimeField`` as
``DateTimeField`` examples::
- >>> from datetime import datetime
- >>> from django.utils import timezone
+ >>> from datetime import datetime, timezone
>>> from django.db.models.functions import (
... ExtractDay, ExtractHour, ExtractMinute, ExtractMonth,
... ExtractQuarter, ExtractSecond, ExtractWeek, ExtractIsoWeekDay,
@@ -447,6 +445,7 @@ to that timezone before the value is extracted. The example below converts to
the Melbourne timezone (UTC +10:00), which changes the day, weekday, and hour
values that are returned::
+ >>> from django.utils import timezone
>>> import zoneinfo
>>> melb = zoneinfo.ZoneInfo('Australia/Melbourne') # UTC+10:00
>>> with timezone.override(melb):
@@ -620,10 +619,9 @@ with less precision. ``expression`` can have an ``output_field`` of either
Since ``DateField``\s don't have a time component, only ``Trunc`` subclasses
that deal with date-parts can be used with ``DateField``::
- >>> from datetime import datetime
+ >>> from datetime import datetime, timezone
>>> from django.db.models import Count
>>> from django.db.models.functions import TruncMonth, TruncYear
- >>> from django.utils import timezone
>>> start1 = datetime(2014, 6, 15, 14, 30, 50, 321, tzinfo=timezone.utc)
>>> start2 = datetime(2015, 6, 15, 14, 40, 2, 123, tzinfo=timezone.utc)
>>> start3 = datetime(2015, 12, 31, 17, 5, 27, 999, tzinfo=timezone.utc)
@@ -699,12 +697,11 @@ datetimes with less precision. ``expression`` must have an ``output_field`` of
Usage example::
- >>> from datetime import date, datetime
+ >>> from datetime import date, datetime, timezone
>>> from django.db.models import Count
>>> from django.db.models.functions import (
... TruncDate, TruncDay, TruncHour, TruncMinute, TruncSecond,
... )
- >>> from django.utils import timezone
>>> import zoneinfo
>>> start1 = datetime(2014, 6, 15, 14, 30, 50, 321, tzinfo=timezone.utc)
>>> Experiment.objects.create(start_datetime=start1, start_date=start1.date())
@@ -753,10 +750,9 @@ with less precision. ``expression`` can have an ``output_field`` of either
Since ``TimeField``\s don't have a date component, only ``Trunc`` subclasses
that deal with time-parts can be used with ``TimeField``::
- >>> from datetime import datetime
+ >>> from datetime import datetime, timezone
>>> from django.db.models import Count, TimeField
>>> from django.db.models.functions import TruncHour
- >>> from django.utils import timezone
>>> start1 = datetime(2014, 6, 15, 14, 30, 50, 321, tzinfo=timezone.utc)
>>> start2 = datetime(2014, 6, 15, 14, 40, 2, 123, tzinfo=timezone.utc)
>>> start3 = datetime(2015, 12, 31, 17, 5, 27, 999, tzinfo=timezone.utc)
diff --git a/docs/topics/i18n/timezones.txt b/docs/topics/i18n/timezones.txt
index 4c6aa58ba2..318a16d6ab 100644
--- a/docs/topics/i18n/timezones.txt
+++ b/docs/topics/i18n/timezones.txt
@@ -151,7 +151,7 @@ used.
However, :ref:`as explained above <naive-datetime-objects>`, this isn't
entirely reliable, and you should always work with aware datetimes in UTC
in your own code. For instance, use :meth:`~datetime.datetime.fromtimestamp`
- and set the ``tz`` parameter to :data:`~django.utils.timezone.utc`.
+ and set the ``tz`` parameter to :attr:`~datetime.timezone.utc`.
Selecting the current time zone
-------------------------------