v1.3.10 修复八字转阳历为空的问题;修复一处法定假日数据错误;十神优化。
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
package sample;
|
||||
|
||||
import com.nlf.calendar.Holiday;
|
||||
import com.nlf.calendar.Solar;
|
||||
import com.nlf.calendar.util.HolidayUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HolidayTest {
|
||||
|
||||
@Test
|
||||
@@ -20,4 +24,31 @@ public class HolidayTest {
|
||||
System.out.println(HolidayUtil.getHolidaysByTarget("20200501"));
|
||||
System.out.println(HolidayUtil.getHolidaysByTarget(2011,1,1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1(){
|
||||
StringBuilder s = new StringBuilder();
|
||||
for(int i = 2001; i <= 2024; i++) {
|
||||
List<Holiday> l = HolidayUtil.getHolidays(i);
|
||||
for (Holiday d : l) {
|
||||
int index = -1;
|
||||
for (int x = 0;x <HolidayUtil.NAMES.length;x++) {
|
||||
if (HolidayUtil.NAMES[x].equals(d.getName())) {
|
||||
index = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == -1) {
|
||||
throw new IllegalArgumentException(d.getName());
|
||||
}
|
||||
String day = d.getDay();
|
||||
String target = d.getTarget();
|
||||
Solar solar = Solar.fromYmd(Integer.parseInt(day.substring(0,4)), Integer.parseInt(day.substring(5,7)), Integer.parseInt(day.substring(8)));
|
||||
Solar targetSolar = Solar.fromYmd(Integer.parseInt(target.substring(0,4)), Integer.parseInt(target.substring(5,7)), Integer.parseInt(target.substring(8)));
|
||||
int diff = targetSolar.subtract(solar);
|
||||
s.append(String.format("%s%d%d%s%02d", d.getDay().replace("-",""), d.isWork() ? 0 : 1, index, diff < 0 ? "-" : "+", Math.abs(diff)));
|
||||
}
|
||||
}
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,4 +406,35 @@ public class BaZiTest {
|
||||
expected.add("1959-12-17 16:00:00");
|
||||
Assert.assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test17() {
|
||||
Solar solar = new Solar(1986, 5, 29, 13, 37, 0);
|
||||
Lunar lunar = solar.getLunar();
|
||||
EightChar eightChar = lunar.getEightChar();
|
||||
Assert.assertEquals("辛丑", eightChar.getShenGong());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test18() {
|
||||
Solar solar = new Solar(2023, 10, 8, 18, 37, 0);
|
||||
Lunar lunar = solar.getLunar();
|
||||
EightChar eightChar = lunar.getEightChar();
|
||||
Assert.assertEquals("己未", eightChar.getShenGong());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test19() {
|
||||
List<Solar> l = Solar.fromBaZi("丁丑","癸卯","癸丑","辛酉");
|
||||
List<String> actual = new ArrayList<String>();
|
||||
for (Solar solar : l) {
|
||||
actual.add(solar.toYmdHms());
|
||||
}
|
||||
|
||||
List<String> expected = new ArrayList<String>();
|
||||
expected.add("1997-03-12 18:00:00");
|
||||
expected.add("1937-03-27 18:00:00");
|
||||
Assert.assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user