Skip to content

Commit

Permalink
v1.3.9 修复星期错误的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
6tail committed Nov 9, 2023
1 parent 9e36b07 commit a174022
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
<dependency>
<groupId>cn.6tail</groupId>
<artifactId>lunar</artifactId>
<version>1.3.8</version>
<version>1.3.9</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
<dependency>
<groupId>cn.6tail</groupId>
<artifactId>lunar</artifactId>
<version>1.3.8</version>
<version>1.3.9</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 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.3.8</version>
<version>1.3.9</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
2 changes: 1 addition & 1 deletion src/main/java/com/nlf/calendar/Solar.java
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public boolean isLeapYear() {
* @return 0123456
*/
public int getWeek() {
return ((int)getJulianDay() + 7000002) % 7;
return ((int)(getJulianDay() + 0.5) + 7000001) % 7;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/sample/BaZiTestNew.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void testBazi2Solar6() {
public void test7() {
Solar solar = new Solar(2020, 5, 26, 23, 43, 0);
Lunar lunar = solar.getLunar();
//庚子, 辛巳, 庚午, 丙子]
// [庚子, 辛巳, 庚午, 丙子]
System.out.println(lunar.getEightChar());
}

Expand Down
12 changes: 12 additions & 0 deletions src/test/java/test/WeekTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,16 @@ public void test9(){
Assert.assertEquals(3, solar.getWeek());
}

@Test
public void test10(){
Assert.assertEquals(6, Solar.fromYmd(1961, 9, 30).getWeek());
Assert.assertEquals(6, Solar.fromYmdHms(1961, 9, 30, 23, 59, 59).getWeek());
Assert.assertEquals(6, Solar.fromYmdHms(1961, 9, 30, 20, 0, 0).getWeek());
}

@Test
public void test11(){
Assert.assertEquals(3, Solar.fromYmdHms(2021, 9, 15, 20, 0, 0).getWeek());
}

}

0 comments on commit a174022

Please sign in to comment.