🐛 Fix Error UTC Timezone

This commit is contained in:
xtaodada 2023-06-22 14:34:26 +08:00
parent b673997f95
commit e6be7a0e61
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
4 changed files with 6 additions and 1 deletions

2
add.py
View File

@ -1,4 +1,5 @@
from pathlib import Path
from pytz import timezone
from sys import argv
from datetime import datetime
from typing import List
@ -16,6 +17,7 @@ def add(code: str, expire_str: str, rewards_str: List[str]) -> Code:
else:
expire = datetime.strptime(expire_str, "%Y-%m-%d")
expire = expire.replace(hour=23, minute=59, second=59, microsecond=999999)
expire = timezone("Asia/Shanghai").localize(expire)
rewards = []
for reward_str in rewards_str:
reward_list = reward_str.split(":")

View File

@ -8,7 +8,7 @@
"cnt": 60
}
],
"expire": 1689724799999
"expire": 1689695999999
},
{
"code": "9A6BHRKX4XNL",

View File

@ -1,4 +1,5 @@
import re
from pytz import timezone
from datetime import datetime
from typing import List
@ -57,6 +58,7 @@ def parse_code(tr: Tag) -> Code:
now = datetime.now()
expire = datetime.strptime(f"{day} {month}", "%d %b")
expire = expire.replace(year=now.year, hour=23, minute=59, second=59, microsecond=999999)
expire = timezone("Asia/Shanghai").localize(expire)
expire = int(expire.timestamp() * 1000)
rewards = []
for reward in tds[1].find_all("div", {"class": "flex"}):

View File

@ -2,3 +2,4 @@ pydantic
httpx
beautifulsoup4
lxml
pytz