Develop
2013.12.25 00:15
[php] GregorianToJD(), JDToGregorian() 함수 내용
Views 10643 Comment 0
어떤 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
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
121 | Develop | [js] 모바일 스크롤 방지(해제) | hooni | 2015.04.14 | 1701 |
120 | Develop | [ios] Swift 4 Singleton inheritance | hooni | 2018.10.31 | 1696 |
119 | Develop | [ios] 스크린 캡쳐 (전원버튼 + 홈버튼) 호출 알아내기 | hooni | 2014.11.19 | 1661 |
118 | Develop |
[ios] binary를 C코드로 변환
![]() |
hooni | 2015.01.03 | 1654 |
117 | Develop | [android] 레이아웃 사이즈 변경 (동적; programmatically) | hooni | 2016.11.07 | 1626 |
116 | Develop |
[swift] popToRoot 모달뷰, 네비게이션컨트롤러 한꺼번에 닫기
![]() |
hooni | 2021.01.29 | 1610 |
115 | Develop | How to Test SMTP AUTH using Telnet | hooni | 2018.04.05 | 1597 |
114 | Develop | What is difference between Get, Post, Put and Delete? | hooni | 2018.02.28 | 1578 |
113 | Develop | [ios] Swift 4 String, Date, DateFormatter 예제 | hooni | 2018.10.18 | 1521 |
112 | Develop |
macOS에 node, npm 설치하기 (homebrew)
![]() |
hooni | 2021.11.06 | 1483 |
111 | Develop | [ios] How to set up clang formatter | hooni | 2015.09.17 | 1480 |
110 | Develop | [android] 간단한 SQLIite 예제 | hooni | 2017.06.14 | 1478 |