getShuJiu method

ShuJiu? getShuJiu()

Implementation

ShuJiu? getShuJiu() {
  Solar current = Solar.fromYmd(_solar!.getYear(), _solar!.getMonth(), _solar!.getDay());
  Solar start = _jieQi['DONG_ZHI']!;
  start = Solar.fromYmd(start.getYear(), start.getMonth(), start.getDay());

  if (current.isBefore(start)) {
    start = _jieQi['冬至']!;
    start = Solar.fromYmd(start.getYear(), start.getMonth(), start.getDay());
  }

  Solar end = Solar.fromYmd(start.getYear(), start.getMonth(), start.getDay()).next(81);

  if (current.isBefore(start) || !current.isBefore(end)) {
    return null;
  }

  int days = current.subtract(start);
  return ShuJiu(LunarUtil.NUMBER[(days / 9).floor() + 1] + '九', days % 9 + 1);
}