| File Name ↓ | File Size ↓ | Date ↓ |
|---|---|---|
| Parent directory/ | - | - |
| sha1sum | 348 B | 2024-Aug-30 06:10 |
| Lunar-1.0.0.tgz | 16.0 KiB | 2013-Jul-19 16:39 |
| Lunar-1.0.1.tgz | 16.7 KiB | 2014-Jan-25 17:52 |
| Lunar-1.0.2.tgz | 16.8 KiB | 2015-Jun-09 03:16 |
| Lunar-2.0.0.tgz | 17.8 KiB | 2015-Dec-07 23:41 |
| Lunar-2.0.1.tgz | 18.6 KiB | 2024-Aug-28 01:15 |
| Lunar-2.0.2.tgz | 19.0 KiB | 2024-Aug-30 06:04 |
Lunar package는 고영창님의 진짜 만세력을 PHP로 포팅하여 개선한 것으로, 양력/음력 간의 변환을 제공합니다.
1852년 10월 15일 이전의 양력 날자는 율리우스력으로 취급을 하며, 내부 계산시에 그레고리력으로 변환을 하여 계산을 합니다.
2.0 부터는 oops/KASI_Lunar package가 설치되어 있고, 코드에서 KASI_Lunar.php를 Lunar.php보다 먼저 include 를 하면, 1391-02-05 ~ 2050-12-31 까지의 기간은 한국천문연구원의 음양력 DB를 이용하여 처리 합니다. (속도도 훨씬 빠릅니다.)
또한, 2.0 부터는 namespace oops가 추가되어, 선언시에, "new oops\Lunar;" 와 같이 선언해야 합니다.
이 패키지가 제공하는 기능은 다음과 같습니다.
이 변환 API의 유효기간은 다음과 같습니다.
계산 처리 시간상, 과거 2000년전과 미래 100년후의 시간은 왠만하면 웹에서는 사용하는 것을 권장하지 않음!
Reference:
<?php
/*
* Test code for pear_Lunar
* $Id: test.php 19 2013-07-15 17:15:37Z oops $
*/
// 한국 천문 연구원의 DB를 사용하기 위해서
// oops/KASI_Lunar pear package가 설치 되어 있어야 한다.
require_once 'KASI_Lunar.php';
/*
* Lunar API import
*/
require_once 'Lunar.php';
$target = $argv[1] ? $argv[1] : date ('Ymd', time ());
$lunar = new oops\Lunar;
$target = $argv[1];
$lunar->toargs ($target);
echo "**\n";
printf ("** target date is %s\n", $target);
echo "**\n";
echo "\n";
# 1일의 음력 정보
$z = $lunar->tolunar ($target);
# 이번달의 세차/월간/일진 정보
$tune = $lunar->dayfortune ($target);
# 1일의 음력월에 대한 합삭/망 정보
$moon = $lunar->moonstatus ($target);
# 1일의 28수 정보
$s28 = $lunar->s28day ($target);
# 이번달의 절기 정보
$season = $lunar->seasondate ($target);
$yoon = $z->moonyoon ? ', 윤달' : '';
$bmon = $z->largemonth ? '큰달' : '평달';
echo <<<EOF
-- 음력 변환 --------------------------------
날자 {$z->date} {$z->week} ({$z->hweek})
연 {$z->year}
월 {$z->month} ($bmon$yoon) {$tune->month}({$tune->hmonth})월
일 {$z->day} {$tune->day}({$tune->hday})일
간지 {$z->ganji} ({$z->hganji}) ({$tune->year})
띠 {$z->ddi}
28수 {$s28->k} ({$s28->h})
합삭 (New Moon) {$moon->new->year}년 {$moon->new->month}월 {$moon->new->day}일 {$moon->new->hour}시 {$moon->new->min}분
망 (Full Moon) {$moon->full->year}년 {$moon->full->month}월 {$moon->full->day}일 {$moon->full->hour}시 {$moon->full->min}분
EOF;
foreach ( $season as $v )
printf ("%s(%s) %d년 %d월 %d일\n", $v->name, $v->hname, $v->year, $v->month, $v->day);
$z = $lunar->tosolar ($z->date, $z->moonyoon);
echo <<<EOF
-- 양력 재변환 ------------------------------
날자 {$z->date} {$z->week} ({$z->hweek})
연 {$z->year}
월 {$z->month}
일 {$z->day}
간지 {$z->ganji} ({$z->hganji})
띠 {$z->ddi}
EOF;
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim: set filetype=php noet sw=4 ts=4 fdm=marker:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
?>
Installation:
shell> pear channel-discover pear.oops.org shell> pear install oops/Lunar shell> pear list -a