Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51afe36b4b | ||
|
|
ee0b227f75 | ||
|
|
a16767e2c7 | ||
|
|
dc0c03ff09 |
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.6tail</groupId>
|
<groupId>cn.6tail</groupId>
|
||||||
<artifactId>lunar</artifactId>
|
<artifactId>lunar</artifactId>
|
||||||
<version>1.2.24</version>
|
<version>1.2.25</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.6tail</groupId>
|
<groupId>cn.6tail</groupId>
|
||||||
<artifactId>lunar</artifactId>
|
<artifactId>lunar</artifactId>
|
||||||
<version>1.2.24</version>
|
<version>1.2.25</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
12
pom.xml
12
pom.xml
@@ -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.24</version>
|
<version>1.2.26</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>
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
<sourceEncoding>UTF-8</sourceEncoding>
|
<sourceEncoding>UTF-8</sourceEncoding>
|
||||||
<source-version>1.5</source-version>
|
<source-version>1.5</source-version>
|
||||||
<target-version>1.5</target-version>
|
<target-version>1.5</target-version>
|
||||||
|
<creator>6tail</creator>
|
||||||
<maven-compiler-plugin-version>3.3</maven-compiler-plugin-version>
|
<maven-compiler-plugin-version>3.3</maven-compiler-plugin-version>
|
||||||
<maven-surefire-plugin-version>2.5</maven-surefire-plugin-version>
|
<maven-surefire-plugin-version>2.5</maven-surefire-plugin-version>
|
||||||
<maven-javadoc-plugin-version>2.9</maven-javadoc-plugin-version>
|
<maven-javadoc-plugin-version>2.9</maven-javadoc-plugin-version>
|
||||||
@@ -60,7 +61,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.13.1</version>
|
<version>4.13.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@@ -104,6 +105,7 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<additionalparam>-Xdoclint:none</additionalparam>
|
<additionalparam>-Xdoclint:none</additionalparam>
|
||||||
|
<source>${source-version}</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@@ -154,6 +156,12 @@
|
|||||||
<descriptors>
|
<descriptors>
|
||||||
<descriptor>${basedir}/src/assembly/assembly.xml</descriptor>
|
<descriptor>${basedir}/src/assembly/assembly.xml</descriptor>
|
||||||
</descriptors>
|
</descriptors>
|
||||||
|
<archive>
|
||||||
|
<manifestEntries>
|
||||||
|
<Created-By>${creator}</Created-By>
|
||||||
|
<Built-By>${creator}</Built-By>
|
||||||
|
</manifestEntries>
|
||||||
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|||||||
@@ -183,6 +183,9 @@ public class Lunar {
|
|||||||
this.second = second;
|
this.second = second;
|
||||||
Solar noon = Solar.fromJulianDay(m.getFirstJulianDay() + lunarDay - 1);
|
Solar noon = Solar.fromJulianDay(m.getFirstJulianDay() + lunarDay - 1);
|
||||||
this.solar = Solar.fromYmdHms(noon.getYear(), noon.getMonth(), noon.getDay(), hour, minute, second);
|
this.solar = Solar.fromYmdHms(noon.getYear(), noon.getMonth(), noon.getDay(), hour, minute, second);
|
||||||
|
if (noon.getYear() != lunarYear) {
|
||||||
|
y = LunarYear.fromYear(noon.getYear());
|
||||||
|
}
|
||||||
compute(y);
|
compute(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2987,7 +2990,11 @@ public class Lunar {
|
|||||||
}
|
}
|
||||||
Solar startSolar = jieQi.getSolar();
|
Solar startSolar = jieQi.getSolar();
|
||||||
int days = ExactDate.getDaysBetween(startSolar.getYear(), startSolar.getMonth(), startSolar.getDay(), solar.getYear(), solar.getMonth(), solar.getDay());
|
int days = ExactDate.getDaysBetween(startSolar.getYear(), startSolar.getMonth(), startSolar.getDay(), solar.getYear(), solar.getMonth(), solar.getDay());
|
||||||
return LunarUtil.WU_HOU[(offset * 3 + days / 5) % LunarUtil.WU_HOU.length];
|
int index = days / 5;
|
||||||
|
if (index > 2) {
|
||||||
|
index = 2;
|
||||||
|
}
|
||||||
|
return LunarUtil.WU_HOU[(offset * 3 + index) % LunarUtil.WU_HOU.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -276,4 +276,23 @@ public class BaZiTest {
|
|||||||
Assert.assertEquals("1990-04-15", lunar.getEightChar().getYun(1).getStartSolar().toYmd());
|
Assert.assertEquals("1990-04-15", lunar.getEightChar().getYun(1).getStartSolar().toYmd());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test10(){
|
||||||
|
Lunar lunar = Solar.fromYmdHms(1988, 2, 15, 23, 30, 0).getLunar();
|
||||||
|
EightChar eightChar = lunar.getEightChar();
|
||||||
|
Assert.assertEquals("年柱", "戊辰", eightChar.getYear());
|
||||||
|
Assert.assertEquals("月柱", "甲寅", eightChar.getMonth());
|
||||||
|
Assert.assertEquals("日柱", "庚子", eightChar.getDay());
|
||||||
|
Assert.assertEquals("时柱", "戊子", eightChar.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test11(){
|
||||||
|
Lunar lunar = Lunar.fromYmdHms(1987, 12, 28, 23, 30, 0);
|
||||||
|
EightChar eightChar = lunar.getEightChar();
|
||||||
|
Assert.assertEquals("年柱", "戊辰", eightChar.getYear());
|
||||||
|
Assert.assertEquals("月柱", "甲寅", eightChar.getMonth());
|
||||||
|
Assert.assertEquals("日柱", "庚子", eightChar.getDay());
|
||||||
|
Assert.assertEquals("时柱", "戊子", eightChar.getTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,8 +94,11 @@ public class HolidayTest {
|
|||||||
Assert.assertEquals("2020-01-01 春节 2020-01-01", HolidayUtil.getHoliday("2020-01-01") + "");
|
Assert.assertEquals("2020-01-01 春节 2020-01-01", HolidayUtil.getHoliday("2020-01-01") + "");
|
||||||
Assert.assertEquals("2099-01-01 元旦节 2099-01-01", HolidayUtil.getHoliday("2099-01-01") + "");
|
Assert.assertEquals("2099-01-01 元旦节 2099-01-01", HolidayUtil.getHoliday("2099-01-01") + "");
|
||||||
|
|
||||||
// 更改节假日名称
|
// 自定义节假日名称
|
||||||
String[] names = HolidayUtil.NAMES;
|
String[] names = new String[HolidayUtil.NAMES.length];
|
||||||
|
for (int i = 0, j = HolidayUtil.NAMES.length; i < j; i++) {
|
||||||
|
names[i] = HolidayUtil.NAMES[i];
|
||||||
|
}
|
||||||
names[0] = "元旦";
|
names[0] = "元旦";
|
||||||
names[1] = "大年初一";
|
names[1] = "大年初一";
|
||||||
|
|
||||||
@@ -128,9 +131,11 @@ public class HolidayTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemove() {
|
public void testRemove() {
|
||||||
|
// 设置默认的节假日名称
|
||||||
|
HolidayUtil.fix(HolidayUtil.NAMES, null);
|
||||||
Holiday holiday = HolidayUtil.getHoliday(2010,1,1);
|
Holiday holiday = HolidayUtil.getHoliday(2010,1,1);
|
||||||
Assert.assertNotNull(holiday);
|
Assert.assertNotNull(holiday);
|
||||||
Assert.assertEquals("元旦",holiday.getName());
|
Assert.assertEquals("元旦节",holiday.getName());
|
||||||
|
|
||||||
HolidayUtil.fix("20100101~000000000000000000000000000");
|
HolidayUtil.fix("20100101~000000000000000000000000000");
|
||||||
holiday = HolidayUtil.getHoliday(2010,1,1);
|
holiday = HolidayUtil.getHoliday(2010,1,1);
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ public class JieQiTest {
|
|||||||
@Test
|
@Test
|
||||||
public void test8() {
|
public void test8() {
|
||||||
Lunar lunar = Lunar.fromYmd(2050, 12, 1);
|
Lunar lunar = Lunar.fromYmd(2050, 12, 1);
|
||||||
Assert.assertEquals("2050-12-07 06:41:00", lunar.getJieQiTable().get("大雪").toYmdHms());
|
Assert.assertEquals("2050-12-07 06:41:00", lunar.getJieQiTable().get("DA_XUE").toYmdHms());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -103,4 +103,18 @@ public class WuHouTest {
|
|||||||
Assert.assertEquals(solar.toString(),"小寒 初候",lunar.getHou());
|
Assert.assertEquals(solar.toString(),"小寒 初候",lunar.getHou());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test15(){
|
||||||
|
Solar solar = new Solar(2022,8,22);
|
||||||
|
Lunar lunar = solar.getLunar();
|
||||||
|
Assert.assertEquals(solar.toString(),"寒蝉鸣",lunar.getWuHou());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test16(){
|
||||||
|
Solar solar = new Solar(2022,8,23);
|
||||||
|
Lunar lunar = solar.getLunar();
|
||||||
|
Assert.assertEquals(solar.toString(),"鹰乃祭鸟",lunar.getWuHou());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user