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

Method computeDay

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

计算干支纪日

()

Source from the content-addressed store, hash-verified

347 * 计算干支纪日
348 */
349 private void computeDay() {
350 Solar noon = Solar.fromYmdHms(solar.getYear(), solar.getMonth(), solar.getDay(), 12, 0, 0);
351 int offset = (int) noon.getJulianDay() - 11;
352 dayGanIndex = offset % 10;
353 dayZhiIndex = offset % 12;
354
355 int dayGanExact = dayGanIndex;
356 int dayZhiExact = dayZhiIndex;
357
358 // 八字流派2,晚子时(夜子/子夜)日柱算当天
359 dayGanIndexExact2 = dayGanExact;
360 dayZhiIndexExact2 = dayZhiExact;
361
362 // 八字流派1,晚子时(夜子/子夜)日柱算明天
363 String hm = (hour < 10 ? "0" : "") + hour + ":" + (minute < 10 ? "0" : "") + minute;
364 if (hm.compareTo("23:00") >= 0 && hm.compareTo("23:59") <= 0) {
365 dayGanExact++;
366 if (dayGanExact >= 10) {
367 dayGanExact -= 10;
368 }
369 dayZhiExact++;
370 if (dayZhiExact >= 12) {
371 dayZhiExact -= 12;
372 }
373 }
374
375 dayGanIndexExact = dayGanExact;
376 dayZhiIndexExact = dayZhiExact;
377 }
378
379 /**
380 * 计算干支纪时

Callers 1

computeMethod · 0.95

Calls 5

fromYmdHmsMethod · 0.95
getJulianDayMethod · 0.95
getYearMethod · 0.45
getMonthMethod · 0.45
getDayMethod · 0.45

Tested by

no test coverage detected