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