v1.2.27 修复立春比春节早时年九星的错误;新增阳历月中获取周。
This commit is contained in:
@@ -2049,13 +2049,16 @@ public class Lunar {
|
||||
}
|
||||
|
||||
protected NineStar getYearNineStar(String yearInGanZhi) {
|
||||
int index = LunarUtil.getJiaZiIndex(yearInGanZhi) + 1;
|
||||
int yearOffset = 0;
|
||||
if (index != LunarUtil.getJiaZiIndex(this.getYearInGanZhi()) + 1) {
|
||||
yearOffset = -1;
|
||||
int indexExact = LunarUtil.getJiaZiIndex(yearInGanZhi) + 1;
|
||||
int index = LunarUtil.getJiaZiIndex(this.getYearInGanZhi()) + 1;
|
||||
int yearOffset = indexExact - index;
|
||||
if (yearOffset > 1) {
|
||||
yearOffset -= 60;
|
||||
} else if (yearOffset < -1) {
|
||||
yearOffset += 60;
|
||||
}
|
||||
int yuan = ((this.year + yearOffset + 2696) / 60) % 3;
|
||||
int offset = (62 + yuan * 3 - index) % 9;
|
||||
int offset = (62 + yuan * 3 - indexExact) % 9;
|
||||
if (0 == offset) {
|
||||
offset = 9;
|
||||
}
|
||||
|
||||
@@ -122,6 +122,26 @@ public class SolarMonth {
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本月的阳历周列表
|
||||
* @param start 星期几作为一周的开始,1234560分别代表星期一至星期天
|
||||
* @return 周列表
|
||||
*/
|
||||
public List<SolarWeek> getWeeks(int start) {
|
||||
List<SolarWeek> l = new ArrayList<SolarWeek>();
|
||||
SolarWeek week = SolarWeek.fromYmd(year, month, 1, start);
|
||||
Solar firstDay = week.getFirstDay();
|
||||
while (true) {
|
||||
l.add(week);
|
||||
week = week.next(1, false);
|
||||
firstDay = week.getFirstDay();
|
||||
if (firstDay.getYear() > year || firstDay.getMonth() > month) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取往后推几个月的阳历月,如果要往前推,则月数用负数
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user