Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d226722d6 | ||
|
|
6dbf70186d | ||
|
|
b6bde78e59 | ||
|
|
701cec10a0 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -8,3 +8,17 @@
|
|||||||
1. 修复节气当天获取下一节气仍为当前节气的问题。
|
1. 修复节气当天获取下一节气仍为当前节气的问题。
|
||||||
2. 修复每日宜忌存在重复项的问题。
|
2. 修复每日宜忌存在重复项的问题。
|
||||||
3. 修复八字转阳历存在遗漏的问题。
|
3. 修复八字转阳历存在遗漏的问题。
|
||||||
|
|
||||||
|
## [1.3.14] - 2024-03-17
|
||||||
|
1. 修复八字转阳历存在遗漏的问题。
|
||||||
|
|
||||||
|
## [1.3.15] - 2024-11-12
|
||||||
|
1. 新增2025年法定假日数据。
|
||||||
|
|
||||||
|
## [1.4.0] - 2025-02-06
|
||||||
|
1. 修复九星错别字。
|
||||||
|
2. 优化每日宜忌算法。
|
||||||
|
3. 去除每日宜忌的重复项。
|
||||||
|
|
||||||
|
## [1.7.0] - 2025-02-12
|
||||||
|
1. 修复每日宜忌错别字。
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.6tail</groupId>
|
<groupId>cn.6tail</groupId>
|
||||||
<artifactId>lunar</artifactId>
|
<artifactId>lunar</artifactId>
|
||||||
<version>1.3.13</version>
|
<version>1.7.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.6tail</groupId>
|
<groupId>cn.6tail</groupId>
|
||||||
<artifactId>lunar</artifactId>
|
<artifactId>lunar</artifactId>
|
||||||
<version>1.3.13</version>
|
<version>1.7.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
3
pom.xml
3
pom.xml
@@ -7,7 +7,7 @@
|
|||||||
<groupId>cn.6tail</groupId>
|
<groupId>cn.6tail</groupId>
|
||||||
<artifactId>lunar</artifactId>
|
<artifactId>lunar</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.3.13</version>
|
<version>1.7.0</version>
|
||||||
<name>${project.groupId}:${project.artifactId}</name>
|
<name>${project.groupId}:${project.artifactId}</name>
|
||||||
<url>https://github.com/6tail/lunar-java</url>
|
<url>https://github.com/6tail/lunar-java</url>
|
||||||
<description>a calendar library for Solar and Chinese Lunar</description>
|
<description>a calendar library for Solar and Chinese Lunar</description>
|
||||||
@@ -104,6 +104,7 @@
|
|||||||
<goal>jar</goal>
|
<goal>jar</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
|
||||||
<additionalparam>-Xdoclint:none</additionalparam>
|
<additionalparam>-Xdoclint:none</additionalparam>
|
||||||
<source>${source-version}</source>
|
<source>${source-version}</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class NineStar {
|
|||||||
/**
|
/**
|
||||||
* 七色
|
* 七色
|
||||||
*/
|
*/
|
||||||
public static final String[] COLOR = {"白", "黒", "碧", "绿", "黄", "白", "赤", "白", "紫"};
|
public static final String[] COLOR = {"白", "黑", "碧", "绿", "黄", "白", "赤", "白", "紫"};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 五行
|
* 五行
|
||||||
|
|||||||
@@ -89,9 +89,13 @@ public class Solar {
|
|||||||
if (month < 1 || month > 12) {
|
if (month < 1 || month > 12) {
|
||||||
throw new IllegalArgumentException(String.format("wrong month %d", month));
|
throw new IllegalArgumentException(String.format("wrong month %d", month));
|
||||||
}
|
}
|
||||||
if (day < 1 || day > 31) {
|
if (day < 1) {
|
||||||
throw new IllegalArgumentException(String.format("wrong day %d", day));
|
throw new IllegalArgumentException(String.format("wrong day %d", day));
|
||||||
}
|
}
|
||||||
|
int days = SolarUtil.getDaysOfMonth(year, month);
|
||||||
|
if (day > days) {
|
||||||
|
throw new IllegalArgumentException(String.format("only %d days in solar year %d month %d", days, year, month));
|
||||||
|
}
|
||||||
if (hour < 0 || hour > 23) {
|
if (hour < 0 || hour > 23) {
|
||||||
throw new IllegalArgumentException(String.format("wrong hour %d", hour));
|
throw new IllegalArgumentException(String.format("wrong hour %d", hour));
|
||||||
}
|
}
|
||||||
@@ -335,9 +339,7 @@ public class Solar {
|
|||||||
Solar solarTime = jieQiList.get(4 + m);
|
Solar solarTime = jieQiList.get(4 + m);
|
||||||
if (solarTime.getYear() >= baseYear) {
|
if (solarTime.getYear() >= baseYear) {
|
||||||
// 日干支和节令干支的偏移值
|
// 日干支和节令干支的偏移值
|
||||||
Lunar lunar = solarTime.getLunar();
|
int d = LunarUtil.getJiaZiIndex(dayGanZhi) - LunarUtil.getJiaZiIndex(solarTime.getLunar().getDayInGanZhiExact2());
|
||||||
String dgz = (2 == sect) ? lunar.getDayInGanZhiExact2() : lunar.getDayInGanZhiExact();
|
|
||||||
int d = LunarUtil.getJiaZiIndex(dayGanZhi) - LunarUtil.getJiaZiIndex(dgz);
|
|
||||||
if (d < 0) {
|
if (d < 0) {
|
||||||
d += 60;
|
d += 60;
|
||||||
}
|
}
|
||||||
@@ -355,8 +357,8 @@ public class Solar {
|
|||||||
}
|
}
|
||||||
// 验证一下
|
// 验证一下
|
||||||
Solar solar = Solar.fromYmdHms(solarTime.getYear(), solarTime.getMonth(), solarTime.getDay(), hour, mi, s);
|
Solar solar = Solar.fromYmdHms(solarTime.getYear(), solarTime.getMonth(), solarTime.getDay(), hour, mi, s);
|
||||||
lunar = solar.getLunar();
|
Lunar lunar = solar.getLunar();
|
||||||
dgz = (2 == sect) ? lunar.getDayInGanZhiExact2() : lunar.getDayInGanZhiExact();
|
String dgz = (2 == sect) ? lunar.getDayInGanZhiExact2() : lunar.getDayInGanZhiExact();
|
||||||
if (lunar.getYearInGanZhiExact().equals(yearGanZhi) && lunar.getMonthInGanZhiExact().equals(monthGanZhi) && dgz.equals(dayGanZhi) && lunar.getTimeInGanZhi().equals(timeGanZhi)) {
|
if (lunar.getYearInGanZhiExact().equals(yearGanZhi) && lunar.getMonthInGanZhiExact().equals(monthGanZhi) && dgz.equals(dayGanZhi) && lunar.getTimeInGanZhi().equals(timeGanZhi)) {
|
||||||
l.add(solar);
|
l.add(solar);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.nlf.calendar.util.LunarUtil;
|
|||||||
*/
|
*/
|
||||||
public class LiuYue {
|
public class LiuYue {
|
||||||
/**
|
/**
|
||||||
* 序数,0-9
|
* 序数,0-11
|
||||||
*/
|
*/
|
||||||
private final int index;
|
private final int index;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -530,4 +530,17 @@ public class BaZiTest {
|
|||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test31() {
|
||||||
|
List<Solar> l = Solar.fromBaZi("丁卯","丁未","甲申","乙丑", 1, 1900);
|
||||||
|
List<String> actual = new ArrayList<String>();
|
||||||
|
for (Solar solar : l) {
|
||||||
|
actual.add(solar.toYmdHms());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> expected = new ArrayList<String>();
|
||||||
|
expected.add("1987-08-03 02:00:00");
|
||||||
|
Assert.assertEquals(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 农历测试
|
* 农历测试
|
||||||
@@ -409,7 +408,7 @@ public class LunarTest {
|
|||||||
Lunar lunar = solar.getLunar();
|
Lunar lunar = solar.getLunar();
|
||||||
Assert.assertEquals("甲辰", lunar.getMonthInGanZhi());
|
Assert.assertEquals("甲辰", lunar.getMonthInGanZhi());
|
||||||
Assert.assertEquals("癸卯", lunar.getMonthInGanZhiExact());
|
Assert.assertEquals("癸卯", lunar.getMonthInGanZhiExact());
|
||||||
Assert.assertEquals(4, lunar.getDayJi().size());
|
Assert.assertEquals("[出火, 入宅, 安葬, 伐木]", lunar.getDayJi().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class NineStarTest {
|
|||||||
@Test
|
@Test
|
||||||
public void test8() {
|
public void test8() {
|
||||||
LunarMonth m = LunarMonth.fromYm(2022, 1);
|
LunarMonth m = LunarMonth.fromYm(2022, 1);
|
||||||
Assert.assertEquals("二黒土天璇", m.getNineStar().toString());
|
Assert.assertEquals("二黑土天璇", m.getNineStar().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -77,4 +77,12 @@ public class NineStarTest {
|
|||||||
Assert.assertEquals("七赤金摇光", d.getTimeNineStar().toString());
|
Assert.assertEquals("七赤金摇光", d.getTimeNineStar().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test12() {
|
||||||
|
LunarMonth m = LunarMonth.fromYm(2024, 11);
|
||||||
|
Assert.assertEquals("四绿木天权", m.getNineStar().toString());
|
||||||
|
m = LunarMonth.fromYm(2024, 12);
|
||||||
|
Assert.assertEquals("三碧木天玑", m.getNineStar().toString());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user