issues
search
6tail
/
lunar-php
日历、公历(阳历)、农历(阴历、老黄历)、佛历、道历,支持节假日、星座、儒略日、干支、生肖、节气、节日、彭祖百忌、每日宜忌、吉神宜趋凶煞宜忌、吉神(喜神/福神/财神/阳贵神/阴贵神)方位、胎神方位、冲煞、纳音、星宿、八字、五行、十神、建除十二值星、青龙名堂等十二神、黄道黑道日及吉凶等。lunar is a calendar library for Solar and Chinese Lunar.
http://6tail.cn/calendar/api.html
MIT License
152
stars
61
forks
source link
获取宜和忌方法和其他编程语言判断存在差别,导致无法获取到宜忌事项
#3
Closed
simplephp
closed
2 years ago
simplephp
commented
3 years ago
`/**
获取日忌
@param string $monthGanZhi 月干支
@param string $dayGanZhi 日干支
@return array 忌 */ public static function getDayJi($monthGanZhi, $dayGanZhi) { $l = array(); $day = LunarUtil::hex(LunarUtil::getJiaZiIndex($dayGanZhi)); $month = LunarUtil::hex(LunarUtil::getJiaZiIndex($monthGanZhi)); $right = LunarUtil::$DAY_YI_JI; $index = strpos($right, $day . '='); // while ($index) { ## 原始的判断 while ($index > -1) { $right = substr($right, $index + 3); $left = $right; if (strpos($left, '=')) { $left = substr($left, 0, strpos($left, '=') - 2); } $matched = false; $months = substr($left, 0, strpos($left, ':')); for ($i = 0, $j = strlen($months); $i < $j; $i += 2) { $m = substr($months, $i, 2); if ($m == $month) { $matched = true; break; } } if ($matched) { $ys = substr($left, strpos($left, ',') + 1, strlen($left)); for ($i = 0, $j = strlen($ys); $i < $j; $i += 2) { $m = substr($ys, $i, 2); $l[] = LunarUtil::$YI_JI[hexdec($m)]; } break; } $index = strpos($right, $day . '='); } if (count($l) < 1) { $l[] = '无'; } return $l; }`
宜和忌方法都存在 while($index) 判断问题
6tail
commented
3 years ago
感谢,已修改。
6tail
commented
3 years ago
v1.1.9 修复日宜忌获取问题。
`/**
宜和忌方法都存在 while($index) 判断问题