Skip to content

Commit

Permalink
v1.2.26 修复物候的错误。
Browse files Browse the repository at this point in the history
  • Loading branch information
6tail committed Nov 1, 2022
1 parent ee0b227 commit 51afe36
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>cn.6tail</groupId>
<artifactId>lunar</artifactId>
<packaging>jar</packaging>
<version>1.2.25</version>
<version>1.2.26</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>
Expand Down Expand Up @@ -105,6 +105,7 @@
</goals>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<source>${source-version}</source>
</configuration>
</execution>
</executions>
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/nlf/calendar/Lunar.java
Original file line number Diff line number Diff line change
Expand Up @@ -2990,7 +2990,11 @@ public String getWuHou() {
}
Solar startSolar = jieQi.getSolar();
int days = ExactDate.getDaysBetween(startSolar.getYear(), startSolar.getMonth(), startSolar.getDay(), solar.getYear(), solar.getMonth(), solar.getDay());
return LunarUtil.WU_HOU[(offset * 3 + days / 5) % LunarUtil.WU_HOU.length];
int index = days / 5;
if (index > 2) {
index = 2;
}
return LunarUtil.WU_HOU[(offset * 3 + index) % LunarUtil.WU_HOU.length];
}

/**
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/test/WuHouTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,18 @@ public void test13(){
Assert.assertEquals(solar.toString(),"小寒 初候",lunar.getHou());
}

@Test
public void test15(){
Solar solar = new Solar(2022,8,22);
Lunar lunar = solar.getLunar();
Assert.assertEquals(solar.toString(),"寒蝉鸣",lunar.getWuHou());
}

@Test
public void test16(){
Solar solar = new Solar(2022,8,23);
Lunar lunar = solar.getLunar();
Assert.assertEquals(solar.toString(),"鹰乃祭鸟",lunar.getWuHou());
}

}

0 comments on commit 51afe36

Please sign in to comment.