From 296dbc555c2a64a1d912c6d60eed48e5d0cd609c Mon Sep 17 00:00:00 2001 From: Kyomotoi <0w0@imki.moe> Date: Wed, 18 Jan 2023 00:40:50 +0800 Subject: =?UTF-8?q?=F0=9F=8E=A8=20=E7=A7=BB=E9=99=A4=E5=AF=B9=20pytz=20?= =?UTF-8?q?=E7=9A=84=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ATRI/plugins/thesaurus/__init__.py | 8 ++++---- ATRI/plugins/thesaurus/data_source.py | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'ATRI/plugins/thesaurus') diff --git a/ATRI/plugins/thesaurus/__init__.py b/ATRI/plugins/thesaurus/__init__.py index 5b6af44..f1860c9 100644 --- a/ATRI/plugins/thesaurus/__init__.py +++ b/ATRI/plugins/thesaurus/__init__.py @@ -1,5 +1,5 @@ -import pytz from tabulate import tabulate +from datetime import timedelta, timezone as tz from nonebot.matcher import Matcher from nonebot.params import ArgPlainText, CommandArg, ArgStr @@ -710,7 +710,7 @@ async def _info_normal_get_item_info( operator=item_info.operator, operator_id=item_info.operator_id, update_time=item_info.update_time.replace( - tzinfo=pytz.timezone("Asia/Shanghai") + tzinfo=tz(timedelta(hours=8)) ), is_vote="是" if item_info.is_vote else "否", vote_list=item_info.vote_list, @@ -752,7 +752,7 @@ async def _info_global_get_item_info(_id: str = ArgPlainText("info_global_item_i operator=item_info.operator, operator_id=item_info.operator_id, update_time=item_info.update_time.replace( - tzinfo=pytz.timezone("Asia/Shanghai") + tzinfo=tz(timedelta(hours=8)) ), is_vote="是" if item_info.is_vote else "否", vote_list=item_info.vote_list, @@ -798,7 +798,7 @@ async def _info_vote_get_item_info( operator=item_info.operator, operator_id=item_info.operator_id, update_time=item_info.update_time.replace( - tzinfo=pytz.timezone("Asia/Shanghai") + tzinfo=tz(timedelta(hours=8)) ), is_vote="是" if item_info.is_vote else "否", vote_list=item_info.vote_list, diff --git a/ATRI/plugins/thesaurus/data_source.py b/ATRI/plugins/thesaurus/data_source.py index 8c12b16..4f99b2c 100644 --- a/ATRI/plugins/thesaurus/data_source.py +++ b/ATRI/plugins/thesaurus/data_source.py @@ -1,5 +1,4 @@ -import pytz -from datetime import datetime +from datetime import datetime, timedelta, timezone as tz from ATRI.message import MessageBuilder from ATRI.exceptions import ThesaurusError @@ -123,7 +122,7 @@ class ThesaurusManager: "group_id": group_id, "operator": operator, "operator_id": operator_id, - "update_time": datetime.now(pytz.timezone("Asia/Shanghai")), + "update_time": datetime.now(tz(timedelta(hours=8))), "is_vote": is_vote, "vote_list": vote_list, } @@ -158,7 +157,7 @@ class ThesaurusManager: group_id, { "vote_list": vote_list, - "update_time": datetime.now(pytz.timezone("Asia/Shanghai")), + "update_time": datetime.now(tz(timedelta(hours=8))), }, ) -- cgit v1.2.3