diff --git a/README.md b/README.md
index 49f86f8..a317e30 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
cn.6tail
lunar
- 1.3.7
+ 1.3.8
```
diff --git a/README_EN.md b/README_EN.md
index 7631ae3..6af60b4 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -12,7 +12,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
cn.6tail
lunar
- 1.3.7
+ 1.3.8
```
diff --git a/pom.xml b/pom.xml
index cbeb8d1..1dd84da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
cn.6tail
lunar
jar
- 1.3.7
+ 1.3.8
${project.groupId}:${project.artifactId}
https://github.com/6tail/lunar-java
a calendar library for Solar and Chinese Lunar
diff --git a/src/main/java/com/nlf/calendar/Lunar.java b/src/main/java/com/nlf/calendar/Lunar.java
index 8445fc6..a79010a 100644
--- a/src/main/java/com/nlf/calendar/Lunar.java
+++ b/src/main/java/com/nlf/calendar/Lunar.java
@@ -2944,11 +2944,7 @@ public Fu getFu() {
days = current.subtract(start);
Solar liQiuSolar = Solar.fromYmd(liQiu.getYear(), liQiu.getMonth(), liQiu.getDay());
// 末伏
- if (!liQiuSolar.isAfter(start)) {
- if (days < 10) {
- return new Fu("末伏", days + 1);
- }
- } else {
+ if (liQiuSolar.isAfter(start)) {
// 中伏
if (days < 10) {
return new Fu("中伏", days + 11);
@@ -2956,9 +2952,9 @@ public Fu getFu() {
// 末伏第1天
start = start.next(10);
days = current.subtract(start);
- if (days < 10) {
- return new Fu("末伏", days + 1);
- }
+ }
+ if (days < 10) {
+ return new Fu("末伏", days + 1);
}
return null;
}
diff --git a/src/main/java/com/nlf/calendar/Solar.java b/src/main/java/com/nlf/calendar/Solar.java
index 0851760..36f38ba 100644
--- a/src/main/java/com/nlf/calendar/Solar.java
+++ b/src/main/java/com/nlf/calendar/Solar.java
@@ -358,26 +358,7 @@ public boolean isLeapYear() {
* @return 0123456
*/
public int getWeek() {
- Solar start = fromYmd(1582, 10, 15);
- int y = year;
- int m = month;
- int d = day;
- Solar current = fromYmd(y, m, d);
- // 蔡勒公式
- if (m < 3) {
- m += 12;
- y--;
- }
- int c = y / 100;
- y = y - c * 100;
- int x = y + y / 4 + c / 4 - 2 * c;
- int w;
- if (current.isBefore(start)) {
- w = (x + 13 * (m + 1) / 5 + d + 2) % 7;
- } else {
- w = (x + 26 * (m + 1) / 10 + d - 1) % 7;
- }
- return (w + 7) % 7;
+ return ((int)getJulianDay() + 7000002) % 7;
}
/**
diff --git a/src/main/java/com/nlf/calendar/util/LunarUtil.java b/src/main/java/com/nlf/calendar/util/LunarUtil.java
index 77a7a1e..36cc89b 100644
--- a/src/main/java/com/nlf/calendar/util/LunarUtil.java
+++ b/src/main/java/com/nlf/calendar/util/LunarUtil.java
@@ -42,7 +42,14 @@ public class LunarUtil{
/** 地支方位 */
public static final String[] POSITION_ZHI = {"坎","中","震","震","中","离","离","中","兑","兑","中","坎"};
/** 逐日胎神方位 */
- public static final String[] POSITION_TAI_DAY = {"占门碓 外东南","碓磨厕 外东南","厨灶炉 外正南","仓库门 外正南","房床栖 外正南","占门床 外正南","占碓磨 外正南","厕灶厨 外西南","仓库炉 外西南","房床门 外西南","门碓栖 外西南","碓磨床 外西南","厨灶碓 外西南","仓库厕 外正西","房床炉 外正西","占大门 外正西","碓磨栖 外正西","厨房床 外正西","仓库碓 外西北","房床厕 外西北","占门炉 外西北","门碓磨 外西北","厨灶栖 外西北","仓库床 外西北","房床碓 外正北","占门厕 外正北","碓磨炉 外正北","厨灶门 外正北","仓库栖 外正北","占房床 房内北","占门碓 房内北","碓磨厕 房内北","厨灶炉 房内北","门仓库 房内北","床房栖 房内中","占门床 房内中","占碓磨 房内南","厨磨厕 房内南","仓库炉 房内南","房床门 房内西","门碓栖 房内东","碓磨床 房内东","厨灶碓 房内东","仓库厕 房内东","房床炉 房内中","占大门 外东北","碓磨栖 外东北","厨灶床 外东北","仓库碓 外东北","房床厕 外东北","占门炉 外东北","门碓磨 外正东","厨灶栖 外正东","仓库床 外正东","房床碓 外正东","占门厕 外正东","碓磨炉 外东南","厨灶门 外东南","仓库栖 外东南","占房床 外东南"};
+ public static final String[] POSITION_TAI_DAY = {
+ "占门碓 外东南","碓磨厕 外东南","厨灶炉 外正南","仓库门 外正南","房床栖 外正南","占门床 外正南","占碓磨 外正南","厨灶厕 外西南","仓库炉 外西南","房床门 外西南",
+ "占门栖 外西南","碓磨床 外西南","厨灶碓 外西南","仓库厕 外正西","房床炉 外正西","占大门 外正西","碓磨栖 外正西","厨灶床 外正西","仓库碓 外西北","房床厕 外西北",
+ "占门炉 外西北","碓磨门 外西北","厨灶栖 外西北","仓库床 外西北","房床碓 外正北","占门厕 外正北","碓磨炉 外正北","厨灶门 外正北","仓库栖 外正北","占房床 房内北",
+ "占门碓 房内北","碓磨厕 房内北","厨灶炉 房内北","仓库门 房内北","房床栖 房内中","占门床 房内中","占碓磨 房内南","厨灶厕 房内南","仓库炉 房内南","房床门 房内西",
+ "占门栖 房内东","碓磨床 房内东","厨灶碓 房内东","仓库厕 房内东","房床炉 房内中","占大门 外东北","碓磨栖 外东北","厨灶床 外东北","仓库碓 外东北","房床厕 外东北",
+ "占门炉 外东北","碓磨门 外正东","厨灶栖 外正东","仓库床 外正东","房床碓 外正东","占门厕 外正东","碓磨炉 外东南","厨灶门 外东南","仓库栖 外东南","占房床 外东南"
+ };
/** 逐月胎神方位 */
public static final String[] POSITION_TAI_MONTH = {"占房床","占户窗","占门堂","占厨灶","占房床","占床仓","占碓磨","占厕户","占门房","占房床","占灶炉","占房床"};
/** 地支 */
@@ -306,7 +313,7 @@ public class LunarUtil{
put("轸","吉");
}
};
- /** 星宿对应吉凶 */
+ /** 星宿歌诀 */
public static final Map XIU_SONG = new HashMap(){
private static final long serialVersionUID = -1;
{
diff --git a/src/test/java/test/LunarMonthTest.java b/src/test/java/test/LunarMonthTest.java
index d6b915f..3a17d5a 100644
--- a/src/test/java/test/LunarMonthTest.java
+++ b/src/test/java/test/LunarMonthTest.java
@@ -53,4 +53,10 @@ public void test5(){
Assert.assertEquals("壬寅", month.getGanZhi());
}
+ @Test
+ public void test6(){
+ LunarMonth month = LunarMonth.fromYm(2023, 9);
+ Assert.assertEquals("癸亥", month.getGanZhi());
+ }
+
}
diff --git a/src/test/java/test/LunarTest.java b/src/test/java/test/LunarTest.java
index 06feb25..35b2359 100644
--- a/src/test/java/test/LunarTest.java
+++ b/src/test/java/test/LunarTest.java
@@ -377,7 +377,7 @@ public void test51() {
public void test52() {
Solar solar = Solar.fromYmd(2011, 11, 12);
Lunar lunar = solar.getLunar();
- Assert.assertEquals("厕灶厨 外西南", lunar.getDayPositionTai());
+ Assert.assertEquals("厨灶厕 外西南", lunar.getDayPositionTai());
}
@Test
@@ -645,4 +645,10 @@ public void test94() {
Assert.assertEquals("九一七年冬月十六", lunar.toString());
}
+ @Test
+ public void test95() {
+ Lunar lunar = Solar.fromYmd(2023, 10, 30).getLunar();
+ Assert.assertEquals("闭", lunar.getZhiXing());
+ }
+
}
diff --git a/src/test/java/test/NineStarTest.java b/src/test/java/test/NineStarTest.java
index b9b657f..1eea8ad 100644
--- a/src/test/java/test/NineStarTest.java
+++ b/src/test/java/test/NineStarTest.java
@@ -1,6 +1,8 @@
package test;
import com.nlf.calendar.Lunar;
+import com.nlf.calendar.LunarMonth;
+import com.nlf.calendar.LunarYear;
import com.nlf.calendar.Solar;
import org.junit.Assert;
import org.junit.Test;
@@ -10,17 +12,69 @@ public class NineStarTest {
public void test1() {
Lunar lunar = Solar.fromYmd(1985, 2, 19).getLunar();
Assert.assertEquals("六", lunar.getYearNineStar().getNumber());
+ Assert.assertEquals("五黄土玉衡", lunar.getDayNineStar().toString());
}
@Test
public void test2() {
Lunar lunar = Lunar.fromYmd(2022, 1, 1);
Assert.assertEquals("六白金开阳", lunar.getYearNineStar().toString());
+ Assert.assertEquals("四绿木天权", lunar.getDayNineStar().toString());
}
@Test
public void test3() {
Lunar lunar = Lunar.fromYmd(2033, 1, 1);
Assert.assertEquals("四绿木天权", lunar.getYearNineStar().toString());
+ Assert.assertEquals("一白水天枢", lunar.getDayNineStar().toString());
}
+
+ @Test
+ public void test4() {
+ LunarYear y = LunarYear.fromYear(1985);
+ Assert.assertEquals("六白金开阳", y.getNineStar().toString());
+ }
+
+ @Test
+ public void test5() {
+ LunarYear y = LunarYear.fromYear(2022);
+ Assert.assertEquals("五黄土玉衡", y.getNineStar().toString());
+ }
+
+ @Test
+ public void test6() {
+ LunarYear y = LunarYear.fromYear(2033);
+ Assert.assertEquals("三碧木天玑", y.getNineStar().toString());
+ }
+
+ @Test
+ public void test7() {
+ LunarMonth m = LunarMonth.fromYm(1985, 2);
+ Assert.assertEquals("四绿木天权", m.getNineStar().toString());
+ }
+
+ @Test
+ public void test8() {
+ LunarMonth m = LunarMonth.fromYm(2022, 1);
+ Assert.assertEquals("二黒土天璇", m.getNineStar().toString());
+ }
+
+ @Test
+ public void test9() {
+ LunarMonth m = LunarMonth.fromYm(2033, 1);
+ Assert.assertEquals("五黄土玉衡", m.getNineStar().toString());
+ }
+
+ @Test
+ public void test10() {
+ Lunar d = Lunar.fromYmdHms(2033, 1, 1, 12, 0,0);
+ Assert.assertEquals("七赤金摇光", d.getTimeNineStar().toString());
+ }
+
+ @Test
+ public void test11() {
+ Lunar d = Lunar.fromYmdHms(2011, 5, 3, 23, 0,0);
+ Assert.assertEquals("七赤金摇光", d.getTimeNineStar().toString());
+ }
+
}
diff --git a/src/test/java/test/WeekTest.java b/src/test/java/test/WeekTest.java
index 091f11a..d89773d 100644
--- a/src/test/java/test/WeekTest.java
+++ b/src/test/java/test/WeekTest.java
@@ -54,4 +54,47 @@ public void test2(){
Solar solar = Solar.fromYmd(1582, 10, 15);
Assert.assertEquals(5, solar.getWeek());
}
+
+ @Test
+ public void test3(){
+ Solar solar = Solar.fromYmd(1129, 11, 17);
+ Assert.assertEquals(0, solar.getWeek());
+ }
+
+ @Test
+ public void test4(){
+ Solar solar = Solar.fromYmd(1129, 11, 1);
+ Assert.assertEquals(5, solar.getWeek());
+ }
+
+ @Test
+ public void test5(){
+ Solar solar = Solar.fromYmd(8, 11, 1);
+ Assert.assertEquals(4, solar.getWeek());
+ }
+
+ @Test
+ public void test6(){
+ Solar solar = Solar.fromYmd(1582, 9, 30);
+ Assert.assertEquals(0, solar.getWeek());
+ }
+
+ @Test
+ public void test7(){
+ Solar solar = Solar.fromYmd(1582, 1, 1);
+ Assert.assertEquals(1, solar.getWeek());
+ }
+
+ @Test
+ public void test8(){
+ Solar solar = Solar.fromYmd(1500, 2, 29);
+ Assert.assertEquals(6, solar.getWeek());
+ }
+
+ @Test
+ public void test9(){
+ Solar solar = Solar.fromYmd(9865, 7, 26);
+ Assert.assertEquals(3, solar.getWeek());
+ }
+
}