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

datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

```python
@classmethod
@deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.UTC)")
def utcnow(cls) -> Self
```
This commit is contained in:
Peter Pfeufer
2025-09-26 17:09:35 +02:00
parent 58cc4b84dd
commit e5f3a67919
5 changed files with 8 additions and 8 deletions

View File

@@ -100,13 +100,13 @@ def jabber_broadcast_view(request):
if main_char is not None:
message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "[" + main_char.corporation_ticker + "]" + \
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"
group_to_send = form.cleaned_data['group']
else:
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"
group_to_send = form.cleaned_data['group']

View File

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

View File

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