||
;Ctrl+Alt+Y 用于计算年份Year
^!y::
{
tmpyear:=0
year :=InputBox("请输入公元多少年:","输入年份","W200 H100","2023").value
if year=0
{
MsgBox "年份不能为0","错误"
return
}
else
{
if year>0
tmpyear := year-4
else
tmpyear :=year-3
}
while tmpyear<0
{
tmpyear += 60
}
tg := Mod(tmpyear,10)+1
dz :=Mod(tmpyear, 12)+1
tgStr:="甲乙丙丁戊己庚辛壬癸"
dzStr:= "子丑寅卯辰巳午未申酉戌亥"
tgdz:=SubStr(tgStr,tg,1) . SubStr(dzStr,dz,1)
MsgBox year . "=>" . tgdz, "计算结果"
}
;Ctrl+Alt+T 用于计算天干地支(TGDZ),
^!t::
{
tgdz :=InputBox("请输入天干地支,限两个汉字:","Input","W200 H100","甲子").value
if StrLen(tgdz) !=2
{
MsgBox "Length of Input must be 2 chars"
return
}
baseYear:=InputBox("请输入或确认甲子元年:","确认","W200 H100","1924").value
if BaseYear>=4
{if Mod(BaseYear-4,60)!=0
{
MsgBox "甲子年起始年份不正确","错误"
return
}
}
else
{
tmpBaseYear:=BaseYear
while tmpBaseYear<0
{
tmpBaseYear +=60
}
if Mod(tmpBaseYear-3, 60)!=0
{
MsgBox "甲子年起始年份不正确","错误"
return
}
}
tgStr:="甲乙丙丁戊己庚辛壬癸"
dzStr:= "子丑寅卯辰巳午未申酉戌亥"
tgIndex:=InStr(tgStr,SubStr(tgdz,1,1))-1
dzIndex:=InStr(dzStr,SubStr(tgdz,2,1))-1
if (tgIndex<0) or (dzIndex<0)
{
MsgBox "天干或地支中至少一个写错了",'错误'
return
}
m:=tgIndex-dzIndex
if m<0
{
m +=12
}
year:= BaseYear + 5*m + tgIndex
MsgBox tgdz "(基于" BaseYear ")=>" year,'计算结果'
}
; 2023-9-28 用AutoHotKey v2测试通过.
汇总不同语言的表述,见
TGDZ in 21 languages(2023-9-28).md
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-23 21:27
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社