v1.3.6 中元节改为农历七月十五;修复Solar的nextMonth超期问题。
This commit is contained in:
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.3.5</version>
|
||||
<version>1.3.6</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -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.5</version>
|
||||
<version>1.3.6</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.3.5</version>
|
||||
<version>1.3.6</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>
|
||||
|
||||
@@ -714,19 +714,17 @@ public class Solar {
|
||||
int y = year + years;
|
||||
int m = month;
|
||||
int d = day;
|
||||
// 2月处理
|
||||
if (2 == m) {
|
||||
if (1582 == y && 10 == m) {
|
||||
if (d > 4 && d < 15) {
|
||||
d += 10;
|
||||
}
|
||||
} else if (2 == m) {
|
||||
if (d > 28) {
|
||||
if (!SolarUtil.isLeapYear(y)) {
|
||||
d = 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (1582 == y && 10 == m) {
|
||||
if (d > 4 && d < 15) {
|
||||
d += 10;
|
||||
}
|
||||
}
|
||||
return fromYmdHms(y, m, d, hour, minute, second);
|
||||
}
|
||||
|
||||
@@ -740,18 +738,15 @@ public class Solar {
|
||||
int y = month.getYear();
|
||||
int m = month.getMonth();
|
||||
int d = day;
|
||||
// 2月处理
|
||||
if (2 == m) {
|
||||
if (d > 28) {
|
||||
if (!SolarUtil.isLeapYear(y)) {
|
||||
d = 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (1582 == y && 10 == m) {
|
||||
if (d > 4 && d < 15) {
|
||||
d += 10;
|
||||
}
|
||||
} else {
|
||||
int maxDay = SolarUtil.getDaysOfMonth(y, m);
|
||||
if (d > maxDay) {
|
||||
d = maxDay;
|
||||
}
|
||||
}
|
||||
return fromYmdHms(y, m, d, hour, minute, second);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class LunarUtil{
|
||||
put("6-6",Collections.nCopies(1,"天贶节"));
|
||||
put("6-24",Collections.nCopies(1,"观莲节"));
|
||||
put("6-25",Collections.nCopies(1,"五谷母节"));
|
||||
put("7-14",Collections.nCopies(1,"中元节"));
|
||||
put("7-15",Collections.nCopies(1,"中元节"));
|
||||
put("7-22",Collections.nCopies(1,"财神节"));
|
||||
put("7-29",Collections.nCopies(1,"地藏节"));
|
||||
put("8-1",Collections.nCopies(1,"天灸日"));
|
||||
|
||||
@@ -171,4 +171,28 @@ public class SolarTest {
|
||||
Assert.assertEquals("1582-09-29", solar.next(-6).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test27(){
|
||||
Solar solar = Solar.fromYmd(2023, 8, 31);
|
||||
Assert.assertEquals("2023-09-30", solar.nextMonth(1).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test28(){
|
||||
Solar solar = Solar.fromYmd(2023, 8, 31);
|
||||
Assert.assertEquals("2023-10-31", solar.nextMonth(2).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test29(){
|
||||
Solar solar = Solar.fromYmd(2023, 8, 31);
|
||||
Assert.assertEquals("2025-08-31", solar.nextYear(2).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test30(){
|
||||
Solar solar = Solar.fromYmd(2023, 8, 31);
|
||||
Assert.assertEquals("2024-02-29", solar.nextMonth(6).toYmd());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user