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