어떤 XE플래너 위젯을 쓰다보면 아래 로컬 함수가 구현되지 않아 오류나는 경우가 있다.
class.planner123_widget_main.php 함수의 1
그레고리안(Gregorian) -> 줄리안(Julian) 변환
function GregorianToJD ($month,$day,$year) { if ($month > 2) { $month = $month - 3; } else { $month = $month + 9; $year = $year - 1; } $c = floor($year / 100); $ya = $year - (100 * $c); $j = floor((146097 * $c) / 4); $j += floor((1461 * $ya)/4); $j += floor(((153 * $month) + 2) / 5); $j += $day + 1721119; return $j; }
줄리안(Julian) -> 그레고리안(Gregorian) 변환 (버전1)
function JDToGregorian($julian) { //return planner123_widget_main::fn_calcJDToGregorian($julian); $julian = $julian - 1721119; $calc1 = 4 * $julian - 1; $year = floor($calc1 / 146097); $julian = floor($calc1 - 146097 * $year); $day = floor($julian / 4); $calc2 = 4 * $day + 3; $julian = floor($calc2 / 1461); $day = $calc2 - 1461 * $julian; $day = floor(($day + 4) / 4); $calc3 = 5 * $day - 3; $month = floor($calc3 / 153); $day = $calc3 - 153 * $month; $day = floor(($day + 5) / 5); $year = 100 * $year + $julian; if ($month < 10) { $month = $month + 3; }else{ $month = $month - 9; $year = $year + 1; } if ($day < 10) { $day = "0".$day; } if ($month < 10) { $month = "0".$month; } //return $day."/".$month."/".$year; return $month."/".$day."/".$year; }
줄리안(Julian) -> 그레고리안(Gregorian) 변환 (버전2)
function fn_calcJDToGregorian($julian) { $z = $julian; $f = .5; $f = 0.0; // PHP함수와 결과값 맞추기 위해 0.5일 조정함 if($z < 2299161){ $a = $z; }else{ $alpha = floor(($z - 1867216.25) / 36524.25); $a = $z + 1 + $alpha - floor($alpha / 4); } $b = $a + 1524; $c = floor( ($b - 122.1) / 365.25); $d = floor( 365.25 * $c); $e = floor( ($b - $d) / 30.6001); $dd = floor( $b - $d - floor(30.6001 * $e) + $f); if($e < 13.5) { $mm = $e - 1; }else{ $mm = $e - 13; } if($mm < 2.5 ){ $yy = $c - 4715; }else{ $yy = $c - 4716; } return "$mm/$dd/$yy"; }
[출처] http://flashcafe.org/php_function/8705