Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
392ac5b00a | ||
|
|
9ec735cd4b | ||
|
|
e06c7a0532 | ||
|
|
bd18254834 | ||
|
|
28dbf8f45f | ||
|
|
0d1f64664e |
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.1.5</version>
|
||||
<version>1.1.7</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -44,7 +44,7 @@ lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)
|
||||
|
||||
### 下载jar
|
||||
|
||||
如果使用jar,建议下载最新的SNAPSHOT版本,bug将得到及时的修复。
|
||||
如果使用jar,建议下载最新的版本,bug将得到及时的修复。
|
||||
|
||||
[Download](https://github.com/6tail/lunar-java/releases)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.1.5</version>
|
||||
<version>1.1.7</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -40,7 +40,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
|
||||
|
||||
### Download
|
||||
|
||||
If you will use jars in your projects, I suggest you to download latest snapshot versions with less bugs.
|
||||
If you will use jars in your projects, I suggest you to download latest versions with less bugs.
|
||||
|
||||
[Download](https://github.com/6tail/lunar-java/releases)
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.1.5</version>
|
||||
<version>1.1.7</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>
|
||||
|
||||
@@ -20,6 +20,14 @@ public class Lunar{
|
||||
public static final String JIE_QI_FIRST = "冬至";
|
||||
/** 农历年末节气名(节令:大雪) */
|
||||
public static final String JIE_QI_LAST = "大雪";
|
||||
/** 节气表尾部追加阳历下年初的第一个节气名(节令:小寒),以示区分 */
|
||||
public static final String JIE_APPEND_SOLAR_FIRST = "XIAO_HAN";
|
||||
/** 节气表尾部追加阳历下年初的第二个节气名(气令:大寒),以示区分 */
|
||||
public static final String QI_APPEND_SOLAR_SECOND = "DA_HAN";
|
||||
/** 阳历下年初的第一个节气名(节令:小寒) */
|
||||
public static final String JIE_SOLAR_FIRST = "小寒";
|
||||
/** 阳历下年初的第二个节气名(气令:大寒) */
|
||||
public static final String QI_SOLAR_SECOND = "大寒";
|
||||
/** 1弧度对应的角秒 */
|
||||
private static final double SECOND_PER_RAD = 180 * 3600 / Math.PI;
|
||||
/** 节气表,国标以冬至为首个节气 */
|
||||
@@ -408,6 +416,16 @@ public class Lunar{
|
||||
//追加下一农历年初的冬至
|
||||
q = calcJieQi(w + 15.2184 * size);
|
||||
jieQi.put(JIE_QI_APPEND, Solar.fromJulianDay(qiAccurate2(q) + Solar.J2000));
|
||||
|
||||
//追加下一阳历年初的小寒
|
||||
size++;
|
||||
q = calcJieQi(w + 15.2184 * size);
|
||||
jieQi.put(JIE_APPEND_SOLAR_FIRST, Solar.fromJulianDay(qiAccurate2(q) + Solar.J2000));
|
||||
|
||||
//追加下一阳历年初的大寒
|
||||
size++;
|
||||
q = calcJieQi(w + 15.2184 * size);
|
||||
jieQi.put(QI_APPEND_SOLAR_SECOND, Solar.fromJulianDay(qiAccurate2(q) + Solar.J2000));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -979,6 +997,11 @@ public class Lunar{
|
||||
if(d.getYear()==solar.getYear()&&d.getMonth()==solar.getMonth()&&d.getDay()==solar.getDay()){
|
||||
return JIE_QI_LAST;
|
||||
}
|
||||
// 追加的节令:小寒
|
||||
d = jieQi.get(JIE_APPEND_SOLAR_FIRST);
|
||||
if(d.getYear()==solar.getYear()&&d.getMonth()==solar.getMonth()&&d.getDay()==solar.getDay()){
|
||||
return JIE_SOLAR_FIRST;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -999,6 +1022,11 @@ public class Lunar{
|
||||
if(d.getYear()==solar.getYear()&&d.getMonth()==solar.getMonth()&&d.getDay()==solar.getDay()){
|
||||
return JIE_QI_FIRST;
|
||||
}
|
||||
// 追加的气令:大寒
|
||||
d = jieQi.get(QI_APPEND_SOLAR_SECOND);
|
||||
if(d.getYear()==solar.getYear()&&d.getMonth()==solar.getMonth()&&d.getDay()==solar.getDay()){
|
||||
return QI_SOLAR_SECOND;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -1875,8 +1903,11 @@ public class Lunar{
|
||||
}
|
||||
// 寅月起,所以需要-2
|
||||
int monthIndex = monthZhiIndex-2;
|
||||
if(monthIndex<0){
|
||||
monthIndex += 12;
|
||||
}
|
||||
int index = start-monthIndex-1;
|
||||
if(index<0){
|
||||
while(index<0){
|
||||
index += 9;
|
||||
}
|
||||
return new NineStar(index);
|
||||
@@ -2030,6 +2061,12 @@ public class Lunar{
|
||||
if(JIE_QI_PREPEND.equals(jq)){
|
||||
jq = JIE_QI_LAST;
|
||||
}
|
||||
if(JIE_APPEND_SOLAR_FIRST.equals(jq)){
|
||||
jq = JIE_SOLAR_FIRST;
|
||||
}
|
||||
if(QI_APPEND_SOLAR_SECOND.equals(jq)){
|
||||
jq = QI_SOLAR_SECOND;
|
||||
}
|
||||
if(filter){
|
||||
if(!filters.contains(jq)){
|
||||
continue;
|
||||
@@ -2078,6 +2115,10 @@ public class Lunar{
|
||||
name = JIE_QI_FIRST;
|
||||
}else if(JIE_QI_PREPEND.equals(name)){
|
||||
name = JIE_QI_LAST;
|
||||
}else if(JIE_APPEND_SOLAR_FIRST.equals(name)){
|
||||
name = JIE_SOLAR_FIRST;
|
||||
}else if(QI_APPEND_SOLAR_SECOND.equals(name)){
|
||||
name = QI_SOLAR_SECOND;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -154,5 +154,23 @@ public class JieQiTest {
|
||||
Assert.assertEquals("小寒", lunar.getNextJie().getName());
|
||||
Assert.assertEquals("大寒", lunar.getNextQi().getName());
|
||||
Assert.assertEquals("小寒", lunar.getNextJieQi().getName());
|
||||
|
||||
|
||||
solar = Solar.fromYmd(2012,12,25);
|
||||
lunar = solar.getLunar();
|
||||
Assert.assertEquals("", lunar.getJie());
|
||||
Assert.assertEquals("", lunar.getQi());
|
||||
Assert.assertEquals("", lunar.getJieQi());
|
||||
Assert.assertNull(lunar.getCurrentJie());
|
||||
Assert.assertNull(lunar.getCurrentQi());
|
||||
Assert.assertNull(lunar.getCurrentJieQi());
|
||||
|
||||
Assert.assertEquals("小寒", lunar.getNextJie().getName());
|
||||
Assert.assertEquals("大寒", lunar.getNextQi().getName());
|
||||
Assert.assertEquals("小寒", lunar.getNextJieQi().getName());
|
||||
|
||||
Assert.assertEquals("大雪", lunar.getPrevJie().getName());
|
||||
Assert.assertEquals("冬至", lunar.getPrevQi().getName());
|
||||
Assert.assertEquals("冬至", lunar.getPrevJieQi().getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user