Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10beaefd34 | ||
|
|
f1be26456d | ||
|
|
cc9444aa03 | ||
|
|
df6119c19e | ||
|
|
c7cd454f2d | ||
|
|
5680eb8d44 |
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.1.7</version>
|
||||
<version>1.1.9</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -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.7</version>
|
||||
<version>1.1.9</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.1.7</version>
|
||||
<version>1.1.9</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>
|
||||
|
||||
@@ -323,7 +323,7 @@ public class Lunar{
|
||||
t -= (53 * t * t + 334116 * Math.cos(4.67 + 628.307585 * t) + 2061 * Math.cos(2.678 + 628.3076 * t) * t) / v / 10000000;
|
||||
l = 48950621.66 + 6283319653.318 * t + 53 * t * t + 334166 * Math.cos(4.669257 + 628.307585 * t) + 3489 * Math.cos(4.6261 + 1256.61517 * t) + 2060.6 * Math.cos(2.67823 + 628.307585 * t) * t - 994 - 834 * Math.sin(2.1824 - 33.75705 * t);
|
||||
t -= (l / 10000000 - w) / 628.332 + (32 * (t + 1.8) * (t + 1.8) - 20) / 86400 / 36525;
|
||||
return t * 36525 + 8 / 24;
|
||||
return t * 36525 + 8D / 24;
|
||||
}
|
||||
|
||||
private double saLonT2(double w){
|
||||
@@ -336,10 +336,10 @@ public class Lunar{
|
||||
|
||||
private double qiHigh(double w){
|
||||
double t = saLonT2(w) * 36525;
|
||||
t = t - dtT(t) + 8 / 24;
|
||||
t = t - dtT(t) + 8D / 24;
|
||||
double v = ((t + 0.5) % 1) * 86400;
|
||||
if (v < 1200 || v > 86400 - 1200){
|
||||
t = saLonT(w) * 36525 - dtT(t) + 8 / 24;
|
||||
t = saLonT(w) * 36525 - dtT(t) + 8D / 24;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
@@ -381,7 +381,7 @@ public class Lunar{
|
||||
|
||||
private double qiAccurate(double w){
|
||||
double t = saLonT(w) * 36525;
|
||||
return t - dtT(t) + 8 * 1D / 24;
|
||||
return t - dtT(t) + 8D / 24;
|
||||
}
|
||||
|
||||
private double qiAccurate2(double jd) {
|
||||
|
||||
@@ -39,16 +39,17 @@ public class DaYun {
|
||||
this.yun = yun;
|
||||
this.lunar = yun.getLunar();
|
||||
this.index = index;
|
||||
int birthYear = lunar.getSolar().getYear();
|
||||
int year = yun.getStartSolar().getYear();
|
||||
if (index < 1) {
|
||||
this.startYear = lunar.getSolar().getYear();
|
||||
this.startYear = birthYear;
|
||||
this.startAge = 1;
|
||||
this.endYear = year - 1;
|
||||
this.endAge = yun.getStartYear();
|
||||
this.endAge = year - birthYear;
|
||||
} else {
|
||||
int add = (index - 1) * 10;
|
||||
this.startYear = year + add;
|
||||
this.startAge = yun.getStartYear() + add + 1;
|
||||
this.startAge = this.startYear - birthYear + 1;
|
||||
this.endYear = this.startYear + 9;
|
||||
this.endAge = this.startAge + 9;
|
||||
}
|
||||
|
||||
@@ -250,6 +250,54 @@ public class BaZiTestNew {
|
||||
Assert.assertEquals(ages[i], liuNian.getAge());
|
||||
Assert.assertEquals(years[i] + "年", ganZhi[i], liuNian.getGanZhi());
|
||||
}
|
||||
|
||||
solar = new Solar(1981, 8, 16, 9, 30, 0);
|
||||
lunar = solar.getLunar();
|
||||
bazi = lunar.getEightChar();
|
||||
yun = bazi.getYun(1);
|
||||
daYun = yun.getDaYun();
|
||||
|
||||
years = new int[]{1981, 1982, 1983};
|
||||
ages = new int[]{1, 2, 3};
|
||||
ganZhi = new String[]{"辛酉","壬戌","癸亥"};
|
||||
l = daYun[0].getLiuNian();
|
||||
for (int i = 0, j = l.length; i < j; i++) {
|
||||
LiuNian liuNian = l[i];
|
||||
Assert.assertEquals(years[i], liuNian.getYear());
|
||||
Assert.assertEquals(ages[i], liuNian.getAge());
|
||||
Assert.assertEquals(ganZhi[i], liuNian.getGanZhi());
|
||||
}
|
||||
|
||||
years = new int[]{1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993};
|
||||
ages = new int[]{4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
|
||||
ganZhi = new String[]{"甲子","乙丑","丙寅","丁卯","戊辰","己巳","庚午","辛未","壬申","癸酉"};
|
||||
l = daYun[1].getLiuNian();
|
||||
for (int i = 0, j = l.length; i < j; i++) {
|
||||
LiuNian liuNian = l[i];
|
||||
Assert.assertEquals(years[i], liuNian.getYear());
|
||||
Assert.assertEquals(ages[i], liuNian.getAge());
|
||||
Assert.assertEquals(ganZhi[i], liuNian.getGanZhi());
|
||||
}
|
||||
|
||||
solar = new Solar(1981, 8, 8, 1, 30, 0);
|
||||
lunar = solar.getLunar();
|
||||
bazi = lunar.getEightChar();
|
||||
yun = bazi.getYun(1);
|
||||
daYun = yun.getDaYun();
|
||||
|
||||
l = daYun[0].getLiuNian();
|
||||
Assert.assertEquals(0, l.length);
|
||||
|
||||
years = new int[]{1981,1982, 1983,1984, 1985, 1986, 1987, 1988, 1989, 1990};
|
||||
ages = new int[]{1,2,3,4,5,6,7,8,9,10};
|
||||
ganZhi = new String[]{"辛酉","壬戌","癸亥","甲子","乙丑","丙寅","丁卯","戊辰","己巳","庚午"};
|
||||
l = daYun[1].getLiuNian();
|
||||
for (int i = 0, j = l.length; i < j; i++) {
|
||||
LiuNian liuNian = l[i];
|
||||
Assert.assertEquals(years[i], liuNian.getYear());
|
||||
Assert.assertEquals(ages[i], liuNian.getAge());
|
||||
Assert.assertEquals(ganZhi[i], liuNian.getGanZhi());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user