Refs #36005 -- Used datetime.UTC alias instead of datetime.timezone.utc.

datetime.UTC was added in Python 3.11.
This commit is contained in:
Mariusz Felisiak 2025-02-18 08:35:36 +01:00 committed by GitHub
parent 0d1dd6bba0
commit efb7f9ced2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 271 additions and 272 deletions

View file

@ -65,7 +65,7 @@ except ImportError:
# datetime.datetime(2011, 9, 1, 13, 20, 30), which translates to
# 10:20:30 in UTC and 17:20:30 in ICT.
UTC = datetime.timezone.utc
UTC = datetime.UTC
EAT = timezone.get_fixed_timezone(180) # Africa/Nairobi
ICT = timezone.get_fixed_timezone(420) # Asia/Bangkok
@ -618,7 +618,7 @@ class NewDatabaseTests(TestCase):
@skipIfDBFeature("supports_timezones")
def test_cursor_execute_accepts_naive_datetime(self):
dt = datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)
utc_naive_dt = timezone.make_naive(dt, datetime.timezone.utc)
utc_naive_dt = timezone.make_naive(dt, UTC)
with connection.cursor() as cursor:
cursor.execute(
"INSERT INTO timezones_event (dt) VALUES (%s)", [utc_naive_dt]
@ -637,7 +637,7 @@ class NewDatabaseTests(TestCase):
@skipIfDBFeature("supports_timezones")
def test_cursor_execute_returns_naive_datetime(self):
dt = datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)
utc_naive_dt = timezone.make_naive(dt, datetime.timezone.utc)
utc_naive_dt = timezone.make_naive(dt, UTC)
Event.objects.create(dt=dt)
with connection.cursor() as cursor:
cursor.execute(