From 2b4bf3afebe61bff194f1a7de96e4bb29dfdb043 Mon Sep 17 00:00:00 2001 From: mirtlecn Date: Sat, 27 Jul 2024 23:31:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20lunar.lua=20=E9=94=99=E8=AF=AF=E6=8D=95?= =?UTF-8?q?=E8=8E=B7=E4=BB=A5=20N=20=E5=BC=80=E5=A4=B4=E7=9A=84=E8=8B=B1?= =?UTF-8?q?=E6=96=87=E5=8D=95=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/lunar.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lunar.lua b/lua/lunar.lua index 7a9c110..e649596 100755 --- a/lua/lunar.lua +++ b/lua/lunar.lua @@ -549,6 +549,7 @@ local function Date2LunarDate(Gregorian) Month = tonumber(Gregorian.sub(Gregorian, 5, 6)) Day = tonumber(Gregorian.sub(Gregorian, 7, 8)) if Year > 2100 or Year < 1899 or Month > 12 or Month < 1 or Day < 1 or Day > 31 or string.len(Gregorian) < 8 then + -- 2024.07.27 这个不能判断不存在的日期,例如 02.31 04.30 等,会显示农历,但不存在 by Mirtle return "无效日期", "无效日期" end @@ -657,7 +658,7 @@ local function translator(input, seg, env) local lunar_date = Candidate("", seg.start, seg._end, date1, "") lunar_date.quality = 999 yield(lunar_date) - elseif env.gregorian_to_lunar ~= '' and input:sub(1, 1) == env.gregorian_to_lunar then + elseif env.gregorian_to_lunar ~= '' and input:sub(1, 1) == env.gregorian_to_lunar and input:sub(2):find("^%d%d%d%d%d%d%d%d$") then local date1, date2 = Date2LunarDate(input:sub(2)) local lunar_ymd = (Candidate("", seg.start, seg._end, date2, "")) lunar_ymd.quality = 999