1
0
mirror of synced 2026-10-20 13:36:11 +08:00

八字增加可选流派(1晚子时日柱算明天,2晚子时日柱算当天,默认2)。

This commit is contained in:
6tail
2020-12-17 23:03:18 +08:00
parent bd19489441
commit b9acfec4d5
4 changed files with 157 additions and 28 deletions

View File

@@ -55,10 +55,14 @@ public class Lunar{
private int dayGanIndex;
/** 日对应的地支下标,0-11 */
private int dayZhiIndex;
/** 日对应的天干下标(最精确的,供八字用,晚子时算第二天),0-9 */
/** 日对应的天干下标(八字流派1,晚子时日柱算明天),0-9 */
private int dayGanIndexExact;
/** 日对应的地支下标(最精确的,供八字用,晚子时算第二天),0-11 */
/** 日对应的地支下标(八字流派1,晚子时日柱算明天),0-11 */
private int dayZhiIndexExact;
/** 日对应的天干下标(八字流派2,晚子时日柱算当天),0-9 */
private int dayGanIndexExact2;
/** 日对应的地支下标(八字流派2,晚子时日柱算当天),0-11 */
private int dayZhiIndexExact2;
/** 月对应的天干下标(以节交接当天起算),0-9 */
private int monthGanIndex;
/** 月对应的地支下标(以节交接当天起算),0-11 */
@@ -564,7 +568,11 @@ public class Lunar{
int dayGanExact = dayGanIndex;
int dayZhiExact = dayZhiIndex;
// 晚子时(夜子/子夜)应算作第二天
// 八字流派2,晚子时(夜子/子夜)日柱算当天
dayGanIndexExact2 = dayGanExact;
dayZhiIndexExact2 = dayZhiExact;
// 八字流派1,晚子时(夜子/子夜)日柱算明天
String hm = (hour<10?"0":"")+hour+":"+(minute<10?"0":"")+minute;
if(hm.compareTo("23:00")>=0&&hm.compareTo("23:59")<=0){
dayGanExact++;
@@ -807,7 +815,7 @@ public class Lunar{
}
/**
* 获取干支纪日(日柱,晚子时算第二天)
* 获取干支纪日(日柱,晚子时日柱算明天)
*
* @return 干支纪日(日柱),如己卯
*/
@@ -815,6 +823,15 @@ public class Lunar{
return getDayGanExact()+getDayZhiExact();
}
/**
* 获取干支纪日(日柱,晚子时日柱算当天)
*
* @return 干支纪日(日柱),如己卯
*/
public String getDayInGanZhiExact2(){
return getDayGanExact2()+getDayZhiExact2();
}
/**
* 获取日天干
*
@@ -825,7 +842,7 @@ public class Lunar{
}
/**
* 获取日天干(晚子时算第二天)
* 获取日天干(晚子时日柱算明天)
*
* @return 日天干,如甲
*/
@@ -833,6 +850,15 @@ public class Lunar{
return LunarUtil.GAN[dayGanIndexExact+1];
}
/**
* 获取日天干(晚子时日柱算当天)
*
* @return 日天干,如甲
*/
public String getDayGanExact2(){
return LunarUtil.GAN[dayGanIndexExact2+1];
}
/**
* 获取日地支
*
@@ -843,7 +869,7 @@ public class Lunar{
}
/**
* 获取日地支(晚子时算第二天)
* 获取日地支(晚子时日柱算明天)
*
* @return 日地支,如卯
*/
@@ -851,6 +877,15 @@ public class Lunar{
return LunarUtil.ZHI[dayZhiIndexExact+1];
}
/**
* 获取日地支(晚子时日柱算当天)
*
* @return 日地支,如卯
*/
public String getDayZhiExact2(){
return LunarUtil.ZHI[dayZhiIndexExact2+1];
}
/**
* 获取年生肖
*
@@ -2308,10 +2343,18 @@ public class Lunar{
return dayGanIndexExact;
}
public int getDayGanIndexExact2() {
return dayGanIndexExact2;
}
public int getDayZhiIndexExact() {
return dayZhiIndexExact;
}
public int getDayZhiIndexExact2() {
return dayZhiIndexExact2;
}
public int getMonthGanIndexExact() {
return monthGanIndexExact;
}
@@ -2479,13 +2522,21 @@ public class Lunar{
}
/**
* 获取日所在旬(晚子时算第二天)
* 获取日所在旬(晚子时日柱算明天)
* @return 旬
*/
public String getDayXunExact(){
return LunarUtil.getXun(getDayInGanZhiExact());
}
/**
* 获取日所在旬(晚子时日柱算当天)
* @return 旬
*/
public String getDayXunExact2(){
return LunarUtil.getXun(getDayInGanZhiExact2());
}
/**
* 获取值日空亡
* @return 空亡(旬空)
@@ -2495,13 +2546,21 @@ public class Lunar{
}
/**
* 获取值日空亡(晚子时算第二天)
* 获取值日空亡(晚子时日柱算明天)
* @return 空亡(旬空)
*/
public String getDayXunKongExact(){
return LunarUtil.getXunKong(getDayInGanZhiExact());
}
/**
* 获取值日空亡(晚子时日柱算当天)
* @return 空亡(旬空)
*/
public String getDayXunKongExact2(){
return LunarUtil.getXunKong(getDayInGanZhiExact2());
}
/**
* 获取时辰所在旬
* @return 旬