MCPcopy Create free account
hub / github.com/6tail/lunar-java / getDayNineStar

Method getDayNineStar

src/main/java/com/nlf/calendar/Lunar.java:2147–2187  ·  view source on GitHub ↗

获取值日九星(日家紫白星歌诀:日家白法不难求,二十四气六宫周;冬至雨水及谷雨,阳顺一七四中游;夏至处暑霜降后,九三六星逆行求。) @return 九星

()

Source from the content-addressed store, hash-verified

2145 * @return 九星
2146 */
2147 public NineStar getDayNineStar() {
2148 String solarYmd = solar.toYmd();
2149 Solar dongZhi = jieQi.get("冬至");
2150 Solar dongZhi2 = jieQi.get("DONG_ZHI");
2151 Solar xiaZhi = jieQi.get("夏至");
2152 int dongZhiIndex = LunarUtil.getJiaZiIndex(dongZhi.getLunar().getDayInGanZhi());
2153 int dongZhiIndex2 = LunarUtil.getJiaZiIndex(dongZhi2.getLunar().getDayInGanZhi());
2154 int xiaZhiIndex = LunarUtil.getJiaZiIndex(xiaZhi.getLunar().getDayInGanZhi());
2155 Solar solarShunBai;
2156 Solar solarShunBai2;
2157 Solar solarNiZi;
2158 if (dongZhiIndex > 29) {
2159 solarShunBai = dongZhi.next(60 - dongZhiIndex);
2160 } else {
2161 solarShunBai = dongZhi.next(-dongZhiIndex);
2162 }
2163 String solarShunBaiYmd = solarShunBai.toYmd();
2164 if (dongZhiIndex2 > 29) {
2165 solarShunBai2 = dongZhi2.next(60 - dongZhiIndex2);
2166 } else {
2167 solarShunBai2 = dongZhi2.next(-dongZhiIndex2);
2168 }
2169 String solarShunBaiYmd2 = solarShunBai2.toYmd();
2170 if (xiaZhiIndex > 29) {
2171 solarNiZi = xiaZhi.next(60 - xiaZhiIndex);
2172 } else {
2173 solarNiZi = xiaZhi.next(-xiaZhiIndex);
2174 }
2175 String solarNiZiYmd = solarNiZi.toYmd();
2176 int offset = 0;
2177 if (solarYmd.compareTo(solarShunBaiYmd) >= 0 && solarYmd.compareTo(solarNiZiYmd) < 0) {
2178 offset = solar.subtract(solarShunBai) % 9;
2179 } else if (solarYmd.compareTo(solarNiZiYmd) >= 0 && solarYmd.compareTo(solarShunBaiYmd2) < 0) {
2180 offset = 8 - (solar.subtract(solarNiZi) % 9);
2181 } else if (solarYmd.compareTo(solarShunBaiYmd2) >= 0) {
2182 offset = solar.subtract(solarShunBai2) % 9;
2183 } else if (solarYmd.compareTo(solarShunBaiYmd) < 0) {
2184 offset = (8 + solarShunBai.subtract(solar)) % 9;
2185 }
2186 return NineStar.fromIndex(offset);
2187 }
2188
2189 /**
2190 * 获取值时九星(时家紫白星歌诀:三元时白最为佳,冬至阳生顺莫差,孟日七宫仲一白,季日四绿发萌芽,每把时辰起甲子,本时星耀照光华,时星移入中宫去,顺飞八方逐细查。夏至阴生逆回首,孟归三碧季加六,仲在九宫时起甲,依然掌中逆轮跨。)

Callers 3

test1Method · 0.95
test2Method · 0.95
test3Method · 0.95

Calls 7

toYmdMethod · 0.95
getJiaZiIndexMethod · 0.95
getLunarMethod · 0.95
nextMethod · 0.95
subtractMethod · 0.95
fromIndexMethod · 0.95
getDayInGanZhiMethod · 0.80

Tested by 3

test1Method · 0.76
test2Method · 0.76
test3Method · 0.76