v1.2.23 新增525心理健康节;修复出现多个全国中小学生安全教育日的问题;新增胎息。
This commit is contained in:
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.2.22</version>
|
||||
<version>1.2.23</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -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.22</version>
|
||||
<version>1.2.23</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.22</version>
|
||||
<version>1.2.23</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>
|
||||
|
||||
@@ -474,6 +474,26 @@ public class EightChar {
|
||||
return LunarUtil.NAYIN.get(getTaiYuan());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取胎息
|
||||
*
|
||||
* @return 胎息
|
||||
*/
|
||||
public String getTaiXi() {
|
||||
int ganIndex = (2 == sect) ? lunar.getDayGanIndexExact2() : lunar.getDayGanIndexExact();
|
||||
int zhiIndex = (2 == sect) ? lunar.getDayZhiIndexExact2() : lunar.getDayZhiIndexExact();
|
||||
return LunarUtil.HE_GAN_5[ganIndex] + LunarUtil.HE_ZHI_6[zhiIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取胎息纳音
|
||||
*
|
||||
* @return 纳音
|
||||
*/
|
||||
public String getTaiXiNaYin() {
|
||||
return LunarUtil.NAYIN.get(getTaiXi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取命宫
|
||||
*
|
||||
@@ -531,7 +551,10 @@ public class EightChar {
|
||||
timeZhiIndex = i;
|
||||
}
|
||||
}
|
||||
int zhiIndex = (2 + (monthZhiIndex + timeZhiIndex)) % 12;
|
||||
int zhiIndex = 2 + monthZhiIndex + timeZhiIndex;
|
||||
if (zhiIndex > 12) {
|
||||
zhiIndex -= 12;
|
||||
}
|
||||
int jiaZiIndex = LunarUtil.getJiaZiIndex(lunar.getMonthInGanZhiExact()) - (monthZhiIndex - zhiIndex);
|
||||
if (jiaZiIndex >= 60) {
|
||||
jiaZiIndex -= 60;
|
||||
|
||||
@@ -1904,7 +1904,7 @@ public class Lunar {
|
||||
* @return 日冲,如申
|
||||
*/
|
||||
public String getDayChong() {
|
||||
return LunarUtil.CHONG[dayZhiIndex + 1];
|
||||
return LunarUtil.CHONG[dayZhiIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1946,7 +1946,7 @@ public class Lunar {
|
||||
* @return 无情之克的日冲天干,如甲
|
||||
*/
|
||||
public String getDayChongGan() {
|
||||
return LunarUtil.CHONG_GAN[dayGanIndex + 1];
|
||||
return LunarUtil.CHONG_GAN[dayGanIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1955,7 +1955,7 @@ public class Lunar {
|
||||
* @return 有情之克的日冲天干,如甲
|
||||
*/
|
||||
public String getDayChongGanTie() {
|
||||
return LunarUtil.CHONG_GAN_TIE[dayGanIndex + 1];
|
||||
return LunarUtil.CHONG_GAN_TIE[dayGanIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1964,7 +1964,7 @@ public class Lunar {
|
||||
* @return 时冲,如申
|
||||
*/
|
||||
public String getTimeChong() {
|
||||
return LunarUtil.CHONG[timeZhiIndex + 1];
|
||||
return LunarUtil.CHONG[timeZhiIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2006,7 +2006,7 @@ public class Lunar {
|
||||
* @return 无情之克的时冲天干,如甲
|
||||
*/
|
||||
public String getTimeChongGan() {
|
||||
return LunarUtil.CHONG_GAN[timeGanIndex + 1];
|
||||
return LunarUtil.CHONG_GAN[timeGanIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2015,7 +2015,7 @@ public class Lunar {
|
||||
* @return 有情之克的时冲天干,如甲
|
||||
*/
|
||||
public String getTimeChongGanTie() {
|
||||
return LunarUtil.CHONG_GAN_TIE[timeGanIndex + 1];
|
||||
return LunarUtil.CHONG_GAN_TIE[timeGanIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -235,7 +235,7 @@ public class LunarTime {
|
||||
* @return 时冲,如申
|
||||
*/
|
||||
public String getChong() {
|
||||
return LunarUtil.CHONG[zhiIndex + 1];
|
||||
return LunarUtil.CHONG[zhiIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,7 +277,7 @@ public class LunarTime {
|
||||
* @return 无情之克的时冲天干,如甲
|
||||
*/
|
||||
public String getChongGan() {
|
||||
return LunarUtil.CHONG_GAN[ganIndex + 1];
|
||||
return LunarUtil.CHONG_GAN[ganIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,7 +286,7 @@ public class LunarTime {
|
||||
* @return 有情之克的时冲天干,如甲
|
||||
*/
|
||||
public String getChongGanTie() {
|
||||
return LunarUtil.CHONG_GAN_TIE[ganIndex + 1];
|
||||
return LunarUtil.CHONG_GAN_TIE[ganIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -386,7 +386,7 @@ public class Solar {
|
||||
if (null != f) {
|
||||
l.add(f);
|
||||
}
|
||||
if (day + 7 >= SolarUtil.getDaysOfMonth(year, month)) {
|
||||
if (day + 7 > SolarUtil.getDaysOfMonth(year, month)) {
|
||||
f = SolarUtil.WEEK_FESTIVAL.get(month + "-0-" + week);
|
||||
if (null != f) {
|
||||
l.add(f);
|
||||
|
||||
@@ -351,32 +351,17 @@ public class LunarUtil{
|
||||
}
|
||||
};
|
||||
/** 地支相冲(子午相冲,丑未相冲,寅申相冲,辰戌相冲,卯酉相冲,巳亥相冲),由于地支对应十二生肖,也就对应了生肖相冲 */
|
||||
public static final String[] CHONG = {"","午","未","申","酉","戌","亥","子","丑","寅","卯","辰","巳"};
|
||||
public static final String[] CHONG = {"午","未","申","酉","戌","亥","子","丑","寅","卯","辰","巳"};
|
||||
/** 天干相冲之无情之克(阳克阳,阴克阴) */
|
||||
public static final String[] CHONG_GAN = {"","戊","己","庚","辛","壬","癸","甲","乙","丙","丁"};
|
||||
/** 天干四冲(无情之克中克得最严重的4个) */
|
||||
public static final Map<String,String> CHONG_GAN_BAD = new HashMap<String,String>(){
|
||||
private static final long serialVersionUID = -1;
|
||||
{
|
||||
put("庚","甲");
|
||||
put("辛","乙");
|
||||
put("壬","丙");
|
||||
put("癸","丁");
|
||||
}
|
||||
};
|
||||
public static final String[] CHONG_GAN = {"戊","己","庚","辛","壬","癸","甲","乙","丙","丁"};
|
||||
/** 天干相冲之有情之克(阳克阴,阴克阳) */
|
||||
public static final String[] CHONG_GAN_TIE = {"","己","戊","辛","庚","癸","壬","乙","甲","丁","丙"};
|
||||
/** 天干五合(有情之克中最有情的5个) */
|
||||
public static final Map<String,String> CHONG_GAN_TIE_GOOD = new HashMap<String,String>(){
|
||||
private static final long serialVersionUID = -1;
|
||||
{
|
||||
put("甲","己");
|
||||
put("丙","辛");
|
||||
put("戊","癸");
|
||||
put("庚","乙");
|
||||
put("壬","丁");
|
||||
}
|
||||
};
|
||||
public static final String[] CHONG_GAN_TIE = {"己","戊","辛","庚","癸","壬","乙","甲","丁","丙"};
|
||||
/** 天干四冲(无情之克中克得最严重的4个) */
|
||||
public static final String[] CHONG_GAN_4 = {"庚","辛","壬","癸","","","甲","乙","丙","丁"};
|
||||
/** 天干五合(有情之克中最有情的5个,甲己合,乙庚合,丙辛合,丁壬合,戊癸合) */
|
||||
public static final String[] HE_GAN_5 = {"己","庚","辛","壬","癸","甲","乙","丙","丁","戊"};
|
||||
/** 地支六合(子丑合,寅亥合,卯戌合,辰酉合,巳申合,午未合) */
|
||||
public static final String[] HE_ZHI_6 = {"丑","子","亥","戌","酉","申","未","午","巳","辰","卯","寅"};
|
||||
/** 煞(逢巳日、酉日、丑日必煞东;亥日、卯日、未日必煞西;申日、子日、辰日必煞南;寅日、午日、戌日必煞北) */
|
||||
public static final Map<String,String> SHA = new HashMap<String,String>(){
|
||||
private static final long serialVersionUID = -1;
|
||||
|
||||
@@ -100,6 +100,7 @@ public class SolarUtil {
|
||||
put("5-5", Collections.nCopies(1, "马克思诞辰纪念日"));
|
||||
put("5-8", Collections.nCopies(1, "世界红十字日"));
|
||||
put("5-11", Collections.nCopies(1, "世界肥胖日"));
|
||||
put("5-25", Collections.nCopies(1, "525心理健康节"));
|
||||
put("5-27", Collections.nCopies(1, "上海解放日"));
|
||||
put("5-31", Collections.nCopies(1, "世界无烟日"));
|
||||
put("6-5", Collections.nCopies(1, "世界环境日"));
|
||||
|
||||
@@ -230,6 +230,24 @@ public class BaZiTest {
|
||||
Assert.assertEquals("身宫", "壬午", lunar.getEightChar().getShenGong());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShenGong1() {
|
||||
Lunar lunar = new Solar(1994, 12, 6, 2, 0, 0).getLunar();
|
||||
Assert.assertEquals("身宫", "丁丑", lunar.getEightChar().getShenGong());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShenGong2() {
|
||||
Lunar lunar = new Solar(1990, 12, 11, 6, 0, 0).getLunar();
|
||||
Assert.assertEquals("身宫", "庚辰", lunar.getEightChar().getShenGong());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShenGong3() {
|
||||
Lunar lunar = new Solar(1993, 5, 23, 4, 0, 0).getLunar();
|
||||
Assert.assertEquals("身宫", "庚申", lunar.getEightChar().getShenGong());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBaZi2Solar() {
|
||||
Solar solar = Solar.fromYmdHms(2027,1,27,12,0,0);
|
||||
|
||||
Reference in New Issue
Block a user