起运计算
(int sect)
| 74 | * 起运计算 |
| 75 | */ |
| 76 | private void computeStart(int sect) { |
| 77 | // 上节 |
| 78 | JieQi prev = lunar.getPrevJie(); |
| 79 | // 下节 |
| 80 | JieQi next = lunar.getNextJie(); |
| 81 | // 出生日期 |
| 82 | Solar current = lunar.getSolar(); |
| 83 | // 阳男阴女顺推,阴男阳女逆推 |
| 84 | Solar start = forward ? current : prev.getSolar(); |
| 85 | Solar end = forward ? next.getSolar() : current; |
| 86 | |
| 87 | int year; |
| 88 | int month; |
| 89 | int day; |
| 90 | int hour = 0; |
| 91 | |
| 92 | if (2 == sect) { |
| 93 | long minutes = end.subtractMinute(start); |
| 94 | long y = minutes / 4320; |
| 95 | minutes -= y * 4320; |
| 96 | long m = minutes / 360; |
| 97 | minutes -= m * 360; |
| 98 | long d = minutes / 12; |
| 99 | minutes -= d * 12; |
| 100 | long h = minutes * 2; |
| 101 | year = (int)y; |
| 102 | month = (int)m; |
| 103 | day = (int)d; |
| 104 | hour = (int)h; |
| 105 | } else { |
| 106 | int endTimeZhiIndex = (end.getHour() == 23) ? 11 : LunarUtil.getTimeZhiIndex(end.toYmdHms().substring(11, 16)); |
| 107 | int startTimeZhiIndex = (start.getHour() == 23) ? 11 : LunarUtil.getTimeZhiIndex(start.toYmdHms().substring(11, 16)); |
| 108 | // 时辰差 |
| 109 | int hourDiff = endTimeZhiIndex - startTimeZhiIndex; |
| 110 | // 天数差 |
| 111 | int dayDiff = end.subtract(start); |
| 112 | if (hourDiff < 0) { |
| 113 | hourDiff += 12; |
| 114 | dayDiff--; |
| 115 | } |
| 116 | int monthDiff = hourDiff * 10 / 30; |
| 117 | month = dayDiff * 4 + monthDiff; |
| 118 | day = hourDiff * 10 - monthDiff * 30; |
| 119 | year = month / 12; |
| 120 | month = month - year * 12; |
| 121 | } |
| 122 | this.startYear = year; |
| 123 | this.startMonth = month; |
| 124 | this.startDay = day; |
| 125 | this.startHour = hour; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * 获取性别 |
no test coverage detected