1
0
mirror of synced 2026-02-11 15:38:01 +08:00

v1.7.5 修复极端情况下八字转公历时刻出现遗漏的问题;更新△T参数;优化吉神宜驱、凶神宜忌。

This commit is contained in:
6tail
2025-10-01 10:39:10 +08:00
parent 664af99ae0
commit cb931339cf
11 changed files with 185 additions and 96 deletions

View File

@@ -39,3 +39,8 @@
## [1.7.4] - 2025-04-29
1. 修复身宫报错的问题。
## [1.7.5] - 2025-09-17
1. 修复:极端情况下八字转公历时刻出现遗漏的问题。
2. 优化更新△T参数。
3. 优化:吉神宜驱、凶神宜忌。

View File

@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
<dependency>
<groupId>cn.6tail</groupId>
<artifactId>lunar</artifactId>
<version>1.7.4</version>
<version>1.7.5</version>
</dependency>
```

View File

@@ -12,7 +12,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
<dependency>
<groupId>cn.6tail</groupId>
<artifactId>lunar</artifactId>
<version>1.7.4</version>
<version>1.7.5</version>
</dependency>
```

78
pom.xml
View File

@@ -7,7 +7,7 @@
<groupId>cn.6tail</groupId>
<artifactId>lunar</artifactId>
<packaging>jar</packaging>
<version>1.7.4</version>
<version>1.7.5</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>
@@ -30,18 +30,6 @@
<developerConnection>scm:git:git@github.com:6tail/lunar-java.git</developerConnection>
<url>git@github.com:6tail/lunar-java.git</url>
</scm>
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus snapshot repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Sonatype Nexus release repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<properties>
<encoding>UTF-8</encoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -49,30 +37,29 @@
<source-version>1.5</source-version>
<target-version>1.5</target-version>
<creator>6tail</creator>
<junit-version>4.13.2</junit-version>
<maven-compiler-plugin-version>3.3</maven-compiler-plugin-version>
<maven-jar-plugin-version>3.3.0</maven-jar-plugin-version>
<maven-surefire-plugin-version>2.5</maven-surefire-plugin-version>
<maven-javadoc-plugin-version>2.9</maven-javadoc-plugin-version>
<maven-source-plugin-version>2.4</maven-source-plugin-version>
<maven-release-plugin-version>2.2.2</maven-release-plugin-version>
<maven-gpg-plugin-version>1.6</maven-gpg-plugin-version>
<maven-deploy-plugin-version>3.1.2</maven-deploy-plugin-version>
<maven-assembly-plugin-version>2.2-beta-5</maven-assembly-plugin-version>
<central-publishing-maven-plugin-version>0.7.0</central-publishing-maven-plugin-version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/test/java</testSourceDirectory>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -84,6 +71,23 @@
<encoding>${encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin-version}</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Created-By>${creator}</Created-By>
<Built-By>${creator}</Built-By>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
@@ -99,7 +103,6 @@
<version>${maven-javadoc-plugin-version}</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
@@ -117,7 +120,6 @@
<version>${maven-source-plugin-version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
@@ -141,7 +143,6 @@
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
@@ -152,7 +153,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<version>${maven-assembly-plugin-version}</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${project.artifactId}-${project.version}</finalName>
@@ -167,6 +168,33 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin-version}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>${central-publishing-maven-plugin-version}</version>
<extensions>true</extensions>
<configuration>
<autoPublish>true</autoPublish>
<publishingServerId>central</publishingServerId>
<deploymentName>${project.groupId}-${project.artifactId}-${project.version}</deploymentName>
</configuration>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>publish</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<finalName>${project.artifactId}-${project.version}</finalName>
</build>

View File

@@ -1889,7 +1889,7 @@ public class Lunar {
* @return 日吉神
*/
public List<String> getDayJiShen() {
return LunarUtil.getDayJiShen(getMonth(), getDayInGanZhi());
return LunarUtil.getDayJiShen(getMonthZhiIndex(), getDayInGanZhi());
}
/**
@@ -1898,7 +1898,7 @@ public class Lunar {
* @return 日凶煞
*/
public List<String> getDayXiongSha() {
return LunarUtil.getDayXiongSha(getMonth(), getDayInGanZhi());
return LunarUtil.getDayXiongSha(getMonthZhiIndex(), getDayInGanZhi());
}
/**

View File

@@ -357,6 +357,9 @@ public class Solar {
}
// 验证一下
Solar solar = Solar.fromYmdHms(solarTime.getYear(), solarTime.getMonth(), solarTime.getDay(), hour, mi, s);
if (d == 30) {
solar = solar.nextHour(-1);
}
Lunar lunar = solar.getLunar();
String dgz = (2 == sect) ? lunar.getDayInGanZhiExact2() : lunar.getDayInGanZhiExact();
if (lunar.getYearInGanZhiExact().equals(yearGanZhi) && lunar.getMonthInGanZhiExact().equals(monthGanZhi) && dgz.equals(dayGanZhi) && lunar.getTimeInGanZhi().equals(timeGanZhi)) {

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@ import com.nlf.calendar.Solar;
* 寿星天文历工具
*
* @author 6tail
* @link http://www.nongli.net/sxwnl/
* @link https://github.com/sxwnl/sxwnl
*/
public class ShouXingUtil {
/**
@@ -56,10 +56,18 @@ public class ShouXingUtil {
2000, 63.87, 0.1, 0, 0,
2005, 64.7, 0.21, 0, 0,
2012, 66.8, 0.22, 0, 0,
2018, 73.6, 0.40, 0, 0,
2021, 78.1, 0.44, 0, 0,
2024, 83.1, 0.55, 0, 0,
2028, 98.6
// 2018, 69.0, 0.36, 0, 0,
// 使用skyfeild的DE440s△T预测数据拟合
2016, 68.1024, 0.5456, -0.0542, -0.001172,
2020, 69.3612, 0.0422, -0.0502, 0.006216,
2024, 69.1752, -0.0335, -0.0048, 0.000811,
2028, 69.0206, -0.0275, 0.0055, -0.000014,
2032, 68.9981, 0.0163, 0.0054, 0.000006,
2036, 69.1498, 0.0599, 0.0053, 0.000026,
2040, 69.4751, 0.1035, 0.0051, 0.000046,
2044, 69.9737, 0.1469, 0.0050, 0.000066,
2048, 70.6451, 0.1903, 0.0049, 0.000085,
2050, 71.0457
};
private static final double[] XL0 = {
10000000000D,

View File

@@ -549,4 +549,26 @@ public class BaZiTest {
EightChar eightChar = lunar.getEightChar();
Assert.assertEquals("身宫", "己丑", eightChar.getShenGong());
}
@Test
public void test50() {
List<Solar> solarTimes = Solar.fromBaZi("壬申", "壬寅", "庚辰", "甲申", 1, 1801);
List<String> actual = new ArrayList<String>();
for (Solar solarTime : solarTimes) {
actual.add(solarTime.toYmdHms());
}
List<String> expected = new ArrayList<String>();
expected.add("1812-02-18 16:00:00");
expected.add("1992-03-05 15:00:00");
Assert.assertEquals(expected, actual);
}
@Test
public void test51() {
Solar solar = new Solar(2013, 8, 8, 9, 30, 0);
Lunar lunar = solar.getLunar();
EightChar eightChar = lunar.getEightChar();
Assert.assertEquals("时柱", "癸巳", eightChar.getTime());
}
}

View File

@@ -21,30 +21,30 @@ public class JieQiTest {
Map<String,String> jieQi = new HashMap<String, String>(){
private static final long serialVersionUID = 1L;
{
put("冬至","2021-12-21 23:59:09");
put("小寒","2022-01-05 17:13:54");
put("大寒","2022-01-20 10:38:56");
put("立春","2022-02-04 04:50:36");
put("雨水","2022-02-19 00:42:50");
put("惊蛰","2022-03-05 22:43:34");
put("春分","2022-03-20 23:33:15");
put("清明","2022-04-05 03:20:03");
put("谷雨","2022-04-20 10:24:07");
put("立夏","2022-05-05 20:25:47");
put("小满","2022-05-21 09:22:25");
put("芒种","2022-06-06 00:25:38");
put("夏至","2022-06-21 17:13:40");
put("小暑","2022-07-07 10:37:49");
put("大暑","2022-07-23 04:06:49");
put("立秋","2022-08-07 20:28:57");
put("处暑","2022-08-23 11:15:59");
put("白露","2022-09-07 23:32:07");
put("秋分","2022-09-23 09:03:31");
put("寒露","2022-10-08 15:22:16");
put("霜降","2022-10-23 18:35:31");
put("立冬","2022-11-07 18:45:18");
put("小雪","2022-11-22 16:20:18");
put("大雪","2022-12-07 11:46:04");
put("冬至","2021-12-21 23:59:19");
put("小寒","2022-01-05 17:14:04");
put("大寒","2022-01-20 10:39:06");
put("立春","2022-02-04 04:50:47");
put("雨水","2022-02-19 00:43:01");
put("惊蛰","2022-03-05 22:43:45");
put("春分","2022-03-20 23:33:26");
put("清明","2022-04-05 03:20:14");
put("谷雨","2022-04-20 10:24:18");
put("立夏","2022-05-05 20:25:57");
put("小满","2022-05-21 09:22:36");
put("芒种","2022-06-06 00:25:49");
put("夏至","2022-06-21 17:13:51");
put("小暑","2022-07-07 10:38:01");
put("大暑","2022-07-23 04:07:00");
put("立秋","2022-08-07 20:29:08");
put("处暑","2022-08-23 11:16:11");
put("白露","2022-09-07 23:32:18");
put("秋分","2022-09-23 09:03:43");
put("寒露","2022-10-08 15:22:28");
put("霜降","2022-10-23 18:35:43");
put("立冬","2022-11-07 18:45:30");
put("小雪","2022-11-22 16:20:30");
put("大雪","2022-12-07 11:46:16");
}
};
@@ -183,7 +183,7 @@ public class JieQiTest {
@Test
public void test8() {
Lunar lunar = Lunar.fromYmd(2050, 12, 1);
Assert.assertEquals("2050-12-07 06:40:53", lunar.getJieQiTable().get("DA_XUE").toYmdHms());
Assert.assertEquals("2050-12-07 06:41:54", lunar.getJieQiTable().get("DA_XUE").toYmdHms());
}
@Test
@@ -197,13 +197,13 @@ public class JieQiTest {
@Test
public void test10() {
Lunar lunar = Solar.fromYmd(2023, 6, 1).getLunar();
Assert.assertEquals("2022-12-22 05:48:01", lunar.getJieQiTable().get("冬至").toYmdHms());
Assert.assertEquals("2022-12-22 05:48:12", lunar.getJieQiTable().get("冬至").toYmdHms());
}
@Test
public void test11() {
Lunar lunar = Solar.fromYmd(2025, 3, 5).getLunar();
Assert.assertEquals("2025-03-05 16:07:02", lunar.getJieQiTable().get("惊蛰").toYmdHms());
Assert.assertEquals("2025-03-05 16:07:18", lunar.getJieQiTable().get("惊蛰").toYmdHms());
}
}

View File

@@ -678,4 +678,11 @@ public class LunarTest {
Assert.assertEquals("[嫁娶, 开市, 纳财, 出火]", lunar.getDayJi().toString());
}
@Test
public void test100() {
Solar solar = new Solar(2025, 9, 16);
Lunar lunar = solar.getLunar();
Assert.assertEquals("[时德, 阳德, 民日, 玉宇, 司命]", lunar.getDayJiShen().toString());
Assert.assertEquals("[河魁, 死神, 天吏, 致死, 往亡]", lunar.getDayXiongSha().toString());
}
}