本帖最后由 caoliu023 于 2016-6-27 22:34 编辑
偶然在明经的vba函数中心看到某位大大写的获取指定年份的农历天干地支年名vba函数
页面地址在这里 http://www.mjtd.com/function/info-130-469.html
感觉挺有意思的,所以就把它翻译成lisp版本
 - (defun GetCNYearName (CurYear / temp temp2 tg dz an)
- (if (< CurYear 4)
- (princ "输入年份不能小于4")
- (progn
- (setq CNYear_TG '("甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"))
- (setq CNYear_DZ '("子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥"))
- (setq CNYear_AN '("鼠" "牛" "虎" "兔" "龙" "蛇" "马" "羊" "猴" "鸡" "狗" "猪"))
- (setq temp (fix(rem (- CurYear 4.0) 60 12)))
- (setq temp2 (fix(rem(- CurYear 4.0) 60 10)))
- (setq tg(nth temp2 CNYear_TG))
- (setq dz(nth temp CNYear_DZ))
- (setq an(nth temp CNYear_AN))
- (princ (strcat "该年是" tg dz "("an")" "年"))
- )
- )
- (princ)
- )
|