Skip to content

Commit

Permalink
Merge pull request #50 from cnwutong/patch-utc
Browse files Browse the repository at this point in the history
patch for offset-aware datetimes
  • Loading branch information
minibear2021 authored Feb 5, 2024
2 parents 74aff4f + d3adcb7 commit 9504197
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions wechatpayv3/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json
import os
from datetime import datetime
from datetime import datetime, timezone

import requests

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9504197

Please sign in to comment.