1
0
mirror of synced 2025-12-16 18:38:00 +08:00

修复八字排盘流年干支错误。

This commit is contained in:
6tail
2020-10-25 13:08:43 +08:00
parent 5680eb8d44
commit cc9444aa03
2 changed files with 52 additions and 3 deletions

View File

@@ -39,16 +39,17 @@ public class DaYun {
this.yun = yun;
this.lunar = yun.getLunar();
this.index = index;
int birthYear = lunar.getSolar().getYear();
int year = yun.getStartSolar().getYear();
if (index < 1) {
this.startYear = lunar.getSolar().getYear();
this.startYear = birthYear;
this.startAge = 1;
this.endYear = year - 1;
this.endAge = yun.getStartYear();
this.endAge = year - birthYear;
} else {
int add = (index - 1) * 10;
this.startYear = year + add;
this.startAge = yun.getStartYear() + add + 1;
this.startAge = this.startYear - birthYear + 1;
this.endYear = this.startYear + 9;
this.endAge = this.startAge + 9;
}

View File

@@ -250,6 +250,54 @@ public class BaZiTestNew {
Assert.assertEquals(ages[i], liuNian.getAge());
Assert.assertEquals(years[i] + "", ganZhi[i], liuNian.getGanZhi());
}
solar = new Solar(1981, 8, 16, 9, 30, 0);
lunar = solar.getLunar();
bazi = lunar.getEightChar();
yun = bazi.getYun(1);
daYun = yun.getDaYun();
years = new int[]{1981, 1982, 1983};
ages = new int[]{1, 2, 3};
ganZhi = new String[]{"辛酉","壬戌","癸亥"};
l = daYun[0].getLiuNian();
for (int i = 0, j = l.length; i < j; i++) {
LiuNian liuNian = l[i];
Assert.assertEquals(years[i], liuNian.getYear());
Assert.assertEquals(ages[i], liuNian.getAge());
Assert.assertEquals(ganZhi[i], liuNian.getGanZhi());
}
years = new int[]{1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993};
ages = new int[]{4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
ganZhi = new String[]{"甲子","乙丑","丙寅","丁卯","戊辰","己巳","庚午","辛未","壬申","癸酉"};
l = daYun[1].getLiuNian();
for (int i = 0, j = l.length; i < j; i++) {
LiuNian liuNian = l[i];
Assert.assertEquals(years[i], liuNian.getYear());
Assert.assertEquals(ages[i], liuNian.getAge());
Assert.assertEquals(ganZhi[i], liuNian.getGanZhi());
}
solar = new Solar(1981, 8, 8, 1, 30, 0);
lunar = solar.getLunar();
bazi = lunar.getEightChar();
yun = bazi.getYun(1);
daYun = yun.getDaYun();
l = daYun[0].getLiuNian();
Assert.assertEquals(0, l.length);
years = new int[]{1981,1982, 1983,1984, 1985, 1986, 1987, 1988, 1989, 1990};
ages = new int[]{1,2,3,4,5,6,7,8,9,10};
ganZhi = new String[]{"辛酉","壬戌","癸亥","甲子","乙丑","丙寅","丁卯","戊辰","己巳","庚午"};
l = daYun[1].getLiuNian();
for (int i = 0, j = l.length; i < j; i++) {
LiuNian liuNian = l[i];
Assert.assertEquals(years[i], liuNian.getYear());
Assert.assertEquals(ages[i], liuNian.getAge());
Assert.assertEquals(ganZhi[i], liuNian.getGanZhi());
}
}
/**