From d8b89fd622e0e3a497578703428cb660a46729e0 Mon Sep 17 00:00:00 2001 From: jimchamp <28732543+jimchamp@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:23:58 -0800 Subject: [PATCH] Replace deprecated method --- scripts/expire_accounts.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/expire_accounts.py b/scripts/expire_accounts.py index 27584fb78a7..5943a2789d7 100644 --- a/scripts/expire_accounts.py +++ b/scripts/expire_accounts.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, timezone, UTC import web @@ -6,7 +6,9 @@ def delete_old_links(): for doc in web.ctx.site.store.values(type="account-link"): expiry_date = datetime.strptime(doc["expires_on"], "%Y-%m-%dT%H:%M:%S.%f") - now = datetime.utcnow() + # Make expiry_date timezone aware + expiry_date = expiry_date.replace(tzinfo=timezone.utc) + now = datetime.now(UTC) key = doc["_key"] if expiry_date > now: print("Deleting link %s" % (key))