1
0
mirror of synced 2026-10-21 05:56:12 +08:00

v1.3.11 修复命宫、身宫的错误。

This commit is contained in:
6tail
2024-01-30 21:00:30 +08:00
parent 1411d8017f
commit e15a916e55
5 changed files with 90 additions and 32 deletions

View File

@@ -501,27 +501,27 @@ public class EightChar {
public String getMingGong() {
int monthZhiIndex = 0;
int timeZhiIndex = 0;
String monthZhi = getMonthZhi();
String timeZhi = getTimeZhi();
for (int i = 0, j = MONTH_ZHI.length; i < j; i++) {
String zhi = MONTH_ZHI[i];
if (lunar.getMonthZhiExact().equals(zhi)) {
if (monthZhi.equals(MONTH_ZHI[i])) {
monthZhiIndex = i;
break;
}
if (lunar.getTimeZhi().equals(zhi)) {
}
for (int i = 0, j = MONTH_ZHI.length; i < j; i++) {
if (timeZhi.equals(MONTH_ZHI[i])) {
timeZhiIndex = i;
break;
}
}
int zhiIndex = 26 - (monthZhiIndex + timeZhiIndex);
if (zhiIndex > 12) {
zhiIndex -= 12;
int offset = monthZhiIndex + timeZhiIndex;
offset = (offset >= 14 ? 26 : 14) - offset;
int ganIndex = (lunar.getYearGanIndexExact() + 1) * 2 + offset;
while (ganIndex > 10) {
ganIndex -= 10;
}
int jiaZiIndex = LunarUtil.getJiaZiIndex(lunar.getMonthInGanZhiExact()) - (monthZhiIndex - zhiIndex);
if (jiaZiIndex >= 60) {
jiaZiIndex -= 60;
}
if (jiaZiIndex < 0) {
jiaZiIndex += 60;
}
return LunarUtil.JIA_ZI[jiaZiIndex];
return LunarUtil.GAN[ganIndex] + MONTH_ZHI[offset];
}
/**
@@ -541,27 +541,29 @@ public class EightChar {
public String getShenGong() {
int monthZhiIndex = 0;
int timeZhiIndex = 0;
String monthZhi = getMonthZhi();
String timeZhi = getTimeZhi();
for (int i = 0, j = MONTH_ZHI.length; i < j; i++) {
String zhi = MONTH_ZHI[i];
if (lunar.getMonthZhiExact().equals(zhi)) {
if (monthZhi.equals(MONTH_ZHI[i])) {
monthZhiIndex = i;
break;
}
if (lunar.getTimeZhi().equals(zhi)) {
}
for (int i = 0, j = MONTH_ZHI.length; i < j; i++) {
if (timeZhi.equals(LunarUtil.ZHI[i])) {
timeZhiIndex = i;
break;
}
}
int zhiIndex = 2 + monthZhiIndex + timeZhiIndex;
if (zhiIndex > 12) {
zhiIndex -= 12;
int offset = monthZhiIndex + timeZhiIndex;
while (offset > 12) {
offset -= 12;
}
int jiaZiIndex = LunarUtil.getJiaZiIndex(lunar.getMonthInGanZhiExact()) - (monthZhiIndex - zhiIndex);
if (jiaZiIndex >= 60) {
jiaZiIndex -= 60;
int ganIndex = (lunar.getYearGanIndexExact() + 1) * 2 + (offset % 12);
while (ganIndex > 10) {
ganIndex -= 10;
}
if (jiaZiIndex < 0) {
jiaZiIndex += 60;
}
return LunarUtil.JIA_ZI[jiaZiIndex];
return LunarUtil.GAN[ganIndex] + MONTH_ZHI[offset];
}
/**