skin.board.diary/moonday.php

269 lines
9.6 KiB
PHP
Raw Permalink Normal View History

2024-10-18 11:18:51 +09:00
<?php
2024-10-18 11:25:52 +09:00
/**
* @author 대하 (https://extrashot.tistory.com/pages/Extra-Shot), phpschool 석봉운 (http://www.phpschool.com/bbs2/inc_view.html?id=9914&code=tnt2), Amber (https://info.drk.st/about)
*
* PHPschool의 석봉운님 오픈소스를 수정하여 사용하였습니다.
* 석봉운님께 감사드립니다.
* 주소 http://www.phpschool.com/bbs2/inc_view.html?id=9914&code=tnt2
*
* 음력 데이터는
* 작은 : 1
* 큰달 : 2
* 윤달이 있는 - 평달이 작고 윤달도 작으면 : 3
* 평달이 작고 윤달이 크면: 4
* 평달이 크고 윤달이 작으면 : 5
* 평달과 윤달이 모두 크면: 6
* @var int[] $kk
* @var int[] $md
*
* compatible php 5.3.x
2024-10-18 11:18:51 +09:00
*/
$kk = array (
2024-10-18 11:25:52 +09:00
//1841년 ~ 1900년
1,2,4,1,1,2,1,2,1,2,2,1, 2,2,1,2,1,1,2,1,2,1,2,1, 2,2,2,1,2,1,4,1,2,1,2,1, 2,2,1,2,1,2,1,2,1,2,1,2, 1,2,1,2,2,1,2,1,2,1,2,1,
2,1,2,1,5,2,1,2,2,1,2,1, 2,1,1,2,1,2,1,2,2,2,1,2, 1,2,1,1,2,1,2,1,2,2,2,1, 2,1,2,3,2,1,2,1,2,1,2,2, 2,1,2,1,1,2,1,1,2,2,1,2,
2,2,1,2,1,1,2,1,2,1,5,2, 2,1,2,2,1,1,2,1,2,1,1,2, 2,1,2,2,1,2,1,2,1,2,1,2, 1,2,1,2,1,2,5,2,1,2,1,2, 1,1,2,1,2,2,1,2,2,1,2,1,
2,1,1,2,1,2,1,2,2,2,1,2, 1,2,1,1,5,2,1,2,1,2,2,2, 1,2,1,1,2,1,1,2,2,1,2,2, 2,1,2,1,1,2,1,1,2,1,2,2, 2,1,6,1,1,2,1,1,2,1,2,2,
1,2,2,1,2,1,2,1,2,1,1,2, 2,1,2,1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1,2,1,1,5,2,1,2,2,2,1,
2,1,2,1,1,2,1,2,1,2,2,2, 1,2,1,2,1,1,2,1,1,2,2,2, 1,2,2,1,5,1,2,1,1,2,2,1, 2,2,1,2,2,1,1,2,1,1,2,2, 1,2,1,2,2,1,2,1,2,1,2,1,
2,1,5,2,1,2,2,1,2,1,2,1, 2,1,1,2,1,2,2,1,2,2,1,2, 1,2,1,1,2,1,5,2,2,2,1,2, 1,2,1,1,2,1,2,1,2,2,2,1, 2,1,2,1,1,2,1,1,2,2,1,2,
2,2,1,2,1,4,1,1,2,1,2,2, 2,2,1,2,1,1,2,1,1,2,1,2, 2,2,1,2,1,2,1,2,1,1,2,1, 2,2,1,2,5,2,1,2,1,2,1,1, 2,1,2,2,1,2,2,1,2,1,2,1,
2,1,1,2,1,2,2,1,2,2,1,2, 1,5,1,2,1,2,1,2,2,2,1,2, 1,2,1,1,2,1,1,2,2,1,2,2);
2024-10-18 11:18:51 +09:00
/*
2024-10-18 11:25:52 +09:00
$sy/ly :
$sm/lm :
$sd/ld :
$leapyes: 윤달
2024-10-18 11:18:51 +09:00
*/
2024-10-18 11:25:52 +09:00
$md = array(31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
function febdays($sy)
{
global $md;
if (($sy % 100 != 0 && $sy % 4 == 0) || $sy % 400 == 0)
$md[1] = 29;
else
$md[1] = 28;
return array($md[1]);
2024-10-18 11:18:51 +09:00
}
2024-10-18 11:25:52 +09:00
function alltd($sy)
{
global $md;
$td = 0;
$ttd = array();
for ($i = 1841; $i <= $sy - 1; $i++) {
$ttd[$i] = array();
$ttd[$i][12] = 0;
$feb_days = febdays($i);
$md[1] = $feb_days[0];
for ($j = 0; $j < 12; $j++) {
$td += $md[$j];
$ttd[$i][12] += $md[$j];
2024-10-18 11:18:51 +09:00
}
2024-10-18 11:25:52 +09:00
}
$td -= 22;
return array($td);
2024-10-18 11:18:51 +09:00
}
2024-10-18 11:25:52 +09:00
function soltolun($sy, $sm, $sd)
{
global $kk, $md;
$ly = 0;
$yoon = "";
2024-10-18 11:18:51 +09:00
2024-10-18 11:25:52 +09:00
$td_result = alltd($sy);
$td = $td_result[0];
$feb_days = febdays($sy);
$md[1] = $feb_days[0];
for ($i = 0; $i < $sm - 1; $i++)
$td += $md[$i];
$td += $sd;
$i = 0;
$temptd = $td;
while ($temptd > 0) {
$yoon = "";
switch ($kk[$i]) {
case 1:
$mm = 29;
break;
case 2:
$mm = 30;
break;
case 3:
$mm = 29;
$ymm = 29;
if ($temptd > 29) {
$temptd -= 29;
$yoon = "*";
2024-10-18 11:18:51 +09:00
}
2024-10-18 11:25:52 +09:00
break;
case 4:
$mm = 29;
$ymm = 30;
if ($temptd > 30) {
$temptd -= 30;
$yoon = "*";
}
break;
case 5:
$mm = 30;
$ymm = 29;
if ($temptd > 29) {
$temptd -= 29;
$yoon = "*";
}
break;
case 6:
$mm = 30;
$ymm = 30;
if ($temptd > 30) {
$temptd -= 30;
$yoon = "*";
}
break;
2024-10-18 11:18:51 +09:00
}
2024-10-18 11:25:52 +09:00
$temptd -= $mm;
$i++;
if ($i % 12 == 1)
$ly += 1;
}
if ($temptd <= 0) {
if ($yoon == "*")
$temptd += $ymm;
else
$temptd += $mm;
}
$ly += 1840;
$lm = $i % 12;
if ($lm == 0)
$lm = 12;
$ld = $temptd;
2024-10-18 11:18:51 +09:00
2024-10-18 11:25:52 +09:00
/* output */
$myarray = array(
"year" => $ly,
"month" => $lm,
"day" => $ld,
"leap" => $yoon
);
return $myarray;
2024-10-18 11:18:51 +09:00
}
2024-10-18 11:25:52 +09:00
function luntosol($ly, $lm, $ld, $leapyes = "")
{
global $kk, $md;
2024-10-18 11:18:51 +09:00
2024-10-18 11:25:52 +09:00
$temptd = 0;
$dm = ($ly - 1841) * 12 + ($lm - 1) - 1;
for ($i = $dm; $i >= 0; $i--) {
switch ($kk[$i]) {
case 1:
$temptd += 29;
break;
case 2:
$temptd += 30;
break;
case 3:
$temptd += 58;
break;
case 4:
case 5:
$temptd += 59;
break;
case 6:
$temptd += 60;
break;
2024-10-18 11:18:51 +09:00
}
2024-10-18 11:25:52 +09:00
}
$dm = ($ly - 1841) * 12 + ($lm) - 1;
if ($leapyes == "yoon") {
switch ($kk[$dm]) {
case 1:
case 2:
break;
case 3:
case 4:
$temptd += 29;
break;
case 5:
case 6:
$temptd += 30;
break;
2024-10-18 11:18:51 +09:00
}
2024-10-18 11:25:52 +09:00
}
2024-10-18 11:18:51 +09:00
2024-10-18 11:25:52 +09:00
$temptd += $ld;
$temptd += 22;
$td = $temptd;
$tempsy = 1841;
while (1) {
$feb_days = febdays($tempsy);
$md[1] = $feb_days[0];
for ($tempsm = 0; $tempsm <= 11; $tempsm++) {
$temptd -= $md[$tempsm];
if ($temptd <= 0)
break;
2024-10-18 11:18:51 +09:00
}
2024-10-18 11:25:52 +09:00
if ($temptd <= 0) {
$temptd += $md[$tempsm];
$tempsd = $temptd;
break;
}
$tempsy++;
}
2024-10-18 11:18:51 +09:00
2024-10-18 11:25:52 +09:00
$sy = $tempsy;
$sm = $tempsm + 1;
$sd = $tempsd;
2024-10-18 11:18:51 +09:00
2024-10-18 11:25:52 +09:00
/* output */
$myyarray = array(
"year" => $sy,
"month" => $sm,
"day" => $sd
);
return $myyarray;
2024-10-18 11:18:51 +09:00
}