mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Replace usage of utcnow()
`datetime.utcnow()` deprecated in Python 3.12
This commit is contained in:
parent
d0c1e467bd
commit
ddc8a08fc7
2 changed files with 7 additions and 7 deletions
|
@ -28,7 +28,7 @@ from cloudinary.api import delete_resources_by_tag
|
||||||
from cloudinary.uploader import upload
|
from cloudinary.uploader import upload
|
||||||
from cloudinary.utils import cloudinary_url
|
from cloudinary.utils import cloudinary_url
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import datetime
|
from datetime import date, datetime, timezone
|
||||||
from functools import reduce, wraps
|
from functools import reduce, wraps
|
||||||
import hashlib
|
import hashlib
|
||||||
import imghdr
|
import imghdr
|
||||||
|
@ -222,14 +222,14 @@ def timestamp():
|
||||||
|
|
||||||
|
|
||||||
def today():
|
def today():
|
||||||
today = datetime.date.today()
|
today = date.today()
|
||||||
yyyymmdd = datetime.date.isoformat(today)
|
yyyymmdd = date.isoformat(today)
|
||||||
|
|
||||||
return yyyymmdd
|
return yyyymmdd
|
||||||
|
|
||||||
|
|
||||||
def utc_now_iso():
|
def utc_now_iso():
|
||||||
utcnow = datetime.datetime.utcnow()
|
utcnow = datetime.now(tz=timezone.utc).replace(tzinfo=None)
|
||||||
|
|
||||||
return utcnow.isoformat()
|
return utcnow.isoformat()
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ def timestamp_to_YMDHMS(ts, sep=False):
|
||||||
|
|
||||||
|
|
||||||
def timestamp_to_datetime(ts):
|
def timestamp_to_datetime(ts):
|
||||||
return datetime.datetime.fromtimestamp(ts)
|
return datetime.fromtimestamp(ts)
|
||||||
|
|
||||||
|
|
||||||
def iso_to_YMD(iso):
|
def iso_to_YMD(iso):
|
||||||
|
@ -258,7 +258,7 @@ def iso_to_datetime(iso):
|
||||||
|
|
||||||
|
|
||||||
def datetime_to_iso(dt, to_date=False):
|
def datetime_to_iso(dt, to_date=False):
|
||||||
if isinstance(dt, datetime.datetime):
|
if isinstance(dt, datetime):
|
||||||
if to_date:
|
if to_date:
|
||||||
dt = dt.date()
|
dt = dt.date()
|
||||||
return dt.isoformat()
|
return dt.isoformat()
|
||||||
|
|
|
@ -378,7 +378,7 @@ class AuthController(object):
|
||||||
|
|
||||||
if valid_login:
|
if valid_login:
|
||||||
time_delta = timedelta(days=30) if remember_me == '1' else timedelta(minutes=60)
|
time_delta = timedelta(days=30) if remember_me == '1' else timedelta(minutes=60)
|
||||||
expiry = datetime.utcnow() + time_delta
|
expiry = datetime.now() + time_delta
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
'user_id': user_details['user_id'],
|
'user_id': user_details['user_id'],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue