From d3adcb779748ce5c58a869d187206742c2193372 Mon Sep 17 00:00:00 2001 From: cnwutong Date: Sat, 3 Feb 2024 22:57:15 +0800 Subject: [PATCH] patch for offset-aware datetimes --- wechatpayv3/core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wechatpayv3/core.py b/wechatpayv3/core.py index 4fdd100..4b2086c 100644 --- a/wechatpayv3/core.py +++ b/wechatpayv3/core.py @@ -2,7 +2,7 @@ import json import os -from datetime import datetime +from datetime import datetime, timezone import requests @@ -199,8 +199,8 @@ def _init_certificates(self): continue with open(self._cert_dir + file_name, encoding="utf-8") as f: certificate = load_certificate(f.read()) - now = datetime.utcnow() - if certificate and now >= certificate.not_valid_before and now <= certificate.not_valid_after: + now = datetime.now(timezone.utc) + if certificate and now >= certificate.not_valid_before_utc and now <= certificate.not_valid_after_utc: self._certificates.append(certificate) if not self._certificates: self._update_certificates()