diff --git a/__pycache__/app.cpython-310.pyc b/__pycache__/app.cpython-310.pyc index e7432ba..681ac69 100644 Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ diff --git a/app.py b/app.py index 43d1680..602a198 100644 --- a/app.py +++ b/app.py @@ -4,7 +4,7 @@ try: import requests as _requests except ImportError: _requests = None -from datetime import datetime, timedelta, date as date_cls +from datetime import datetime, timedelta, date as date_cls, timezone from authlib.integrations.flask_client import OAuth app = Flask(__name__) @@ -1938,7 +1938,7 @@ def calendar_ics(): ORDER BY cb.date''').fetchall() conn.close() - now_str = datetime.utcnow().strftime('%Y%m%dT%H%M%SZ') + now_str = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ') lines = [ 'BEGIN:VCALENDAR', 'VERSION:2.0', @@ -2044,8 +2044,8 @@ def _ha_sync_once(): "SELECT id, name, ha_entity_prefix FROM printers " "WHERE ha_entity_prefix IS NOT NULL AND ha_entity_prefix != ''" ).fetchall() - now_iso = datetime.utcnow().isoformat() - window = (datetime.utcnow() + timedelta(minutes=30)).isoformat() + now_iso = datetime.now(timezone.utc).replace(tzinfo=None).isoformat() + window = (datetime.now(timezone.utc).replace(tzinfo=None) + timedelta(minutes=30)).isoformat() for p in printers: prefix = p['ha_entity_prefix'] ha_status = states.get(f'sensor.{prefix}_etat_de_l_impression', 'unknown')