1
0
mirror of synced 2026-02-04 12:07:59 +08:00

v1.2.14 佛历新增27宿;修复宜忌重复的问题;修复获取气时缺冬至的问题。

This commit is contained in:
6tail
2021-12-08 21:45:12 +08:00
parent bab052909b
commit e9ec0fc4b9
9 changed files with 174 additions and 7 deletions

View File

@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
<dependency> <dependency>
<groupId>cn.6tail</groupId> <groupId>cn.6tail</groupId>
<artifactId>lunar</artifactId> <artifactId>lunar</artifactId>
<version>1.2.13</version> <version>1.2.14</version>
</dependency> </dependency>
``` ```
@@ -54,3 +54,31 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
## 文档 ## 文档
请移步至 [http://6tail.cn/calendar/api.html](http://6tail.cn/calendar/api.html "http://6tail.cn/calendar/api.html") 请移步至 [http://6tail.cn/calendar/api.html](http://6tail.cn/calendar/api.html "http://6tail.cn/calendar/api.html")
## 更新日志
v1.2.14 佛历新增27宿修复宜忌重复的问题修复获取气时缺冬至的问题。
v1.2.13 新增道历Tao。
v1.2.12 修复星宿方位错误。
v1.2.11 修正胎神数据;增加福神流派。
v1.2.9 新增2022年法定假日。
v1.2.8 新增佛历Foto更改Lunar中的getOtherFestivals方法为传统节日。
v1.2.7 修复儒略日转阳历秒数为60的错误。
v1.2.6 新增治水、分饼、耕田、得金、日禄新增时辰LunarTime新增获取当天的所有时辰。
v1.2.5 修复公元0至4年转阴历错误的问题。
v1.2.4 修复闰冬月、闰腊月的问题;修复日历不准的问题;修复物候错误;大运、小运、流年支持自定义轮数。
v1.2.3 修复除夕错误;代码优化。
v1.2.2 修正2016年国庆节数据删除5月23日世界读书日修复v1.2.0和v1.2.1的重大bug。
v1.2.0 支持0001到9999年。

View File

@@ -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.2.13</version> <version>1.2.14</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>

View File

@@ -83,11 +83,21 @@ public class Foto {
return l; return l;
} }
/**
* 是否月斋
*
* @return true/false
*/
public boolean isMonthZhai() { public boolean isMonthZhai() {
int m = getMonth(); int m = getMonth();
return 1 == m || 5 == m || 9 == m; return 1 == m || 5 == m || 9 == m;
} }
/**
* 是否杨公忌
*
* @return true/false
*/
public boolean isDayYangGong() { public boolean isDayYangGong() {
for (FotoFestival f : getFestivals()) { for (FotoFestival f : getFestivals()) {
if ("杨公忌".equals(f.getName())) { if ("杨公忌".equals(f.getName())) {
@@ -97,11 +107,21 @@ public class Foto {
return false; return false;
} }
/**
* 是否朔望斋
*
* @return true/false
*/
public boolean isDayZhaiShuoWang() { public boolean isDayZhaiShuoWang() {
int d = getDay(); int d = getDay();
return 1 == d || 15 == d; return 1 == d || 15 == d;
} }
/**
* 是否六斋日
*
* @return true/false
*/
public boolean isDayZhaiSix() { public boolean isDayZhaiSix() {
int d = getDay(); int d = getDay();
if (8 == d || 14 == d || 15 == d || 23 == d || 29 == d || 30 == d) { if (8 == d || 14 == d || 15 == d || 23 == d || 29 == d || 30 == d) {
@@ -113,11 +133,21 @@ public class Foto {
return false; return false;
} }
/**
* 是否十斋日
*
* @return true/false
*/
public boolean isDayZhaiTen() { public boolean isDayZhaiTen() {
int d = getDay(); int d = getDay();
return 1 == d || 8 == d || 14 == d || 15 == d || 18 == d || 23 == d || 24 == d || 28 == d || 29 == d || 30 == d; return 1 == d || 8 == d || 14 == d || 15 == d || 18 == d || 23 == d || 24 == d || 28 == d || 29 == d || 30 == d;
} }
/**
* 是否观音斋
*
* @return true/false
*/
public boolean isDayZhaiGuanYin() { public boolean isDayZhaiGuanYin() {
String k = getMonth() + "-" + getDay(); String k = getMonth() + "-" + getDay();
for (String d : FotoUtil.DAY_ZHAI_GUAN_YIN) { for (String d : FotoUtil.DAY_ZHAI_GUAN_YIN) {
@@ -128,6 +158,69 @@ public class Foto {
return false; return false;
} }
/**
* 获取星宿
*
* @return 星宿
*/
public String getXiu() {
return FotoUtil.getXiu(getMonth(), getDay());
}
/**
* 获取宿吉凶
*
* @return 吉/凶
*/
public String getXiuLuck() {
return LunarUtil.XIU_LUCK.get(getXiu());
}
/**
* 获取宿歌诀
*
* @return 宿歌诀
*/
public String getXiuSong() {
return LunarUtil.XIU_SONG.get(getXiu());
}
/**
* 获取政
*
* @return 政
*/
public String getZheng() {
return LunarUtil.ZHENG.get(getXiu());
}
/**
* 获取动物
*
* @return 动物
*/
public String getAnimal() {
return LunarUtil.ANIMAL.get(getXiu());
}
/**
* 获取宫
*
* @return 宫
*/
public String getGong() {
return LunarUtil.GONG.get(getXiu());
}
/**
* 获取兽
*
* @return 兽
*/
public String getShou() {
return LunarUtil.SHOU.get(getGong());
}
@Override @Override
public String toString() { public String toString() {
return getYearInChinese() + "" + getMonthInChinese() + "" + getDayInChinese(); return getYearInChinese() + "" + getMonthInChinese() + "" + getDayInChinese();

View File

@@ -842,8 +842,8 @@ public class Lunar {
*/ */
public String getJie() { public String getJie() {
String jie = ""; String jie = "";
for(int i=1,j=JIE_QI.length;i<j;i+=2){ for(int i=0,j=JIE_QI_IN_USE.length;i<j;i+=2){
String key = JIE_QI[i]; String key = JIE_QI_IN_USE[i];
Solar d = jieQi.get(key); Solar d = jieQi.get(key);
if (d.getYear() == solar.getYear() && d.getMonth() == solar.getMonth() && d.getDay() == solar.getDay()) { if (d.getYear() == solar.getYear() && d.getMonth() == solar.getMonth() && d.getDay() == solar.getDay()) {
jie = key; jie = key;
@@ -860,8 +860,8 @@ public class Lunar {
*/ */
public String getQi() { public String getQi() {
String qi = ""; String qi = "";
for(int i=0,j=JIE_QI.length;i<j;i+=2){ for(int i=1,j=JIE_QI_IN_USE.length;i<j;i+=2){
String key = JIE_QI[i]; String key = JIE_QI_IN_USE[i];
Solar d = jieQi.get(key); Solar d = jieQi.get(key);
if (d.getYear() == solar.getYear() && d.getMonth() == solar.getMonth() && d.getDay() == solar.getDay()) { if (d.getYear() == solar.getYear() && d.getMonth() == solar.getMonth() && d.getDay() == solar.getDay()) {
qi = key; qi = key;

View File

@@ -261,4 +261,25 @@ public class FotoUtil {
put("12-30", Collections.nCopies(1, new FotoFestival("诸神下降,察访善恶", "犯者男女俱亡"))); put("12-30", Collections.nCopies(1, new FotoFestival("诸神下降,察访善恶", "犯者男女俱亡")));
} }
}; };
/**
* 27星宿佛教从印度传入中国印度把28星宿改为27星宿把牛宿(牛金牛)纳入了女宿(女土蝠)。
*/
public static final String[] XIU_27 = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
/**
* 每月初一的27星宿偏移
*/
private static final int[] XIU_OFFSET = {11, 13, 15, 17, 19, 21, 24, 0, 2, 4, 7, 9};
/**
* 获取27星宿
*
* @param month 佛历月
* @param day 佛历日
* @return 星宿
*/
public static String getXiu(int month, int day) {
return XIU_27[(XIU_OFFSET[Math.abs(month)-1] + day - 1) % XIU_27.length];
}
} }

File diff suppressed because one or more lines are too long

View File

@@ -18,4 +18,14 @@ public class FotoTest {
Assert.assertEquals("二五六五年十月十四 (三元降) (四天王巡行)", foto.toFullString()); Assert.assertEquals("二五六五年十月十四 (三元降) (四天王巡行)", foto.toFullString());
} }
@Test
public void test1() {
Foto foto = Foto.fromLunar(Lunar.fromYmd(2020, 4, 13));
Assert.assertEquals("", foto.getXiu());
Assert.assertEquals("", foto.getZheng());
Assert.assertEquals("", foto.getAnimal());
Assert.assertEquals("", foto.getGong());
Assert.assertEquals("青龙", foto.getShou());
}
} }

View File

@@ -186,4 +186,12 @@ public class JieQiTest {
Assert.assertEquals("2050-12-07 06:41:00", lunar.getJieQiTable().get("大雪").toYmdHms()); Assert.assertEquals("2050-12-07 06:41:00", lunar.getJieQiTable().get("大雪").toYmdHms());
} }
@Test
public void test9() {
Solar solar = Solar.fromYmd(2021, 12, 21);
Assert.assertEquals("冬至", solar.getLunar().getJieQi());
Assert.assertEquals("", solar.getLunar().getJie());
Assert.assertEquals("冬至", solar.getLunar().getQi());
}
} }

View File

@@ -387,4 +387,11 @@ public class LunarTest {
Assert.assertEquals("厕灶厨 外西南", lunar.getDayPositionTai()); Assert.assertEquals("厕灶厨 外西南", lunar.getDayPositionTai());
} }
@Test
public void test53() {
Solar solar = Solar.fromYmd(2021, 11, 27);
Lunar lunar = solar.getLunar();
Assert.assertEquals("[嫁娶, 祭祀, 祈福, 求嗣, 开光, 出行, 解除, 出火, 拆卸, 进人口, 入宅, 移徙, 安床, 栽种, 动土, 修造, 纳畜, 入殓, 安葬, 立碑, 除服, 成服]", lunar.getDayYi().toString());
}
} }