Merge branch 'fix-deprecated-utcnow' into 'master'

[FIX] Calls to deprecated `utcnow` method of `datetime.datetime`

See merge request allianceauth/allianceauth!1767
This commit is contained in:
Peter Pfeufer 2025-09-27 05:52:06 +00:00
commit d841e6f1de
5 changed files with 8 additions and 8 deletions

View File

@ -27,7 +27,7 @@ def dashboard_results(hours: int) -> _TaskCounts:
my_earliest = events.first_event(earliest=earliest) my_earliest = events.first_event(earliest=earliest)
return [my_earliest] if my_earliest else [] return [my_earliest] if my_earliest else []
earliest = dt.datetime.utcnow() - dt.timedelta(hours=hours) earliest = dt.datetime.now(dt.timezone.utc) - dt.timedelta(hours=hours)
earliest_events = [] earliest_events = []
succeeded_count = succeeded_tasks.count(earliest=earliest) succeeded_count = succeeded_tasks.count(earliest=earliest)
earliest_events += earliest_if_exists(succeeded_tasks, earliest) earliest_events += earliest_if_exists(succeeded_tasks, earliest)

View File

@ -42,7 +42,7 @@ class EventSeries:
- event_time: timestamp of event. Will use current time if not specified. - event_time: timestamp of event. Will use current time if not specified.
""" """
if not event_time: if not event_time:
event_time = dt.datetime.utcnow() event_time = dt.datetime.now(dt.timezone.utc)
my_id = self._redis.incr(self._key_counter) my_id = self._redis.incr(self._key_counter)
self._redis.zadd(self._key_sorted_set, {my_id: event_time.timestamp()}) self._redis.zadd(self._key_sorted_set, {my_id: event_time.timestamp()})

View File

@ -100,13 +100,13 @@ def jabber_broadcast_view(request):
if main_char is not None: if main_char is not None:
message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "[" + main_char.corporation_ticker + "]" + \ message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "[" + main_char.corporation_ticker + "]" + \
main_char.character_name + " TO: " + \ main_char.character_name + " TO: " + \
form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime( form.cleaned_data['group'] + " WHEN: " + datetime.datetime.now(datetime.timezone.utc).strftime(
"%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n" "%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n"
group_to_send = form.cleaned_data['group'] group_to_send = form.cleaned_data['group']
else: else:
message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "No character but can send pings?" + " TO: " + \ message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "No character but can send pings?" + " TO: " + \
form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime( form.cleaned_data['group'] + " WHEN: " + datetime.datetime.now(datetime.timezone.utc).strftime(
"%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n" "%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n"
group_to_send = form.cleaned_data['group'] group_to_send = form.cleaned_data['group']

View File

@ -2,7 +2,7 @@ import random
import string import string
import calendar import calendar
import re import re
from datetime import datetime import datetime as dt
from passlib.apps import phpbb3_context from passlib.apps import phpbb3_context
from django.db import connections from django.db import connections
@ -128,7 +128,7 @@ class Phpbb3Manager:
@staticmethod @staticmethod
def __get_current_utc_date(): def __get_current_utc_date():
d = datetime.utcnow() d = dt.datetime.now(dt.timezone.utc)
unixtime = calendar.timegm(d.utctimetuple()) unixtime = calendar.timegm(d.utctimetuple())
return unixtime return unixtime

View File

@ -1,7 +1,7 @@
import random import random
import string import string
import calendar import calendar
from datetime import datetime import datetime as dt
import hashlib import hashlib
import logging import logging
import re import re
@ -105,7 +105,7 @@ class SmfManager:
@staticmethod @staticmethod
def get_current_utc_date(): def get_current_utc_date():
d = datetime.utcnow() d = dt.datetime.now(dt.timezone.utc)
unixtime = calendar.timegm(d.utctimetuple()) unixtime = calendar.timegm(d.utctimetuple())
return unixtime return unixtime