diff --git a/scripts/expire_accounts.py b/scripts/expire_accounts.py index 27584fb78a73..5943a2789d75 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))