mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
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.
This commit is contained in:
parent
1cf60ce601
commit
bb61f0186d
33 changed files with 115 additions and 102 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue