/** * 음력 광활하고 심오한 음력
* 원본 데이터 및 알고리즘 아이디어는 S&S에서 제공
연구실 http://www.focus-2000.com 아쉽게도 홈페이지가 폐쇄된 것 같습니다
*/
/*
음력 각 달의 일수입니다.
각 요소는 1년입니다. 각 요소의 데이터는 다음과 같습니다.
[0]은 윤달이 있는 달이고, 0은 윤달이 없음을 의미합니다.
[1]~[13]은 1년에 12개월 또는 13개월을 기준으로 한 달의 일수입니다.
[14]는 그해 천간순이며,
[15]는 올해의 땅가지의 순서이다.
*/
- 음력 달력($month, $year)
- {
- global $lnlunarcalendar;
- /* *
- * 음력 방대하고 심오한 음력
- * 원본 데이터 및 알고리즘 아이디어는 S&S에서 가져옴
- 연구실 http://www.focus-2000.com 아쉽게도 웹사이트는 폐쇄된 것 같습니다
- */
- /*
- 음력 각 달의 일수입니다.
- 각 요소는 1년입니다.각 요소의 데이터는 다음과 같습니다.
- [0]은 윤달이 있는 달이고, 0은 윤달이 없음을 의미합니다.
- [1] ~ [13]은 각 달의 일수입니다. 1년은 12개월 또는 13개월입니다.
- [14]는 한 해의 천간 순서이고,
- [15]는 한 해의 가지 순서입니다.
- */
- $ 매월 = 배열(
- 0 => 배열(8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 30, 7, 1),
- 1 => 배열(0, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30, 29, 0, 8, 2),
- 2 => 배열(0, 30, 29 , 30, 29, 29, 30, 29, 30, 29, 30, 30, 30, 0, 9, 3),
- 3 => 배열(5, 29, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 10, 4) ,
- 4 => 배열(0, 30, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 0, 1, 5),
- 5 => 배열(0, 30, 30, 29, 30, 30, 29, 29, 30, 29, 30, 29, 30, 0, 2, 6),
- 6 => 배열(4, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 3, 7),
- 7 => 배열(0, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 0, 4, 8),
- 8 => 배열(0, 30, 29, 29 , 30, 30, 29, 30, 29, 30, 30, 29, 30, 0, 5, 9),
- 9 => 배열(2, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30, 29, 30, 6, 10),
- 10 => 배열(0, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30, 29 , 0, 7, 11),
- 11 = > 배열(6, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30, 8, 12),
- 12 => 배열(0, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 0, 9, 1),
- 13 => 배열( 0, 30, 30, 29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 0, 10, 2),
- 14 => 배열(5, 30, 30, 29, 30 , 29, 30, 29, 30, 29, 30, 29, 29, 30, 1, 3),
- 15 => 배열(0, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 0, 2, 4),
- 16 => 배열(0, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 0 , 3, 5),
- 17 => 배열(2, 30, 29, 29, 30, 29, 30, 30, 29, 30, 30, 29, 30, 29, 4, 6),
- 18 => 배열(0, 30, 29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 0, 5, 7),
- 19 => , 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30, 30, 6, 8),
- 20 => 배열(0, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30, 0, 7, 9),
- 21 => 배열(0, 30, 29, 30, 29, 29, 30, 29, 29, 30 , 29, 30, 30, 0, 8, 10),
- 22 => 배열(5, 30, 29, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 9, 11),
- 23 => 배열(0, 29, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 0, 10, 12),
- 24 => 배열(0, 29, 30, 30, 29, 30, 30, 29, 30, 29, 30, 29, 29, 0, 1, 1),
- 25 => 배열(4, 30, 29 , 30, 29, 30, 30, 29, 30, 30, 29, 30, 29, 30, 2, 2),
- 26 => 배열(0, 29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 0, 3, 3),
- 27 => 배열(0, 30, 29, 29, 30, 29, 30, 29, 30, 29, 30, 30 , 30, 0, 4, 4),
- 28 => 배열(2, 29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30, 30, 5, 5) ,
- 29 => 배열(0, 29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30, 0, 6, 6),
- 30 => 배열(6, 29, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 29, 7, 7),
- 31 => 배열(0, 30, 30, 29 , 30, 29, 30, 29, 29, 30, 29, 30, 29, 0, 8, 8),
- 32 => 배열(0, 30, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 0, 9, 9),
- 33 => 배열(5, 29, 30, 30, 29, 30, 30, 29, 30, 29, 30, 29, 29 , 30, 10, 10),
- 34 => 배열(0, 29, 30, 29, 30, 30, 29, 30, 29, 30, 30, 29, 30, 0, 1, 11),
- 35 => 배열(0, 29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 0, 2, 12),
- 36 = > , 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30, 30, 29, 3, 1),
- 37 => 배열(0, 30, 29, 29, 30 , 29, 29, 30, 29, 30, 30, 30, 29, 0, 4, 2),
- 38 => 배열(7, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 29, 30, 5, 3),
- 39 => 배열(0, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 29, 30, 0 , 6, 4),
- 40 => 배열(0, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 0, 7, 5),
- 41 => 배열(6, 30, 30, 29, 30, 30, 29, 30, 29, 29, 30, 29, 30, 29, 8, 6),
- 42 => , 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 0, 9, 7),
- 43 => 배열(0, 29, 30, 29, 30, 29 , 30, 30, 29, 30, 29, 30, 29, 0, 10, 8),
- 44 => 배열(4, 30, 29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 1, 9),
- 45 => 배열(0, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30, 29, 30, 0, 2 , 10),
- 46 => 배열(0, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 29, 30, 0, 3, 11),
- 47 = > 배열(2, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 4, 12),
- 48 => 배열(0, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 0, 5, 1),
- 49 => 배열( 7, 30, 29, 30, 30, 29, 30, 29 , 29, 30, 29, 30, 29, 30, 6, 2),
- 50 => 배열(0, 29, 30, 30, 29, 30, 30, 29, 29, 30, 29, 30, 29, 0, 7, 3),
- 51 => 배열(0, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 0, 8, 4),
- 52 => 배열(5, 29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 9, 5),
- 53 => 배열(0 , 29, 30, 29, 29, 30, 30, 29, 30, 30, 29, 30, 29, 0, 10, 6) ,
- 54 => 배열(0, 30, 29, 30, 29, 29, 30, 29, 30, 30, 29, 30, 30, 0, 1, 7),
- 55 => 배열(3, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30, 2, 8),
- 56 => 배열(0, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 0, 3, 9),
- 57 => 배열(8, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 29, 4, 10),
- 58 => 배열(0, 30, 30, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 0, 5, 11),
- 59 => 배열(0, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 0, 6, 12),
- 60 => 배열(6, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 7, 1),
- 61 => 배열(0, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 0, 8, 2),
- 62 => 배열(0, 29, 30, 29, 29, 30, 29, 30, 30, 29, 30, 30, 29, 0, 9, 3),
- 63 => 배열(4, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30, 29, 10, 4),
- 64 => 배열(0, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30, 0, 1, 5),
- 65 => 배열(0, 29, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 0, 2, 6),
- 66 => 배열(3, 30, 30, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 3, 7),
- 67 => 배열(0, 30, 30, 29, 30, 30, 29, 29, 30, 29, 30, 29, 30, 0, 4, 8),
- 68 => 배열(7, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 5, 9),
- 69 => 배열(0, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 0, 6, 10),
- 70 => 배열(0, 30, 29, 29, 30, 29, 30, 30, 29, 30, 30, 29, 30, 0, 7, 11),
- 71 => 배열(5, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30, 29, 30, 8, 12),
- 72 => 배열(0, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 0, 9, 1),
- 73 => 배열(0, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 0, 10, 2),
- 74 => 배열(4, 30, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 1, 3),
- 75 => 배열(0, 30, 30, 29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 0, 2, 4),
- 76 => 배열(8, 30, 30, 29, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 3, 5),
- 77 => 배열(0, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 29, 0, 4, 6),
- 78 => 배열(0, 30, 29, 30, 30, 29, 30, 30, 29, 30, 29, 30, 29, 0, 5, 7),
- 79 => 배열(6, 30, 29, 29, 30, 29, 30, 30, 29, 30, 30, 29, 30, 29, 6, 8),
- 80 => 배열(0, 30, 29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 0, 7, 9),
- 81 => 배열(0, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30, 0, 8, 10),
- 82 => 배열(4, 30, 29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30, 9, 11),
- 83 => 배열(0, 30, 29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 0, 10, 12),
- 84 => 배열(10, 30, 29, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 1, 1),
- 85 => 배열(0, 29, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 0, 2, 2),
- 86 => 배열(0, 29, 30, 30, 29, 30, 30, 29, 30, 29, 30, 29, 29, 0, 3, 3),
- 87 => 배열(6, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 30, 29, 29, 4, 4),
- 88 => 배열(0, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 0, 5, 5),
- 89 => 배열(0, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30, 30, 0, 6, 6),
- 90 => 배열(5, 29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30, 30, 7, 7),
- 91 => 배열(0, 29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30, 0, 8, 8),
- 92 => 배열(0, 29, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 0, 9, 9),
- 93 => 배열(3, 29, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 10, 10),
- 94 => 배열(0, 30, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 0, 1, 11),
- 95 => 배열(8, 29, 30, 30, 29, 30, 29, 30, 30, 29, 29, 30, 29, 30, 2, 12),
- 96 => 배열(0, 29, 30, 29, 30, 30, 29, 30, 29, 30, 30, 29, 29, 0, 3, 1),
- 97 => 배열(0, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 0, 4, 2),
- 98 => 배열(5, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30, 29, 30, 5, 3),
- 99 => 배열(0, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30, 29, 0, 6, 4),
- 100 => 배열(0, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 29, 0, 7, 5),
- 101 => 배열(4, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 8, 6),
- 102 => 배열(0, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 0, 9, 7),
- 103 => 배열(0, 30, 30, 29, 30, 30, 29, 30, 29, 29, 30, 29, 30, 0, 10, 8),
- 104 => 배열(2, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 1, 9),
- 105 => 배열(0, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 0, 2, 10),
- 106 => 배열(7, 30, 29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 3, 11),
- 107 => 배열(0, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30, 29, 30, 0, 4, 12),
- 108 => 배열(0, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 29, 30, 0, 5, 1),
- 109 => 배열(5, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 6, 2),
- 110 => 배열(0, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 0, 7, 3),
- 111 => 배열(0, 30, 29, 30, 30, 29, 30, 29, 29, 30, 29, 30, 29, 0, 8, 4),
- 112 => 배열(4, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 9, 5),
- 113 => 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 0, 10, 6),
- 114 => 배열(9, 29, 30, 29, 30, 29 , 30, 29, 30, 30, 29, 30, 29, 30, 1, 7),
- 115 => 배열(0, 29, 30, 29, 29, 30, 29, 30, 30, 30, 29, 30, 29, 0, 2, 8),
- 116 => 배열(0, 30, 29, 30, 29, 29, 30, 29, 30, 30, 29, 30, 30, 0, 3 , 9),
- 117 => 배열(6, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30, 4, 10),
- 118 = > 배열(0, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 0, 5, 11),
- 119 => 배열( 0, 30, 29, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 0, 6, 12),
- 120 => 배열(4, 29, 30, 30, 30, 29, 30, 29 , 29, 30, 29, 30, 29, 30, 7, 1)
- );
-
- $mten = $lnlunarcalendar['tiangan'];// 음력 천구월
- $mtwelve = $lnlunarcalendar['dizhi'];// 음력 지구
- $mmonth = $lnlunarcalendar['month'];// 음력 월
- $mday = $lnlunarcalendar['day'] // 음력 day
- // 1900년 12월 21일까지의 그레고리력의 총 일수
- $total = 69 * 365 17 11
- //1970년 1월 1일 이전의 날짜는 계산되지 않습니다
- if ($year == "" || $month == "" || ($year < 1970 or $year > 2020) return '' //이 범위를 벗어나면 계산되지 않습니다.
- / / 계산: 요청한 날짜에 대한 그레고리력의 총 일 수 - 1900년 12월 21일 이후
-
- for ($y = 1970; $y < $year;$y ) {// 먼저 연도의 합계
- $total = 365;
- if ($y % 4 == 0) $total ;
- }
- // 현재 연도의 월을 더합니다.
- $total = gmdate("z", gmmktime (0, 0, 0, $month, 1, $year));
- // 음력의 누적 일수를 사용하여 음력의 일수를 초과하는지 확인합니다. 태양력
- $flag1 = 0; //루프에서 벗어나기 위한 조건 판단
- $lcj = 0;
- while ($lcj <= 120) {
- $lci = 1 ;
- while ($lci <= 13) {
- $mtotal = $everymonth[ $lcj][$lci];
- if ($mtotal >= $total) {
- $flag1 = 1;
- break;
- }
- $lci ;
- }
- if ($flag1 == 1) break;
- $lcj ;
- }
- // 위에서 구한 $lci는 이번 음력, $lcj는 이번 음력
- // 원하는 달 1일의 음력 날짜를 계산
- $fisrtdaylunar = $everymonth[$lcj][ $lci] - ($mtotal - $total);
- $results['연도'] = $mten[$everymonth [$lcj][14]] $mtwelve[$everymonth[$lcj][15]] ; //현재 연도는 무엇입니까
- $daysthismonth = gmdate("t", gmmktime(0, 0, 0, $ Month, 1, $year)) //이번 달의 총 일수
- $ op = 1;
- for ($i = 1; $i <= $daysthismonth; $i ) {
- $ availablelunarday = $fisrtdaylunar $op-1; //이론적으로 겹쳐진 음력 일
- if ( $possiblelunarday <= $everymonth[$lcj][$lci]) { // 이번 달의 날짜 범위 내
- $results[$i] = $mday[$possiblelunarday];
- $op = 1;
- }
- else { // 이번 달의 날짜 범위에 속하지 않습니다
- $results[$i ] = $mday[1] //1일차로 돌아갑니다
- $fisrtdaylunar = 1;
- $op = 2;
- $curmonthnum = ($everymonth[$lcj][0] != 0) ? 13 : 12 //올해는 몇 개월입니까
- if ($lci 1 > $curmonthnum) { // 13/14번째 달이니까 다음 해로 가세요
- $lci = 1;
- $lcj = $lcj 1;
- // 새달이에요 새해의 별자리도 적어보세요
- $results['year'] .= '/' . $mten[$everymonth[ $lcj][14]] . 15]];
- }
- else { // 올해에도
- $lci = $lci 1;
- $lcj = $lcj;
- }
- }
- if ($results[$i] == $mday[1]) { // 매월 1일은 몇 월인지 표시해야 합니다
- if ($everymonth[$lcj][0] != 0) { / / 윤달이 있는 연도
- $monthss = ($lci > $everymonth[$lcj][0]) ? ($lci-1 ) : $lci; 🎜> if ($lci == $everymonth[$lcj][0] 1) { //이번 달은 윤달입니다.
- $monthssshow = $mmonth[$monthss] / /앞에 도약 문자 추가
- $runyue = 1;
- }
- else {
- $monthssshow = $mmonth[$monthss];
- }
- }
- else {
- $monthss = $lci;
- $monthssshow = $mmonth[$monthss];
- }
- if ($monthss <= 10 && $ runyue != 1){ //한 단어만 월 더하기 '월'
- $monthssshow .= $mmonth[13];
- }
- $results[$i] = $monthssshow
- }
- }
- return $ 결과;
- }
- // 이것을 추가하는 것을 잊었습니다: 음력 달력 단어
- $lnlunarcalendar = array(
- 'tiangan' => array("Unknown", "A", "B", "C", " Ding ", "Wu", "Ji", "Geng", "Xin", "Ren", "縸"),
- 'dizhi' => array("Unknown", "Zi Nian (쥐)" , "Chou Nian (Ox)", "Yin Nian (호랑이)", "Mao Nian (토끼)", "Chen Nian (Dragon)",
- "Si Nian (Snake)", "Wu Nian (말) " , "Wei Nian(양)", "Shen Nian(원숭이)", "You Nian(닭)", "Xu Nian(개)", "Hai Nian(돼지)"),
- '월' => ; array("闰", "정", "이", "삼", "사", "오", "六",
- "七", "八", "九", "十", " 11", "12", "월"),
- '일' => array("알 수 없음", "중학교 첫날", "중학교 둘째 날", "중학교 셋째 날" 고등학교', '중학교 넷째 날', ''보름날', '보름날', '음월 칠일', '음력 팔일', "음력 구월", "음력 십일",
- "십일일", "십이일", "십삼일", "십사일" ", "십오", "십육일", "열일곱", "열여덟", "열아홉", "스물",
- "스물하나", "스물둘", "스물셋", "스물넷", "스물다섯", " 스물여섯", "스물일곱", "스물여덟", "스물아홉", "서른")
- );
-
코드 복사
|