From e3684e31d532cb092fbcd6ff02c14073aac6dea0 Mon Sep 17 00:00:00 2001 From: EillesWan Date: Fri, 31 Jan 2025 01:56:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20zhDateTime=20=E5=BA=93?= =?UTF-8?q?=E9=9C=80=E6=B1=82=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 2 +- .../trimo_plugin_msctconverter/utils.py | 10 ++++----- src/nonebot_plugins/trimo_status/status.py | 21 +++++++++++-------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3cbc00d..5d212db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ nonebot_plugin_apscheduler>=0.4.0 nonebot-adapter-satori>=0.11.5 # pyppeteer>=2.0.0 markdown>=3.3.6 -zhDateTime>=1.1.1 +zhDateTime>=2.0.0 numpy<2.0.0 packaging>=23.1 psutil>=5.9.8 diff --git a/src/nonebot_plugins/trimo_plugin_msctconverter/utils.py b/src/nonebot_plugins/trimo_plugin_msctconverter/utils.py index 116b6ff..725847c 100644 --- a/src/nonebot_plugins/trimo_plugin_msctconverter/utils.py +++ b/src/nonebot_plugins/trimo_plugin_msctconverter/utils.py @@ -7,17 +7,17 @@ def hanzi_timeid( zhd: Optional[zhDateTime.zhDateTime] = None, ) -> str: if not zhd: - zhd = zhDateTime.DateTime.now().to_lunar() + zhd = zhDateTime.DateTime.now().chinesize return "{地支时}{刻}{分}{秒}".format( - 地支时=zhDateTime.DÌZHĪ[zhd.shichen] + 地支时=zhDateTime.TERRESTRIAL_BRANCHES[zhd.shichen] + ( "" if ((zhd.quarters) or (zhd.minutes) or (zhd.seconds) or (zhd.microseconds)) else "整" ), 刻=( - (zhDateTime.HANNUM[zhd.quarters]) + (zhDateTime.NUM_IN_HANZI[zhd.quarters]) + ("" if ((zhd.minutes) or (zhd.seconds) or (zhd.microseconds)) else "整") ), 分=( @@ -25,8 +25,8 @@ def hanzi_timeid( + ("" if ((zhd.seconds) or (zhd.microseconds)) else "整") ), 秒=( - zhDateTime.HANNUM[zhd.seconds // 10] - + zhDateTime.HANNUM[zhd.seconds % 10] + zhDateTime.NUM_IN_HANZI[zhd.seconds // 10] + + zhDateTime.NUM_IN_HANZI[zhd.seconds % 10] + ("" if (zhd.microseconds) else "整") ), ).strip() diff --git a/src/nonebot_plugins/trimo_status/status.py b/src/nonebot_plugins/trimo_status/status.py index 12a4102..0ce1062 100644 --- a/src/nonebot_plugins/trimo_status/status.py +++ b/src/nonebot_plugins/trimo_status/status.py @@ -115,24 +115,27 @@ async def _(): global yanlun_texts, yanlun_seqs - solar_datetime = zhDateTime.DateTime.now() - lunar_datetime = solar_datetime.to_lunar() - solar_date = (solar_datetime.month, solar_datetime.day) - lunar_date = (lunar_datetime.lunar_month, lunar_datetime.lunar_day) + western_datetime = zhDateTime.DateTime.now() + chinese_datetime = western_datetime.chinesize + western_date = (western_datetime.month, western_datetime.day) + chinese_date = ( + chinese_datetime.chinese_calendar_month, + chinese_datetime.chinese_calendar_day, + ) - if solar_date == (4, 3): + if western_date == (4, 3): yanlun_seqs = yanlun_texts = ["金羿ELS 生日快乐~!", "Happy Birthday, Eilles!"] - elif solar_date == (8, 6): + elif western_date == (8, 6): yanlun_seqs = yanlun_texts = [ "玉衡 生日快乐~!", "Happy Birthday, Alioth~!", ] - elif solar_date == (8, 16): + elif western_date == (8, 16): yanlun_seqs = yanlun_texts = [ "鱼旧梦 生日快乐~!", "Happy Birthday, ElapsingDreams~!", ] - elif lunar_date == (1, 1): + elif chinese_date == (1, 1): yanlun_seqs = yanlun_texts = [ "新春快乐~", "千门万户曈曈日,总把新桃换旧符\t——王安石《元日》", @@ -316,5 +319,5 @@ async def _( ): # ulang = get_user_lang(event_utils.get_user_id(event)) # type: ignore await time_query.finish( - UniMessage.text(zhDateTime.DateTime.now().to_lunar().hanzify()) + UniMessage.text(zhDateTime.DateTime.now().chinesize.chinese_text) )