v1.2.29 修复1582年总天数问题;修复八字转阳历遗漏问题。
This commit is contained in:
@@ -6,6 +6,7 @@ import com.nlf.calendar.Solar;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -250,20 +251,71 @@ public class BaZiTest {
|
||||
|
||||
@Test
|
||||
public void testBaZi2Solar() {
|
||||
Solar solar = Solar.fromYmdHms(2027,1,27,12,0,0);
|
||||
System.out.println(solar.getLunar().getEightChar().toString());
|
||||
List<Solar> l = Solar.fromBaZi("丙午","辛丑","丙午","甲午");
|
||||
for(Solar s:l){
|
||||
System.out.println(s.toFullString());
|
||||
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("1976-09-21 12:00:00");
|
||||
expected.add("1916-10-06 12:00:00");
|
||||
Assert.assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBaZi2Solar1() {
|
||||
List<Solar> l = Solar.fromBaZi("壬寅","庚戌","己未","乙亥");
|
||||
for(Solar s:l){
|
||||
System.out.println(s.toFullString());
|
||||
List<String> actual = new ArrayList<String>();
|
||||
for (Solar solar : l) {
|
||||
actual.add(solar.toYmdHms());
|
||||
}
|
||||
|
||||
List<String> expected = new ArrayList<String>();
|
||||
expected.add("2022-11-02 22:00:00");
|
||||
Assert.assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBaZi2Solar2() {
|
||||
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("1999-07-21 16:00:00");
|
||||
expected.add("1939-08-05 16:00:00");
|
||||
Assert.assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBaZi2Solar3() {
|
||||
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("1960-12-17 12:00:00");
|
||||
expected.add("1901-01-01 12:00:00");
|
||||
Assert.assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBaZi2Solar4() {
|
||||
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("2020-07-21 22:00:00");
|
||||
expected.add("1960-08-05 22:00:00");
|
||||
Assert.assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -447,4 +447,16 @@ public class LunarTest {
|
||||
Assert.assertEquals("秋社", lunar.getOtherFestivals().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test62() {
|
||||
Lunar lunar = Lunar.fromYmd(1582, 9, 18);
|
||||
Assert.assertEquals("1582-10-04", lunar.getSolar().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test63() {
|
||||
Lunar lunar = Lunar.fromYmd(1582, 9, 19);
|
||||
Assert.assertEquals("1582-10-15", lunar.getSolar().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,4 +79,70 @@ public class SolarTest {
|
||||
Assert.assertEquals("全国中小学生安全教育日",solar.getFestivals().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test12(){
|
||||
Solar solar = new Solar(2022, 1, 1);
|
||||
Assert.assertEquals("2022-01-02", solar.next(1).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test13(){
|
||||
Solar solar = new Solar(2022, 1, 31);
|
||||
Assert.assertEquals("2022-02-01", solar.next(1).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test14(){
|
||||
Solar solar = new Solar(2022, 1, 1);
|
||||
Assert.assertEquals("2023-01-01", solar.next(365).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test15(){
|
||||
Solar solar = new Solar(2023, 1, 1);
|
||||
Assert.assertEquals("2022-01-01", solar.next(-365).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test16(){
|
||||
Solar solar = new Solar(1582, 10, 4);
|
||||
Assert.assertEquals("1582-10-15", solar.next(1).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test17(){
|
||||
Solar solar = new Solar(1582, 10, 4);
|
||||
Assert.assertEquals("1582-11-01", solar.next(18).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test18(){
|
||||
Solar solar = new Solar(1582, 11, 1);
|
||||
Assert.assertEquals("1582-10-04", solar.next(-18).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test19(){
|
||||
Solar solar = new Solar(1582, 11, 1);
|
||||
Assert.assertEquals("1582-10-15", solar.next(-17).toYmd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test20(){
|
||||
int days = SolarUtil.getDaysBetween(1582, 10, 4, 1582, 10, 15);
|
||||
Assert.assertEquals(1, days);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test21(){
|
||||
int days = SolarUtil.getDaysBetween(1582, 10, 4, 1582, 11, 1);
|
||||
Assert.assertEquals(18, days);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test22(){
|
||||
int days = SolarUtil.getDaysBetween(1582, 1, 1, 1583, 1, 1);
|
||||
Assert.assertEquals(355, days);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package test;
|
||||
|
||||
import com.nlf.calendar.Solar;
|
||||
import com.nlf.calendar.SolarWeek;
|
||||
import com.nlf.calendar.util.SolarUtil;
|
||||
import org.junit.Assert;
|
||||
@@ -41,4 +42,16 @@ public class WeekTest {
|
||||
//当周第一天(本月)
|
||||
Assert.assertEquals("2019-05-01",week.getFirstDayInMonth().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1(){
|
||||
Solar solar = Solar.fromYmd(1582, 10, 1);
|
||||
Assert.assertEquals(1, solar.getWeek());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2(){
|
||||
Solar solar = Solar.fromYmd(1582, 10, 15);
|
||||
Assert.assertEquals(5, solar.getWeek());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user