On Django 3.1 the `TimezoneMixin` method `get_tzname()` returns "+10" for
a "Etc/GMT-10" time zone after calling
[https://github.com/django/django/blob/febc980e89591ffdc6df86cbeac13d7dfd89876e/django/utils/timezone.py#L71
_get_timezone_name()]. This later becomes "-10" in the resulting query due
to the return value of `_prepare_tzname_delta()` of the Postgres
`DatabaseOperations` class, i.e. the time zone 10 hours east from UTC.
{{{
SELECT ... DATE_TRUNC(\'day\', "my_model"."start_at" AT TIME ZONE \'-10\')
AS "date" ...
}}}
On Django 3.2 the `TimezoneMixin` method `get_tzname()` returns
"Etc/GMT-10" for a "Etc/GMT-10" time zone after calling
[https://github.com/django/django/blob/f18da11b8a7a4f9b80798704085b37194a3627fd/django/utils/timezone.py#L76
_get_timezone_name()]. This later, incorrectly, becomes "Etc/GMT+10" in
the resulting query due to the return value of `_prepare_tzname_delta()`
of the Postgres `DatabaseOperations` class, i.e. the time zone 10 hours
west from UTC, which is the opposite direction from the behavior in Django
3.1.
{{{
SELECT ... DATE_TRUNC(\'day\', "my_model"."start_at" AT TIME ZONE
\'Etc/GMT+10\') AS "date" ...
}}}
{{{
# Django 3.1
>>> timezone._get_timezone_name(pytz.timezone("Etc/GMT-10"))
'+10'
# Django 3.2
>>> timezone._get_timezone_name(pytz.timezone("Etc/GMT-10"))
'Etc/GMT-10'
}}}
The above is the same when using Python's `zoneinfo.ZoneInfo()` too.
--
Ticket URL: <https://code.djangoproject.com/ticket/32992>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: Carlton Gibson, Paul Ganssle (added)
* component: Uncategorized => Database layer (models, ORM)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
Thanks for the report.
Regression in 10d126198434810529e0220b0c6896ed64ca0e88.
Reproduced at 4fe3774c729f3fd5105b3001fe69a70bdca95ac3.
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:1>
* owner: nobody => tigicion
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:2>
* owner: tigicion => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:3>
Comment (by Alan):
This problem is also affecting MySQL, the timezone "Etc/GMT-10" is
returning "-10" instead of "-10:00". #33037
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:4>
* owner: (none) => Carlton Gibson
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:5>
Comment (by Carlton Gibson):
[https://github.com/django/django/pull/14792 PR] — Alan and James, it
would be good if you could confirm this addresses your issues.
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:6>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:7>
Comment (by James Beith):
This fixes the original issue I encountered, thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:8>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"cbba49971bbbbe3e8c6685e4ce6ab87b1187ae87" cbba499]:
{{{
#!CommitTicketReference repository=""
revision="cbba49971bbbbe3e8c6685e4ce6ab87b1187ae87"
Fixed #32992 -- Restored offset extraction for fixed offset timezones.
Regression in 10d126198434810529e0220b0c6896ed64ca0e88.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:10>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"fe3a854e1de2753ad6fa78a8584f85186092f801" fe3a854e]:
{{{
#!CommitTicketReference repository=""
revision="fe3a854e1de2753ad6fa78a8584f85186092f801"
[3.2.x] Fixed #32992 -- Restored offset extraction for fixed offset
timezones.
Regression in 10d126198434810529e0220b0c6896ed64ca0e88.
Backport of cbba49971bbbbe3e8c6685e4ce6ab87b1187ae87 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32992#comment:11>