-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.1.3 优化代码;修复吉神宜趋、凶神宜忌错误;新增Lunar的2种起运流派;新增支持八字晚子时日柱算当天。
- Loading branch information
Showing
19 changed files
with
275 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace com\tyme\eightchar\provider; | ||
|
||
|
||
use com\tyme\eightchar\EightChar; | ||
use com\tyme\lunar\LunarHour; | ||
|
||
/** | ||
* 八字计算接口 | ||
* @author 6tail | ||
* @package com\tyme\eightchar\provider | ||
*/ | ||
interface EightCharProvider | ||
{ | ||
/** | ||
* 八字 | ||
* @param LunarHour $hour 农历时辰 | ||
* @return EightChar 八字 | ||
*/ | ||
function getEightChar(LunarHour $hour): EightChar; | ||
} |
45 changes: 45 additions & 0 deletions
45
src/eightchar/provider/impl/AbstractChildLimitProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace com\tyme\eightchar\provider\impl; | ||
|
||
|
||
use com\tyme\eightchar\ChildLimitInfo; | ||
use com\tyme\eightchar\provider\ChildLimitProvider; | ||
use com\tyme\ExtendTrait; | ||
use com\tyme\solar\SolarMonth; | ||
use com\tyme\solar\SolarTime; | ||
|
||
/** | ||
* 童限计算抽象 | ||
* @author 6tail | ||
* @package com\tyme\eightchar\provider\impl | ||
*/ | ||
abstract class AbstractChildLimitProvider implements ChildLimitProvider | ||
{ | ||
use ExtendTrait; | ||
|
||
function next(SolarTime $birthTime, int $addYear, int $addMonth, int $addDay, int $addHour, int $addMinute, int $addSecond): ChildLimitInfo | ||
{ | ||
$d = $birthTime->getDay() + $addDay; | ||
$h = $birthTime->getHour() + $addHour; | ||
$mi = $birthTime->getMinute() + $addMinute; | ||
$s = $birthTime->getSecond() + $addSecond; | ||
$mi += intdiv($s, 60); | ||
$s %= 60; | ||
$h += intdiv($mi, 60); | ||
$mi %= 60; | ||
$d += intdiv($h, 24); | ||
$h %= 24; | ||
|
||
$sm = SolarMonth::fromYm($birthTime->getYear() + $addYear, $birthTime->getMonth())->next($addMonth); | ||
|
||
$dc = $sm->getDayCount(); | ||
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, $s), $addYear, $addMonth, $addDay, $addHour, $addMinute); | ||
} | ||
} |
Oops, something went wrong.