Skip to content

Commit

Permalink
Merge branch 'v1.1.0-SNAPSHOT'
Browse files Browse the repository at this point in the history
  • Loading branch information
6tail committed Oct 25, 2020
2 parents df6119c + cc9444a commit f1be264
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/com/nlf/calendar/eightchar/DaYun.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ public DaYun(Yun yun, int index) {
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;
}
Expand Down
48 changes: 48 additions & 0 deletions src/test/java/sample/BaZiTestNew.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,54 @@ public void testLiuNian() {
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());
}
}

/**
Expand Down

0 comments on commit f1be264

Please sign in to comment.