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

Sample code

  1. <?php
  2. /*
  3.  * Test code for KASI_Lunar
  4.  * $Id$
  5.  */
  6.  
  7. $iniget function_exists ('___ini_get''___ini_get' 'ini_get';
  8. $iniset function_exists ('___ini_set''___ini_set' 'ini_set';
  9.  
  10. $cwd getcwd ();
  11. $ccwd basename ($cwd);
  12. if $ccwd == 'tests' {
  13.     $oldpath $iniget ('include_path');
  14.     $newpath preg_replace ("!/{$ccwd}!"''$cwd);
  15.     $iniset ('include_path'$newpath ':' $oldpath);
  16. }
  17.  
  18. /*
  19.  * oops\KASI/Lunar API import
  20.  */
  21. require_once 'KASI_Lunar.php';
  22.  
  23. $lunar new oops\KASI\Lunar;
  24.  
  25. $days array (
  26.     '1391-02-05',
  27.     '1582-10-04',
  28.     '1582-10-05',
  29.     '1582-10-15',
  30.     '1583-03-03'// not leap
  31.     '1583-04-03'// leap
  32.     '2050-12-31',
  33.     '2051-12-31',
  34. );
  35.  
  36. $ment array (
  37.     '유효범위 시작날자',
  38.     '율리우스력 마지막 날자',
  39.     '율리우스력과 그레고리력 사이의 존재하지 않는 날',
  40.     '그레고리력 시작 날자',
  41.     '윤달 체크(아님)',
  42.     '윤달 체크(맞음)',
  43.     '유효범위 마지막 날자',
  44.     '유효범위 밖'
  45. );
  46.  
  47. echo "-----------------------------------------------------------------------\n";
  48.  
  49. try {
  50.     $i 0;
  51.     foreach $days as $day {
  52.         $l $lunar->tolunar ($day);
  53.  
  54.         $leap  $l->leap 'true' 'false';
  55.         $lmoon $l->lmoon 'true' 'false';
  56.  
  57.         $s $lunar->tosolar ($l->fmt$l->leap);
  58.  
  59.         echo <<<EOF
  60. 지정 날자: $day - {$ment[$i++]}
  61. 음력 변환: {$l->fmt}, leap: {$leap}, LargeMoon: {$lmoon}
  62. 양력 변환: {$s->fmt{$s->jd}
  63. -----------------------------------------------------------------------
  64.  
  65. EOF;
  66.     }
  67. catch Exception $e {
  68.     echo $e->Message ("\n";
  69.     print_r ($e->TraceAsArray ()) "\n";
  70.     $e->finalize ();
  71. }
  72.  
  73. ?>

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