oops-Lunar
[ class tree: oops-Lunar ] [ index: oops-Lunar ] [ all elements ]

Sample code

  1. <?php
  2. /*
  3.  * Test code for Lunar
  4.  * $Id$
  5.  */
  6.  
  7.  
  8. $iniget function_exists ('___ini_get''___ini_get' 'ini_get';
  9. $iniset function_exists ('___ini_set''___ini_set' 'ini_set';
  10.  
  11. $cwd getcwd ();
  12. $ccwd basename ($cwd);
  13. if $ccwd == 'tests' {
  14.     $oldpath $iniget ('include_path');
  15.     $newpath preg_replace ("!/{$ccwd}!"''$cwd);
  16.     $iniset ('include_path'$newpath ':' $oldpath);
  17. }
  18.  
  19. /*
  20.  * Lunar API import
  21.  */
  22. #require_once 'KASI_Lunar.php';
  23. require_once 'Lunar.php';
  24.  
  25.  
  26. $target $argv[1$argv[1date ('Ymd'time ());
  27.  
  28. try {
  29.     $lunar new oops\Lunar;
  30.  
  31.     $target $argv[1];
  32.     $lunar->toargs ($target);
  33.  
  34.     echo "**\n";
  35.     printf ("** target date is %s\n"$target);
  36.     echo "**\n";
  37.     echo "\n";
  38.  
  39.     # 1일의 음력 정보
  40.     $z $lunar->tolunar ($target);
  41.     # 이번달의 세차/월간/일진 정보
  42.     $tune $lunar->dayfortune ($target);
  43.     # 1일의 음력월에 대한 합삭/망 정보
  44.     $moon $lunar->moonstatus ($target);
  45.     # 1일의 28수 정보
  46.     $s28  $lunar->s28day ($target);
  47.     # 이번달의 절기 정보
  48.     $season $lunar->seasondate ($target);
  49.  
  50.     $yoon $z->leap ', 윤달' '';
  51.     $bmon $z->largemonth '큰달' '평달';
  52.  
  53.     echo <<<EOF
  54. -- 음력 변환 --------------------------------
  55.  
  56. 날자   {$z->fmt{$z->week} ({$z->hweek})
  57. 연     {$z->year}
  58. 월     {$z->month} ($bmon$yoon) {$tune->month}({$tune->hmonth})월
  59. 일     {$z->day{$tune->day}({$tune->hday})일
  60. 간지   {$z->ganji} ({$z->hganji}) ({$tune->year})
  61. 띠     {$z->ddi}
  62. 28수   {$s28->k} ({$s28->h})
  63.  
  64. 합삭 (New Moon)   {$moon->new->year}년 {$moon->new->month}월 {$moon->new->day}일 {$moon->new->hour}시 {$moon->new->min}
  65. 망   (Full Moon)  {$moon->full->year}년 {$moon->full->month}월 {$moon->full->day}일 {$moon->full->hour}시 {$moon->full->min}
  66.  
  67.  
  68. EOF;
  69.  
  70.     foreach $season as $v )
  71.         printf ("%s(%s) %d년 %d월 %d일\n"$v->name$v->hname$v->year$v->month$v->day);
  72.  
  73.  
  74.     $z $lunar->tosolar ($z->fmt$z->leap);
  75.  
  76.     echo <<<EOF
  77.  
  78. -- 양력 재변환 ------------------------------
  79. 날자   {$z->fmt{$z->week} ({$z->hweek})
  80. 연     {$z->year}
  81. 월     {$z->month}
  82. 일     {$z->day}
  83. 간지   {$z->ganji} ({$z->hganji})
  84. 띠     {$z->ddi}
  85.  
  86. EOF;
  87. catch Exception $e {
  88.     echo $e->Message ("\n";
  89.     print_r ($e->TraceAsArray ()) "\n";
  90.     $e->finalize ();
  91. }
  92.  
  93. /*
  94.  * Local variables:
  95.  * tab-width: 4
  96.  * c-basic-offset: 4
  97.  * End:
  98.  * vim: set filetype=php noet sw=4 ts=4 fdm=marker:
  99.  * vim600: noet sw=4 ts=4 fdm=marker
  100.  * vim<600: noet sw=4 ts=4
  101.  */
  102. ?>

Documentation generated on Tue, 14 May 2019 02:00:27 +0900 by phpDocumentor 1.4.4