Skip to content

Commit

Permalink
v1.3.15 修复八字转阳历存在遗漏的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
6tail committed Mar 19, 2024
1 parent 19dd0d1 commit 3e1a79a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
1. 修复节气当天获取下一节气仍为当前节气的问题。
2. 修复每日宜忌存在重复项的问题。
3. 修复八字转阳历存在遗漏的问题。

## [1.3.15] - 2024-03-19
1. 修复八字转阳历存在遗漏的问题。
4 changes: 1 addition & 3 deletions Lunar.php
Original file line number Diff line number Diff line change
Expand Up @@ -8915,9 +8915,7 @@ public static function fromBaZiBySectAndBaseYear($yearGanZhi, $monthGanZhi, $day
$solarTime = $jieQiTable[Lunar::$JIE_QI_IN_USE[4 + $m]];
if ($solarTime->getYear() >= $baseYear) {
// 日干支和节令干支的偏移值
$lunar = $solarTime->getLunar();
$dgz = (2 == $sect) ? $lunar->getDayInGanZhiExact2() : $lunar->getDayInGanZhiExact();
$d = LunarUtil::getJiaZiIndex($dayGanZhi) - LunarUtil::getJiaZiIndex($dgz);
$d = LunarUtil::getJiaZiIndex($dayGanZhi) - LunarUtil::getJiaZiIndex($solarTime->getLunar()->getDayInGanZhiExact2());
if ($d < 0) {
$d += 60;
}
Expand Down
6 changes: 6 additions & 0 deletions demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,9 @@
// 佛历
$foto = Foto::fromLunar(Lunar::fromYmd(2021, 10, 14));
echo $foto->toFullString() . "\n";

$solar = Solar::fromYmdHms(2000, 1, 23, 22, 0, 0);
$lunar = $solar->getLunar();
$eightChar = $lunar->getEightChar();
// 己卯 丁丑 庚辰 丁亥
echo $eightChar->getYear() . " " . $eightChar->getMonth(). " " . $eightChar->getDay(). " " . $eightChar->getTime() . "\n";

0 comments on commit 3e1a79a

Please sign in to comment.