From ee2d381fb7d771441061bec6bdf1c64ba2dded22 Mon Sep 17 00:00:00 2001
From: 6tail <6tail@6tail.cn>
Date: Mon, 15 Nov 2021 21:26:52 +0800
Subject: [PATCH] =?UTF-8?q?v1.2.11=20=E4=BF=AE=E6=AD=A3=E8=83=8E=E7=A5=9E?=
=?UTF-8?q?=E6=95=B0=E6=8D=AE=EF=BC=9B=E5=A2=9E=E5=8A=A0=E7=A6=8F=E7=A5=9E?=
=?UTF-8?q?=E6=B5=81=E6=B4=BE=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +-
README_EN.md | 2 +-
pom.xml | 2 +-
src/main/java/com/nlf/calendar/Lunar.java | 28 ++++++++++++---
src/main/java/com/nlf/calendar/LunarTime.java | 36 ++++++++++++++-----
5 files changed, 55 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index 51d14d9..73117f3 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)
cn.6tail
lunar
- 1.2.10
+ 1.2.11
```
diff --git a/README_EN.md b/README_EN.md
index 691b703..cf00303 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.2.10
+ 1.2.11
```
diff --git a/pom.xml b/pom.xml
index 667b85d..21e9e23 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
cn.6tail
lunar
jar
- 1.2.10
+ 1.2.11
${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 56bd257..b4ba754 100644
--- a/src/main/java/com/nlf/calendar/Lunar.java
+++ b/src/main/java/com/nlf/calendar/Lunar.java
@@ -1178,12 +1178,22 @@ public class Lunar {
}
/**
- * 获取日福神方位描述
+ * 获取日福神方位描述(默认流派:2)
*
* @return 福神方位描述,如东北
*/
public String getDayPositionFuDesc() {
- return LunarUtil.POSITION_DESC.get(getDayPositionFu());
+ return getDayPositionFuDesc(2);
+ }
+
+ /**
+ * 获取日福神方位描述
+ *
+ * @param sect 流派,1或2
+ * @return 福神方位描述,如东北
+ */
+ public String getDayPositionFuDesc(int sect) {
+ return LunarUtil.POSITION_DESC.get(getDayPositionFu(sect));
}
/**
@@ -1278,12 +1288,22 @@ public class Lunar {
}
/**
- * 获取时辰福神方位描述
+ * 获取时辰福神方位描述,默认流派2
*
* @return 福神方位描述,如东北
*/
public String getTimePositionFuDesc() {
- return LunarUtil.POSITION_DESC.get(getTimePositionFu());
+ return getTimePositionFuDesc(2);
+ }
+
+ /**
+ * 获取时辰福神方位描述
+ *
+ * @param sect 流派,1或2
+ * @return 福神方位描述,如东北
+ */
+ public String getTimePositionFuDesc(int sect) {
+ return LunarUtil.POSITION_DESC.get(getTimePositionFu(sect));
}
/**
diff --git a/src/main/java/com/nlf/calendar/LunarTime.java b/src/main/java/com/nlf/calendar/LunarTime.java
index 3d27827..a262117 100644
--- a/src/main/java/com/nlf/calendar/LunarTime.java
+++ b/src/main/java/com/nlf/calendar/LunarTime.java
@@ -136,21 +136,41 @@ public class LunarTime {
}
/**
- * 获取福神方位
+ * 获取福神方位(默认流派:2)
*
* @return 福神方位,如艮
*/
public String getPositionFu() {
- return LunarUtil.POSITION_FU[ganIndex + 1];
+ return getPositionFu(2);
+ }
+
+ /**
+ * 获取福神方位
+ *
+ * @param sect 流派,1或2
+ * @return 福神方位,如艮
+ */
+ public String getPositionFu(int sect) {
+ return (1 == sect ? LunarUtil.POSITION_FU : LunarUtil.POSITION_FU_2)[ganIndex + 1];
+ }
+
+ /**
+ * 获取福神方位描述(默认流派:2)
+ *
+ * @return 福神方位描述,如东北
+ */
+ public String getPositionFuDesc() {
+ return getPositionFuDesc(2);
}
/**
* 获取福神方位描述
*
+ * @param sect 流派,1或2
* @return 福神方位描述,如东北
*/
- public String getPositionFuDesc() {
- return LunarUtil.POSITION_DESC.get(getPositionFu());
+ public String getPositionFuDesc(int sect) {
+ return LunarUtil.POSITION_DESC.get(getPositionFu(sect));
}
/**
@@ -342,12 +362,12 @@ public class LunarTime {
*/
public String getMinHm() {
int hour = lunar.getHour();
- if (hour <1){
+ if (hour < 1) {
return "00:00";
} else if (hour > 22) {
return "23:00";
}
- return String.format("%02d:00", hour % 2 == 0? hour - 1 : hour);
+ return String.format("%02d:00", hour % 2 == 0 ? hour - 1 : hour);
}
/**
@@ -357,12 +377,12 @@ public class LunarTime {
*/
public String getMaxHm() {
int hour = lunar.getHour();
- if (hour <1){
+ if (hour < 1) {
return "00:59";
} else if (hour > 22) {
return "23:59";
}
- return String.format("%02d:59", hour % 2 == 0? hour : hour + 1);
+ return String.format("%02d:59", hour % 2 == 0 ? hour : hour + 1);
}
@Override