sxtwl_cpp是寿星天文历的C++版本实现。支持多种语言的绑定python
python版的sxtwl_cpp传送入口android
在build.gradle的allprojects中加入微信
maven { url 'https://dl.bintray.com/yuangu/sxtwl' }
最终以下面代码所示:app
allprojects { repositories { google() jcenter() maven { url 'https://dl.bintray.com/yuangu/sxtwl' } } }
最后在dependencies中加入maven
implementation 'com.huoyaojing:sxtwl:1.0.3'
便可ide
使用事例:gradle
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import com.huoyaojing.sxtwl.Day; import com.huoyaojing.sxtwl.GZ; import com.huoyaojing.sxtwl.Lunar; import com.huoyaojing.sxtwl.Month; import com.huoyaojing.sxtwl.Year; public class MainActivity extends AppCompatActivity { String[] Gan = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"}; String[] Zhi = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"}; String[] ShX = {"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"}; String[] numCn = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"}; String[] jqmc = {"冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑","白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪"}; String[] ymc = {"十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十" }; String[] rmc = {"初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"}; private void log(String str) { Log.d(this.getClass().getName(), str); } private void printDay(Day day) { log("==================================================="); log("公历:" + day.getY() + "年" + day.getM() + "月" + day.getD() + "日"); if(day.getLleap()) //是不是阴历润月 { log("农历:" +"润" + (day.getLyear0() + 1984) + "年" + ymc[day.getLmc()] + "月" + rmc[day.getLdi()] + "日"); }else { log("农历:" + (day.getLyear0() + 1984) + "年" + ymc[day.getLmc()] + "月" + rmc[day.getLdi()] + "日"); } log("儒略历:JD" + J2000 + day.getD0()); log("星期" + numCn[day.getWeek()]); log("天干:" + Gan[day.getLyear2().getTg()] + Zhi[day.getLyear2().getDz()] + "年" + Gan[day.getLmonth2().getTg()] + Zhi[day.getLmonth2().getDz()] + "月" + Gan[day.getLday2().getTg()] + Zhi[day.getLday2().getDz()] + "日" ); if(day.getQk() >= 0) { log("当日节气:" + jqmc[day.getJqmc()]) ; log("节气时间:" + day.getJqsj()); } //day.getXiZ(); //这个是星座 log("距冬至:" + day.getCur_dz() + "天"); log("距夏至:" + day.getCur_xz() + "天"); log("距立秋:" + day.getCur_lq() + "天"); log("距芒种:" + day.getCur_mz() + "天"); log("距小暑:" + day.getCur_xs() + "天"); } private void testLunar() { Lunar lunar = new Lunar(); //查询某月的月份信息(如:查2017年10月份) Month month = lunar.yueLiCalc(2017, (short) 10); //年生肖 log(month.getY() + "年:" + ShX[month.getShX()] ); //年天干地支 log("天干:" + Gan [month.getYearGan()] + Zhi[month.getYearZhi()]); //当月的全部的日信息 for (int i = 0; i < month.getDays().size(); ++ i) { Day day = month.getDays().get(i); printDay(day); } //获取某个阳历日的信息(可在信息中查询到阴历,天干等) Day day = lunar.getDayBySolar(2018, (short)10, (short)1); printDay(day); //获取某个阴历日的信息(可在信息中查询到阳历,天干等) Day day2 = lunar.getDayByLunar(2018, (short)10, (short)1); printDay(day2); //获取时辰上的那个天干(例如拿下午13点的时辰干支) GZ gz = lunar.getShiGz( day.getLday2().getTg(), (short)13); log("获取时辰的干支:" + Gan[gz.getTg()] + Zhi[gz.getDz()]); //获取一年的信息(干支,生肖,) Year year = lunar.getYearCal(2018); log("获取年的干支:" + Gan[year.getYearGan()] + Zhi[year.getYearZhi()]); log("获取年的生肖:" + ShX[year.getShX()]); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); testLunar(); } }
若失效,请邮件至:lifulinghan@aol.com 索要新的二维码ui