请教关于日期输出的两个问题?
#141
-
1、本方案中如何设置,在输入“date”的时候,可以打出如下面的大写的日期: 2、输入任意日期时,是否有快捷或简便的方式,如下: |
Beta Was this translation helpful? Give feedback.
Answered by
bczhc
Aug 1, 2024
Replies: 1 comment 11 replies
-
可以在lua里面自己改。比如第一个,一种方法是: local function CnDate_translator(y)
local t, cstr, t2
cstr = { "〇", "一", "二", "三", "四", "五", "六", "七", "八", "九" }
t = ""
for i = 1, y.len(y) do
t2 = cstr[tonumber(y.sub(y, i, i)) + 1]
if i == 5 and t2 ~= "〇" then
t2 = "年十"
elseif i == 5 and t2 == "〇" then
t2 = "年"
end
if i == 6 and t2 ~= "〇" then
t2 = t2 .. "月"
elseif i == 6 and t2 == "〇" then
t2 = "月"
end
-- if t.sub(t,t.len(t)-1)=="年" then t2=t2 .. "月" end
if i == 7 and tonumber(y.sub(y, 7, 7)) > 1 then
t2 = t2 .. "十"
elseif i == 7 and t2 == "〇" then
t2 = ""
elseif i == 7 and tonumber(y.sub(y, 7, 7)) == 1 then
t2 = "十"
end
if i == 8 and t2 ~= "〇" then
t2 = t2 .. "日"
elseif i == 8 and t2 == "〇" then
t2 = "日"
end
t = t .. t2
end
return t
end
local function translator(input, seg)
if (input == "date") then
local cn_date = CnDate_translator(os.date("%Y%m%d"));
yield(Candidate("date", seg.start, seg._end, cn_date, ''))
end
end
参考自98wubi group https://github.com/yanhuacuo/98wubi/blob/3b2f2769cf39f9253fd0e6594e85ae3f7f5c72d0/rime.lua |
Beta Was this translation helpful? Give feedback.
11 replies
Answer selected by
Aisaray
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
可以在lua里面自己改。比如第一个,一种方法是: