From ea1b3c38f8c09a0989e7b51cb1c2b21f1ef1fab5 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 14 Jan 2024 20:00:30 +0100 Subject: [PATCH] remove last utcnow usage --- freqtrade/optimize/base_analysis.py | 2 +- freqtrade/rpc/api_server/api_auth.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/freqtrade/optimize/base_analysis.py b/freqtrade/optimize/base_analysis.py index 190ac882f..eb0a5e002 100644 --- a/freqtrade/optimize/base_analysis.py +++ b/freqtrade/optimize/base_analysis.py @@ -54,7 +54,7 @@ class BaseAnalysis: self.full_varHolder.from_dt = parsed_timerange.startdt if parsed_timerange.stopdt is None: - self.full_varHolder.to_dt = datetime.utcnow() + self.full_varHolder.to_dt = datetime.now(timezone.utc) else: self.full_varHolder.to_dt = parsed_timerange.stopdt diff --git a/freqtrade/rpc/api_server/api_auth.py b/freqtrade/rpc/api_server/api_auth.py index 71f1145a9..dd4749100 100644 --- a/freqtrade/rpc/api_server/api_auth.py +++ b/freqtrade/rpc/api_server/api_auth.py @@ -1,6 +1,6 @@ import logging import secrets -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from typing import Any, Dict, Union import jwt @@ -88,14 +88,14 @@ async def validate_ws_token( def create_token(data: dict, secret_key: str, token_type: str = "access") -> str: to_encode = data.copy() if token_type == "access": - expire = datetime.utcnow() + timedelta(minutes=15) + expire = datetime.now(timezone.utc) + timedelta(minutes=15) elif token_type == "refresh": - expire = datetime.utcnow() + timedelta(days=30) + expire = datetime.now(timezone.utc) + timedelta(days=30) else: raise ValueError() to_encode.update({ "exp": expire, - "iat": datetime.utcnow(), + "iat": datetime.now(timezone.utc), "type": token_type, }) encoded_jwt = jwt.encode(to_encode, secret_key, algorithm=ALGORITHM)