getDayNineStar method
Implementation
NineStar getDayNineStar() {
String solarYmd = _solar!.toYmd();
Solar dongZhi = _jieQi['冬至']!;
Solar dongZhi2 = _jieQi['DONG_ZHI']!;
Solar xiaZhi = _jieQi['夏至']!;
int dongZhiIndex = LunarUtil.getJiaZiIndex(dongZhi.getLunar().getDayInGanZhi());
int dongZhiIndex2 = LunarUtil.getJiaZiIndex(dongZhi2.getLunar().getDayInGanZhi());
int xiaZhiIndex = LunarUtil.getJiaZiIndex(xiaZhi.getLunar().getDayInGanZhi());
Solar solarShunBai;
Solar solarShunBai2;
Solar solarNiZi;
if (dongZhiIndex > 29) {
solarShunBai = dongZhi.next(60 - dongZhiIndex);
} else {
solarShunBai = dongZhi.next(-dongZhiIndex);
}
String solarShunBaiYmd = solarShunBai.toYmd();
if (dongZhiIndex2 > 29) {
solarShunBai2 = dongZhi2.next(60 - dongZhiIndex2);
} else {
solarShunBai2 = dongZhi2.next(-dongZhiIndex2);
}
String solarShunBaiYmd2 = solarShunBai2.toYmd();
if (xiaZhiIndex > 29) {
solarNiZi = xiaZhi.next(60 - xiaZhiIndex);
} else {
solarNiZi = xiaZhi.next(-xiaZhiIndex);
}
String solarNiZiYmd = solarNiZi.toYmd();
int offset = 0;
if (solarYmd.compareTo(solarShunBaiYmd) >= 0 && solarYmd.compareTo(solarNiZiYmd) < 0) {
offset = _solar!.subtract(solarShunBai) % 9;
} else if (solarYmd.compareTo(solarNiZiYmd) >= 0 && solarYmd.compareTo(solarShunBaiYmd2) < 0) {
offset = 8 - (_solar!.subtract(solarNiZi) % 9);
} else if (solarYmd.compareTo(solarShunBaiYmd2) >= 0) {
offset = _solar!.subtract(solarShunBai2) % 9;
} else if (solarYmd.compareTo(solarShunBaiYmd) < 0) {
offset = (8 + solarShunBai.subtract(_solar!)) % 9;
}
return NineStar.fromIndex(offset);
}