2019独角兽企业重金招聘Python工程师标准>>>
sxtwl_cpp是寿星天文历的C++版本实现。支持多种语言的绑定
代码首页
懒人包
懒人包使用方法
1、右链工程中的引用-》添加引用-》浏览-》选中dotnet目录下的sxtwl.net.dll
2、生成解决方案-》找生成解决方案有exe目录下,将bin目录下dll拷贝过去(建议使用win32的dll, x64的DLL可能跑不起来)
功能代码演示:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace sxtwl_csharp
{
class Program
{
string[] Gan = { "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" };
string[] Zhi = { "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥" };
string[] ShX = { "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪" };
string[] numCn = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" }; //中文数字
string[] jqmc = { "冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪" };
string[] ymc = { "十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十" }; //月名称,建寅
string[] rmc = { "初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一" };
private void log(String str)
{
System.Console.WriteLine(str);
}
private void printDay(Day day)
{
log("===================================================");
log("公历:" + day.y + "年" + (int)day.m + "月" + day.d + "日");
if (day.Lleap)//是否是阴历润月
{
log("农历:" + "润" + (day.Lyear0 + 1984) + "年" + ymc[day.Lmc] + "月" + rmc[day.Ldi] + "日");
}
else
{
log("农历:" + "润" + (day.Lyear0 + 1984) + "年" + ymc[day.Lmc] + "月" + rmc[day.Ldi] + "日");
}
log("儒略历:JD" + sxtwl.J2000 + day.d0);
log("星期" + numCn[day.week]);
log("天干:" + Gan[day.Lyear2.tg] + Zhi[day.Lyear2.dz] + "年"
+ Gan[day.Lmonth2.tg] + Zhi[day.Lmonth2.dz] + "月"
+ Gan[day.Lday2.tg] + Zhi[day.Lday2.dz] + "日"
);
if (day.qk >= 0)
{
log("当日节气:" + jqmc[day.jqmc]);
log("节气时间:" + day.jqsj);
}
//day.getXiZ(); //这个是星座
log("距冬至" + day.cur_dz + "天");
log("距夏至" + day.cur_xz + "天");
log("距立秋" + day.cur_lq + "天");
log("距芒种" + day.cur_mz + "天");
log("距小暑" + day.cur_xs + "天");
}
private void testLunar()
{
Lunar lunar = new Lunar();
//查询某月的月份信息(如:查2017年10月份)
Month month = lunar.yueLiCalc(2017, 10);
//年生肖
log(month.y + "年:" + ShX[month.ShX]);
//年天干地支
log("天干:" + Gan[month.yearGan] + Zhi[month.yearZhi]);
//当月的所有的日信息
for (int i = 0; i < month.days.Count; ++i)
{
Day tmpDay = month.days[i];
printDay(tmpDay);
}
//获取某个阳历日的信息(可在信息中查询到阴历,天干等)
Day day = lunar.getDayBySolar(2018, 10, 1);
printDay(day);
//获取某个阴历日的信息(可在信息中查询到阳历,天干等)
Day day2 = lunar.getDayByLunar(2018, 10, 1);
printDay(day2);
//获取时辰上的那个天干(例如拿下午13点的时辰干支)
GZ gz = lunar.getShiGz(day.Lday2.tg, 13);
log("获取时辰的干支:" + Gan[gz.tg] + Zhi[gz.dz]);
//获取一年的信息(干支,生肖,)
Year year = lunar.getYearCal(2018);
log("获取年的干支:" + Gan[year.yearGan] + Zhi[year.yearZhi]);
log("获取年的生肖:" + ShX[year.ShX]);
}
static void Main(string[] args)
{
new Program().testLunar();
System.Console.ReadKey();
}
}
}
微信交流群
若失效,请邮件至:[email protected] 索要新的二维码