next method
获取往后推几天的阳历日期,如果要往前推,则天数用负数 @param days 天数 @param onlyWorkday 是否仅限工作日 @return 阳历日期
Implementation
Solar next(int days, [bool onlyWorkday = false]) {
if(!onlyWorkday) {
return nextDay(days);
}
Solar solar = Solar.fromYmdHms(_year, _month, _day, _hour, _minute, _second);
if (days != 0) {
int rest = days.abs();
int add = days < 0 ? -1 : 1;
while (rest > 0) {
solar = solar.nextDay(add);
bool work = true;
Holiday? holiday = HolidayUtil.getHolidayByYmd(solar.getYear(), solar.getMonth(), solar.getDay());
if (null == holiday) {
int week = solar.getWeek();
if (0 == week || 6 == week) {
work = false;
}
} else {
work = holiday.isWork();
}
if (work) {
rest -= 1;
}
}
}
return solar;
}