-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
ichingshifa/ichingshifa/ichingshifa.py
Line 762 in 5321208
| b = "農曆︰{}{}月{}日\n".format(cn2an.transform(str(year)+"年", "an2cn"), an2cn(self.lunar_date_d(year, month, day).get("月")), an2cn(self.lunar_date_d(year,month, day).get("日"))) |
该语句中,年份的解析式为 cn2an.transform(str(year)+"年", "an2cn")
这会导致公历年年初的日期解析错误:例如 2026 年 1 月的公历日期,实际农历年份应为 二零二五 年,但代码中仍会解析为二零二六 年,与真实农历年份不符。
建议将年份解析逻辑改为从 self.lunar_date_d() 方法返回的农历年取值,例如
# 原行修改:年份从lunar_date_d返回值取,而非传入的year
b = "農曆︰{}{}月{}日\n".format(
cn2an.transform(str(self.lunar_date_d(year, month, day).get("年"))+"年", "an2cn"),
an2cn(self.lunar_date_d(year, month, day).get("月")),
an2cn(self.lunar_date_d(year,month, day).get("日"))
)非常感谢您开源分享这个实用的工具!以上建议若有不妥之处,还请指正 😊
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels