diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a7287c..66091e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,3 +34,7 @@ 3. 新增:天干五合、地支六合、地支六害。 4. 修复:获取当年第几周报错的问题。 5. 优化:性能。 + +## [1.1.2] - 2024-08-19 +1. 优化:十神计算逻辑。 +2. 修复:获取起运时间报错的问题。 diff --git a/src/culture/Element.php b/src/culture/Element.php index c1e82b6..00b2951 100644 --- a/src/culture/Element.php +++ b/src/culture/Element.php @@ -39,7 +39,7 @@ function next(int $n): static } /** - * 我生者(生) + * 我生者 * * @return Element 五行 */ @@ -49,7 +49,7 @@ function getReinforce(): static } /** - * 我克者(克) + * 我克者 * * @return Element 五行 */ @@ -59,7 +59,7 @@ function getRestrain(): static } /** - * 生我者(泄) + * 生我者 * * @return Element 五行 */ @@ -69,7 +69,7 @@ function getReinforced(): static } /** - * 克我者(耗) + * 克我者 * * @return Element 五行 */ diff --git a/src/eightchar/provider/impl/China95ChildLimitProvider.php b/src/eightchar/provider/impl/China95ChildLimitProvider.php index d40b80a..cb146a6 100644 --- a/src/eightchar/provider/impl/China95ChildLimitProvider.php +++ b/src/eightchar/provider/impl/China95ChildLimitProvider.php @@ -30,9 +30,10 @@ function getInfo(SolarTime $birthTime, SolarTerm $term): ChildLimitInfo $d = $birthTime->getDay() + $day; $dc = $sm->getDayCount(); - if ($d > $dc) { + while ($d > $dc) { $d -= $dc; $sm = $sm->next(1); + $dc = $sm->getDayCount(); } return new ChildLimitInfo($birthTime, SolarTime::fromYmdHms($sm->getYear(), $sm->getMonth(), $d, $birthTime->getHour(), $birthTime->getMinute(), $birthTime->getSecond()), $year, $month, $day, 0, 0); diff --git a/src/eightchar/provider/impl/DefaultChildLimitProvider.php b/src/eightchar/provider/impl/DefaultChildLimitProvider.php index f940193..0cb9e49 100644 --- a/src/eightchar/provider/impl/DefaultChildLimitProvider.php +++ b/src/eightchar/provider/impl/DefaultChildLimitProvider.php @@ -46,9 +46,10 @@ function getInfo(SolarTime $birthTime, SolarTerm $term): ChildLimitInfo $sm = SolarMonth::fromYm($birthTime->getYear() + $year, $birthTime->getMonth())->next($month); $dc = $sm->getDayCount(); - if ($d > $dc) { + while ($d > $dc) { $d -= $dc; $sm = $sm->next(1); + $dc = $sm->getDayCount(); } return new ChildLimitInfo($birthTime, SolarTime::fromYmdHms($sm->getYear(), $sm->getMonth(), $d, $h, $mi, $birthTime->getSecond()), $year, $month, $day, $hour, $minute); diff --git a/src/sixtycycle/HeavenStem.php b/src/sixtycycle/HeavenStem.php index 77afa42..fdb2fa0 100644 --- a/src/sixtycycle/HeavenStem.php +++ b/src/sixtycycle/HeavenStem.php @@ -72,20 +72,12 @@ function getYinYang(): YinYang */ function getTenStar(HeavenStem $target): TenStar { - $hostElement = $this->getElement(); - $guestElement = $target->getElement(); - $index = 0; - $sameYinYang = $this->getYinYang()->equals($target->getYinYang()); - if ($hostElement->getReinforce()->equals($guestElement)) { - $index = 1; - } else if ($hostElement->getRestrain()->equals($guestElement)) { - $index = 2; - } else if ($guestElement->getRestrain()->equals($hostElement)) { - $index = 3; - } else if ($guestElement->getReinforce()->equals($hostElement)) { - $index = 4; + $targetIndex = $target->getIndex(); + $offset = $targetIndex - $this->index; + if ($this->index % 2 != 0 && $targetIndex % 2 == 0) { + $offset += 2; } - return TenStar::fromIndex($index * 2 + ($sameYinYang ? 0 : 1)); + return TenStar::fromIndex($offset); } /**