= 2050) { //년수가 해당일자를 넘는 경우 $YunMonthFlag = 0; return false; //년도 범위가 벗어남.. } if ($getMONTH > 12) { // 달수가 13이 넘는 경우 $YunMonthFlag = 0; return false; //달수 범위가 벗어남.. } $m1 = $getYEAR - 1881; if (substr($arrayDATA[$m1],12,1) == 0) { // 윤달이 없는 해임 $YunMonthFlag = 0; } else { if (substr($arrayDATA[$m1],$getMONTH, 1) > 2) { $YunMonthFlag = 1; } else { $YunMonthFlag = 0; } } //------------- $m1 = -1; $td = 0; if ($getYEAR > 1881 && $getYEAR < 2050) { $m1 = $getYEAR - 1882; for ($i=0;$i<=$m1;$i++) { for ($j=0;$j<=12;$j++) { $td = $td + (substr($arrayDATA[$i],$j,1)); } if (substr($arrayDATA[$i],12,1) == 0) { $td = $td + 336; } else { $td = $td + 362; } } } else { $gf_lun2sol = 0; } $m1++; $n2 = $getMONTH - 1; $m2 = -1; while(1) { $m2++; if (substr($arrayDATA[$m1], $m2, 1) > 2) { $td = $td + 26 + (substr($arrayDATA[$m1], $m2, 1)); $n2++; } else { if ($m2 == $n2) { if ($gf_yun) { $td = $td + 28 + (substr($arrayDATA[$m1], $m2, 1)); } break; } else { $td = $td + 28 + (substr($arrayDATA[$m1], $m2, 1)); } } } $td = $td + $getDAY + 29; $m1 = 1880; while(1) { $m1++; if ($m1 % 400 == 0 || $m1 % 100 != 0 && $m1 % 4 == 0) { $leap = 1; } else { $leap = 0; } if ($leap == 1) { $m2 = 366; } else { $m2 = 365; } if ($td < $m2) break; $td = $td - $m2; } $syear = $m1; $arrayLDAY[1] = $m2 - 337; $m1 = 0; while(1) { $m1++; if ($td <= $arrayLDAY[$m1-1]) { break; } $td = $td - $arrayLDAY[$m1-1]; } $smonth = $m1; $sday = $td; $y = $syear - 1; $td = intval($y*365) + intval($y/4) - intval($y/100) + intval($y/400); if ($syear % 400 == 0 || $syear % 100 != 0 && $syear % 4 == 0) { $leap = 1; } else { $leap = 0; } if ($leap == 1) { $arrayLDAY[1] = 29; } else { $arrayLDAY[1] = 28; } for ($i=0;$i<=$smonth-2;$i++) { $td = $td + $arrayLDAY[$i]; } $td = $td + $sday; $w = $td % 7; $sweek = $arrayWEEK[$w]; $gf_lun2sol = 1; return($syear."|".$smonth."|".$sday."|".$sweek); } function sol2lun($yyyymmdd) { $getYEAR = (int)substr($yyyymmdd,0,4); $getMONTH = (int)substr($yyyymmdd,4,2); $getDAY = (int)substr($yyyymmdd,6,2); $arrayDATASTR = sunlunar_data(); $arrayDATA = explode("-",$arrayDATASTR); $arrayLDAYSTR="31-0-31-30-31-30-31-31-30-31-30-31"; $arrayLDAY = explode("-",$arrayLDAYSTR); $arrayYUKSTR="갑-을-병-정-무-기-경-신-임-계"; $arrayYUK = explode("-",$arrayYUKSTR); $arrayGAPSTR="자-축-인-묘-진-사-오-미-신-유-술-해"; $arrayGAP = explode("-",$arrayGAPSTR); $arrayDDISTR="쥐-소-호랑이-토끼-용-뱀-말-양-원숭이-닭-개-돼지"; $arrayDDI = explode("-",$arrayDDISTR); $arrayWEEKSTR="일-월-화-수-목-금-토"; $arrayWEEK = explode("-",$arrayWEEKSTR); $dt = $arrayDATA; for ($i=0;$i<=168;$i++) { $dt[$i] = 0; for ($j=0;$j<12;$j++) { switch (substr($arrayDATA[$i],$j,1)) { case 1: $dt[$i] += 29; break; case 3: $dt[$i] += 29; break; case 2: $dt[$i] += 30; break; case 4: $dt[$i] += 30; break; } } switch (substr($arrayDATA[$i],12,1)) { case 0: break; case 1: $dt[$i] += 29; break; case 3: $dt[$i] += 29; break; case 2: $dt[$i] += 30; break; case 4: $dt[$i] += 30; break; } } $td1 = 1880 * 365 + (int)(1880/4) - (int)(1880/100) + (int)(1880/400) + 30; $k11 = $getYEAR - 1; $td2 = $k11 * 365 + (int)($k11/4) - (int)($k11/100) + (int)($k11/400); if ($getYEAR % 400 == 0 || $getYEAR % 100 != 0 && $getYEAR % 4 == 0) { $arrayLDAY[1] = 29; } else { $arrayLDAY[1] = 28; } if ($getMONTH > 13) { $gf_sol2lun = 0; } if ($getDAY > $arrayLDAY[$getMONTH-1]) { $gf_sol2lun = 0; } for ($i=0;$i<=$getMONTH-2;$i++) { $td2 += $arrayLDAY[$i]; } $td2 += $getDAY; $td = $td2 - $td1 + 1; $td0 = $dt[0]; for ($i=0;$i<=168;$i++) { if ($td <= $td0) { break; } $td0 += $dt[$i+1]; } $ryear = $i + 1881; $td0 -= $dt[$i]; $td -= $td0; if (substr($arrayDATA[$i], 12, 1) == 0) { $jcount = 11; } else { $jcount = 12; } $m2 = 0; for ($j=0;$j<=$jcount;$j++) { // 달수 check, 윤달 > 2 (by harcoon) if (substr($arrayDATA[$i],$j,1) <= 2) { $m2++; $m1 = substr($arrayDATA[$i],$j,1) + 28; $gf_yun = 0; } else { $m1 = substr($arrayDATA[$i],$j,1) + 26; $gf_yun = 1; } if ($td <= $m1) { break; } $td = $td - $m1; } $k1=($ryear+6) % 10; $syuk = $arrayYUK[$k1]; $k2=($ryear+8) % 12; $sgap = $arrayGAP[$k2]; $sddi = $arrayDDI[$k2]; $gf_sol2lun = 1; return ($ryear."|".$m2."|".$td."|".$syuk.$sgap."년|".$sddi."띠"); } ?>