Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c91bcc5da7 | ||
|
|
e9ec0fc4b9 |
32
README.md
32
README.md
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.2.13</version>
|
||||
<version>1.2.15</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -54,3 +54,33 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
|
||||
## 文档
|
||||
|
||||
请移步至 [http://6tail.cn/calendar/api.html](http://6tail.cn/calendar/api.html "http://6tail.cn/calendar/api.html")
|
||||
|
||||
## 更新日志
|
||||
|
||||
v1.2.15 南京大XX纪念日更改为国家公祭日;新增初候、二候、三候;新增三元九运;新增道历戊日。
|
||||
|
||||
v1.2.14 佛历新增27宿;修复宜忌重复的问题;修复获取气时缺冬至的问题。
|
||||
|
||||
v1.2.13 新增道历Tao。
|
||||
|
||||
v1.2.12 修复星宿方位错误。
|
||||
|
||||
v1.2.11 修正胎神数据;增加福神流派。
|
||||
|
||||
v1.2.9 新增2022年法定假日。
|
||||
|
||||
v1.2.8 新增佛历Foto;更改Lunar中的getOtherFestivals方法为传统节日。
|
||||
|
||||
v1.2.7 修复儒略日转阳历秒数为60的错误。
|
||||
|
||||
v1.2.6 新增治水、分饼、耕田、得金、日禄;新增时辰LunarTime;新增获取当天的所有时辰。
|
||||
|
||||
v1.2.5 修复公元0至4年转阴历错误的问题。
|
||||
|
||||
v1.2.4 修复闰冬月、闰腊月的问题;修复日历不准的问题;修复物候错误;大运、小运、流年支持自定义轮数。
|
||||
|
||||
v1.2.3 修复除夕错误;代码优化。
|
||||
|
||||
v1.2.2 修正2016年国庆节数据;删除5月23日世界读书日;修复v1.2.0和v1.2.1的重大bug。
|
||||
|
||||
v1.2.0 支持0001到9999年。
|
||||
|
||||
@@ -12,7 +12,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.2.13</version>
|
||||
<version>1.2.15</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.2.13</version>
|
||||
<version>1.2.15</version>
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<url>https://github.com/6tail/lunar-java</url>
|
||||
<description>a calendar library for Solar and Chinese Lunar</description>
|
||||
|
||||
@@ -83,11 +83,21 @@ public class Foto {
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否月斋
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isMonthZhai() {
|
||||
int m = getMonth();
|
||||
return 1 == m || 5 == m || 9 == m;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否杨公忌
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayYangGong() {
|
||||
for (FotoFestival f : getFestivals()) {
|
||||
if ("杨公忌".equals(f.getName())) {
|
||||
@@ -97,11 +107,21 @@ public class Foto {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否朔望斋
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayZhaiShuoWang() {
|
||||
int d = getDay();
|
||||
return 1 == d || 15 == d;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否六斋日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayZhaiSix() {
|
||||
int d = getDay();
|
||||
if (8 == d || 14 == d || 15 == d || 23 == d || 29 == d || 30 == d) {
|
||||
@@ -113,11 +133,21 @@ public class Foto {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否十斋日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayZhaiTen() {
|
||||
int d = getDay();
|
||||
return 1 == d || 8 == d || 14 == d || 15 == d || 18 == d || 23 == d || 24 == d || 28 == d || 29 == d || 30 == d;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否观音斋
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayZhaiGuanYin() {
|
||||
String k = getMonth() + "-" + getDay();
|
||||
for (String d : FotoUtil.DAY_ZHAI_GUAN_YIN) {
|
||||
@@ -128,6 +158,69 @@ public class Foto {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取星宿
|
||||
*
|
||||
* @return 星宿
|
||||
*/
|
||||
public String getXiu() {
|
||||
return FotoUtil.getXiu(getMonth(), getDay());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取宿吉凶
|
||||
*
|
||||
* @return 吉/凶
|
||||
*/
|
||||
public String getXiuLuck() {
|
||||
return LunarUtil.XIU_LUCK.get(getXiu());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取宿歌诀
|
||||
*
|
||||
* @return 宿歌诀
|
||||
*/
|
||||
public String getXiuSong() {
|
||||
return LunarUtil.XIU_SONG.get(getXiu());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取政
|
||||
*
|
||||
* @return 政
|
||||
*/
|
||||
public String getZheng() {
|
||||
return LunarUtil.ZHENG.get(getXiu());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取动物
|
||||
*
|
||||
* @return 动物
|
||||
*/
|
||||
public String getAnimal() {
|
||||
return LunarUtil.ANIMAL.get(getXiu());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取宫
|
||||
*
|
||||
* @return 宫
|
||||
*/
|
||||
public String getGong() {
|
||||
return LunarUtil.GONG.get(getXiu());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取兽
|
||||
*
|
||||
* @return 兽
|
||||
*/
|
||||
public String getShou() {
|
||||
return LunarUtil.SHOU.get(getGong());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getYearInChinese() + "年" + getMonthInChinese() + "月" + getDayInChinese();
|
||||
|
||||
@@ -842,8 +842,8 @@ public class Lunar {
|
||||
*/
|
||||
public String getJie() {
|
||||
String jie = "";
|
||||
for(int i=1,j=JIE_QI.length;i<j;i+=2){
|
||||
String key = JIE_QI[i];
|
||||
for(int i=0,j=JIE_QI_IN_USE.length;i<j;i+=2){
|
||||
String key = JIE_QI_IN_USE[i];
|
||||
Solar d = jieQi.get(key);
|
||||
if (d.getYear() == solar.getYear() && d.getMonth() == solar.getMonth() && d.getDay() == solar.getDay()) {
|
||||
jie = key;
|
||||
@@ -860,8 +860,8 @@ public class Lunar {
|
||||
*/
|
||||
public String getQi() {
|
||||
String qi = "";
|
||||
for(int i=0,j=JIE_QI.length;i<j;i+=2){
|
||||
String key = JIE_QI[i];
|
||||
for(int i=1,j=JIE_QI_IN_USE.length;i<j;i+=2){
|
||||
String key = JIE_QI_IN_USE[i];
|
||||
Solar d = jieQi.get(key);
|
||||
if (d.getYear() == solar.getYear() && d.getMonth() == solar.getMonth() && d.getDay() == solar.getDay()) {
|
||||
qi = key;
|
||||
@@ -1954,12 +1954,22 @@ public class Lunar {
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getNextJie() {
|
||||
return getNextJie(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一节令(顺推的第一个节令)
|
||||
*
|
||||
* @param wholeDay 是否按天计
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getNextJie(boolean wholeDay) {
|
||||
int l = JIE_QI_IN_USE.length/2;
|
||||
String[] conditions = new String[l];
|
||||
for(int i=0;i<l;i++){
|
||||
conditions[i] = JIE_QI_IN_USE[i*2];
|
||||
}
|
||||
return getNearJieQi(true, conditions);
|
||||
return getNearJieQi(true, conditions, wholeDay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1968,12 +1978,22 @@ public class Lunar {
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getPrevJie() {
|
||||
return getPrevJie(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上一节令(逆推的第一个节令)
|
||||
*
|
||||
* @param wholeDay 是否按天计
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getPrevJie(boolean wholeDay) {
|
||||
int l = JIE_QI_IN_USE.length/2;
|
||||
String[] conditions = new String[l];
|
||||
for(int i=0;i<l;i++){
|
||||
conditions[i] = JIE_QI_IN_USE[i*2];
|
||||
}
|
||||
return getNearJieQi(false, conditions);
|
||||
return getNearJieQi(false, conditions, wholeDay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1982,12 +2002,22 @@ public class Lunar {
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getNextQi() {
|
||||
return getNextQi(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一气令(顺推的第一个气令)
|
||||
*
|
||||
* @param wholeDay 是否按天计
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getNextQi(boolean wholeDay) {
|
||||
int l = JIE_QI_IN_USE.length/2;
|
||||
String[] conditions = new String[l];
|
||||
for(int i=0;i<l;i++){
|
||||
conditions[i] = JIE_QI_IN_USE[i*2+1];
|
||||
}
|
||||
return getNearJieQi(true, conditions);
|
||||
return getNearJieQi(true, conditions, wholeDay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1996,12 +2026,22 @@ public class Lunar {
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getPrevQi() {
|
||||
return getPrevQi(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上一气令(逆推的第一个气令)
|
||||
*
|
||||
* @param wholeDay 是否按天计
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getPrevQi(boolean wholeDay) {
|
||||
int l = JIE_QI_IN_USE.length/2;
|
||||
String[] conditions = new String[l];
|
||||
for(int i=0;i<l;i++){
|
||||
conditions[i] = JIE_QI_IN_USE[i*2+1];
|
||||
}
|
||||
return getNearJieQi(false, conditions);
|
||||
return getNearJieQi(false, conditions, wholeDay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2010,7 +2050,17 @@ public class Lunar {
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getNextJieQi() {
|
||||
return getNearJieQi(true, null);
|
||||
return getNextJieQi(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一节气(顺推的第一个节气)
|
||||
*
|
||||
* @param wholeDay 是否按天计
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getNextJieQi(boolean wholeDay) {
|
||||
return getNearJieQi(true, null, wholeDay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2019,7 +2069,17 @@ public class Lunar {
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getPrevJieQi() {
|
||||
return getNearJieQi(false, null);
|
||||
return getPrevJieQi(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上一节气(逆推的第一个节气)
|
||||
*
|
||||
* @param wholeDay 是否按天计
|
||||
* @return 节气
|
||||
*/
|
||||
public JieQi getPrevJieQi(boolean wholeDay) {
|
||||
return getNearJieQi(false, null, wholeDay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2027,9 +2087,10 @@ public class Lunar {
|
||||
*
|
||||
* @param forward 是否顺推,true为顺推,false为逆推
|
||||
* @param conditions 过滤条件,如果设置过滤条件,仅返回匹配该名称的
|
||||
* @param wholeDay 是否按天计
|
||||
* @return 节气
|
||||
*/
|
||||
protected JieQi getNearJieQi(boolean forward, String[] conditions) {
|
||||
protected JieQi getNearJieQi(boolean forward, String[] conditions, boolean wholeDay) {
|
||||
String name = null;
|
||||
Solar near = null;
|
||||
Set<String> filters = new HashSet<String>();
|
||||
@@ -2037,7 +2098,7 @@ public class Lunar {
|
||||
Collections.addAll(filters, conditions);
|
||||
}
|
||||
boolean filter = !filters.isEmpty();
|
||||
String today = solar.toYmdHms();
|
||||
String today = wholeDay ? solar.toYmd() : solar.toYmdHms();
|
||||
for (Map.Entry<String, Solar> entry : jieQi.entrySet()) {
|
||||
String jq = convertJieQi(entry.getKey());
|
||||
if (filter) {
|
||||
@@ -2046,22 +2107,34 @@ public class Lunar {
|
||||
}
|
||||
}
|
||||
Solar solar = entry.getValue();
|
||||
String day = solar.toYmdHms();
|
||||
String day = wholeDay ? solar.toYmd() : solar.toYmdHms();
|
||||
if (forward) {
|
||||
if (day.compareTo(today) < 0) {
|
||||
continue;
|
||||
}
|
||||
if (null == near || day.compareTo(near.toYmdHms()) < 0) {
|
||||
if (null == near) {
|
||||
name = jq;
|
||||
near = solar;
|
||||
} else {
|
||||
String nearDay = wholeDay ? near.toYmd() : near.toYmdHms();
|
||||
if (day.compareTo(nearDay) < 0) {
|
||||
name = jq;
|
||||
near = solar;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (day.compareTo(today) > 0) {
|
||||
continue;
|
||||
}
|
||||
if (null == near || day.compareTo(near.toYmdHms()) > 0) {
|
||||
if (null == near) {
|
||||
name = jq;
|
||||
near = solar;
|
||||
} else {
|
||||
String nearDay = wholeDay ? near.toYmd() : near.toYmdHms();
|
||||
if (day.compareTo(nearDay) > 0) {
|
||||
name = jq;
|
||||
near = solar;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2626,7 +2699,7 @@ public class Lunar {
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public String getWuHou() {
|
||||
JieQi jieQi = getPrevJieQi();
|
||||
JieQi jieQi = getPrevJieQi(true);
|
||||
String name = jieQi.getName();
|
||||
int offset = 0;
|
||||
for (int i = 0, j = JIE_QI.length; i < j; i++) {
|
||||
@@ -2644,6 +2717,21 @@ public class Lunar {
|
||||
return LunarUtil.WU_HOU[(offset * 3 + days / 5) % LunarUtil.WU_HOU.length];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取候
|
||||
*
|
||||
* @return 候
|
||||
*/
|
||||
public String getHou() {
|
||||
JieQi jieQi = getPrevJieQi(true);
|
||||
String name = jieQi.getName();
|
||||
Calendar currentCalendar = ExactDate.fromYmd(solar.getYear(), solar.getMonth(), solar.getDay());
|
||||
Solar startSolar = jieQi.getSolar();
|
||||
Calendar startCalendar = ExactDate.fromYmd(startSolar.getYear(), startSolar.getMonth(), startSolar.getDay());
|
||||
int days = (int) ((currentCalendar.getTimeInMillis() - startCalendar.getTimeInMillis()) / MS_PER_DAY);
|
||||
return String.format("%s %s", name, LunarUtil.HOU[(days / 5) % LunarUtil.HOU.length]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日禄
|
||||
* @return 日禄
|
||||
|
||||
@@ -15,6 +15,16 @@ import java.util.Map;
|
||||
*/
|
||||
public class LunarYear {
|
||||
|
||||
/**
|
||||
* 元
|
||||
*/
|
||||
private static final String[] YUAN = {"下", "上", "中"};
|
||||
|
||||
/**
|
||||
* 运
|
||||
*/
|
||||
private static final String[] YUN = {"七", "八", "九", "一", "二", "三", "四", "五", "六"};
|
||||
|
||||
/**
|
||||
* 闰冬月年份
|
||||
*/
|
||||
@@ -264,6 +274,24 @@ public class LunarYear {
|
||||
return LunarUtil.NUMBER[offset+1] + "日得金";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取三元
|
||||
*
|
||||
* @return 元
|
||||
*/
|
||||
public String getYuan() {
|
||||
return YUAN[((year + 2696) / 60) % 3] + "元";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取九运
|
||||
*
|
||||
* @return 运
|
||||
*/
|
||||
public String getYun() {
|
||||
return YUN[((year + 2696) / 20) % 9] + "运";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return year + "";
|
||||
|
||||
@@ -149,6 +149,33 @@ public class Tao {
|
||||
return TaoUtil.BA_HUI.containsKey(lunar.getDayInGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否明戊日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayMingWu() {
|
||||
return "戊".equals(lunar.getDayGan());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否暗戊日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayAnWu() {
|
||||
return lunar.getDayZhi().equals(TaoUtil.AN_WU[Math.abs(getMonth()) - 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否戊日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayWu() {
|
||||
return isDayMingWu() || isDayAnWu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s年%s月%s", getYearInChinese(), getMonthInChinese(), getDayInChinese());
|
||||
|
||||
@@ -261,4 +261,25 @@ public class FotoUtil {
|
||||
put("12-30", Collections.nCopies(1, new FotoFestival("诸神下降,察访善恶", "犯者男女俱亡")));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 27星宿,佛教从印度传入中国,印度把28星宿改为27星宿,把牛宿(牛金牛)纳入了女宿(女土蝠)。
|
||||
*/
|
||||
public static final String[] XIU_27 = {"角", "亢", "氐", "房", "心", "尾", "箕", "斗", "女", "虚", "危", "室", "壁", "奎", "娄", "胃", "昴", "毕", "觜", "参", "井", "鬼", "柳", "星", "张", "翼", "轸"};
|
||||
|
||||
/**
|
||||
* 每月初一的27星宿偏移
|
||||
*/
|
||||
private static final int[] XIU_OFFSET = {11, 13, 15, 17, 19, 21, 24, 0, 2, 4, 7, 9};
|
||||
|
||||
/**
|
||||
* 获取27星宿
|
||||
*
|
||||
* @param month 佛历月
|
||||
* @param day 佛历日
|
||||
* @return 星宿
|
||||
*/
|
||||
public static String getXiu(int month, int day) {
|
||||
return XIU_27[(XIU_OFFSET[Math.abs(month)-1] + day - 1) % XIU_27.length];
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -128,7 +128,7 @@ public class SolarUtil {
|
||||
put("11-28", Collections.nCopies(1, "恩格斯诞辰纪念日"));
|
||||
put("12-1", Collections.nCopies(1, "世界艾滋病日"));
|
||||
put("12-12", Collections.nCopies(1, "西安事变纪念日"));
|
||||
put("12-13", Collections.nCopies(1, "南京大屠杀纪念日"));
|
||||
put("12-13", Collections.nCopies(1, "国家公祭日"));
|
||||
put("12-26", Collections.nCopies(1, "毛泽东诞辰纪念日"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -169,4 +169,9 @@ public class TaoUtil {
|
||||
*/
|
||||
public static final String[] WU_LA = {"1-1", "5-5", "7-7", "10-1", "12-8"};
|
||||
|
||||
/**
|
||||
* 暗戊
|
||||
*/
|
||||
public static final String[] AN_WU = {"未", "戌", "辰", "寅", "午", "子", "酉", "申", "巳", "亥", "卯", "丑"};
|
||||
|
||||
}
|
||||
|
||||
@@ -18,4 +18,14 @@ public class FotoTest {
|
||||
Assert.assertEquals("二五六五年十月十四 (三元降) (四天王巡行)", foto.toFullString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
Foto foto = Foto.fromLunar(Lunar.fromYmd(2020, 4, 13));
|
||||
Assert.assertEquals("氐", foto.getXiu());
|
||||
Assert.assertEquals("土", foto.getZheng());
|
||||
Assert.assertEquals("貉", foto.getAnimal());
|
||||
Assert.assertEquals("东", foto.getGong());
|
||||
Assert.assertEquals("青龙", foto.getShou());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -186,4 +186,12 @@ public class JieQiTest {
|
||||
Assert.assertEquals("2050-12-07 06:41:00", lunar.getJieQiTable().get("大雪").toYmdHms());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test9() {
|
||||
Solar solar = Solar.fromYmd(2021, 12, 21);
|
||||
Assert.assertEquals("冬至", solar.getLunar().getJieQi());
|
||||
Assert.assertEquals("", solar.getLunar().getJie());
|
||||
Assert.assertEquals("冬至", solar.getLunar().getQi());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -387,4 +387,11 @@ public class LunarTest {
|
||||
Assert.assertEquals("厕灶厨 外西南", lunar.getDayPositionTai());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test53() {
|
||||
Solar solar = Solar.fromYmd(2021, 11, 27);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals("[嫁娶, 祭祀, 祈福, 求嗣, 开光, 出行, 解除, 出火, 拆卸, 进人口, 入宅, 移徙, 安床, 栽种, 动土, 修造, 纳畜, 入殓, 安葬, 立碑, 除服, 成服]", lunar.getDayYi().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,4 +75,32 @@ public class WuHouTest {
|
||||
Assert.assertEquals(solar.toString(),"蚯蚓结",lunar.getWuHou());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test10(){
|
||||
Solar solar = new Solar(2021,12,21);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals(solar.toString(),"冬至 初候",lunar.getHou());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test11(){
|
||||
Solar solar = new Solar(2021,12,26);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals(solar.toString(),"冬至 二候",lunar.getHou());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test12(){
|
||||
Solar solar = new Solar(2021,12,31);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals(solar.toString(),"冬至 三候",lunar.getHou());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test13(){
|
||||
Solar solar = new Solar(2022,1,5);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals(solar.toString(),"小寒 初候",lunar.getHou());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,4 +61,82 @@ public class YearTest {
|
||||
Assert.assertEquals("三日得金",year.getDeJin());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test5(){
|
||||
LunarYear year = new LunarYear(1864);
|
||||
Assert.assertEquals("上元",year.getYuan());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test6(){
|
||||
LunarYear year = new LunarYear(1923);
|
||||
Assert.assertEquals("上元",year.getYuan());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test7(){
|
||||
LunarYear year = new LunarYear(1924);
|
||||
Assert.assertEquals("中元",year.getYuan());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test8(){
|
||||
LunarYear year = new LunarYear(1983);
|
||||
Assert.assertEquals("中元",year.getYuan());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test9(){
|
||||
LunarYear year = new LunarYear(1984);
|
||||
Assert.assertEquals("下元",year.getYuan());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test10(){
|
||||
LunarYear year = new LunarYear(2043);
|
||||
Assert.assertEquals("下元",year.getYuan());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test11(){
|
||||
LunarYear year = new LunarYear(1864);
|
||||
Assert.assertEquals("一运",year.getYun());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test12(){
|
||||
LunarYear year = new LunarYear(1883);
|
||||
Assert.assertEquals("一运",year.getYun());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test13(){
|
||||
LunarYear year = new LunarYear(1884);
|
||||
Assert.assertEquals("二运",year.getYun());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test14(){
|
||||
LunarYear year = new LunarYear(1903);
|
||||
Assert.assertEquals("二运",year.getYun());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test15(){
|
||||
LunarYear year = new LunarYear(1904);
|
||||
Assert.assertEquals("三运",year.getYun());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test16(){
|
||||
LunarYear year = new LunarYear(1923);
|
||||
Assert.assertEquals("三运",year.getYun());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test17(){
|
||||
LunarYear year = new LunarYear(2004);
|
||||
Assert.assertEquals("八运",year.getYun());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user