{@ $link_path = getUrl('','mid',$mid,'dummy',1)} {@ $XE_path = getUrl('')} {@ $today_bgcolor=yellow} {@ $day_bgcolor=aliceblue} {@ $day_bgcolor=beige} link_path; $xepath = $__Context->XE_path; $skinpath = $tpl_path; // 스킨 설치 경로지정 //echo $linkpath; //echo $skinpath; ?> 3 ) { $pOption=1; // 간지옵션 } ?> 0 && $pYear % 4 == 0) || $pYear % 400 == 0) { $fn_leapmonth = true; } else { $fn_leapmonth = false; } return $fn_leapmonth; // 또는 단순히 date()를 이용 하거나....("L" : 윤년여부 윤년엔 1, 그 외엔 0) // return date("L", mktime(0, 0, 0, $pMonth, 1, $pYear)); } //-------------------------------------------------------------------------------- /** * @function: fn_monthcount($pYear,$pMonth) * @return : integer * @brief: 해당월의 마지막 일을 반환한다 **/ function fn_monthcount($pYear,$pMonth) { $aMonthNum = explode("-","31-0-31-30-31-30-31-31-30-31-30-31-"); //2월달은 예외 if (fn_leapmonth($pYear)) { $aMonthNum[1] = 29; } else { $aMonthNum[1] = 28; } // return $aMonthNum; return $aMonthNum[$pMonth-1]; // 또는 단순히 date()를 이용 하거나....("t" : 주어진 월의 일수) // return date("t", mktime(0, 0, 0, $pMonth, 1, $pYear)); } //-------------------------------------------------------------------------------- /** * @function: fn_firstweek($pYear,$pMonth) * @return : integer * @brief: 해당년/월의 첫번째일의 위치를 반환 ("w" : 0=일요일, 6=토요일) **/ function fn_firstweek($pYear,$pMonth) { return date("w", mktime(0, 0, 0,$pMonth, 1, $pYear)); } //-------------------------------------------------------------------------------- /** * @function: fn_nowweek($pYear,$pMonth,$pDay) * @return : integer * @brief: 해당년/월/일의 요일 위치를 반환 ("w" : 0=일요일, 6=토요일) **/ function fn_nowweek($pYear,$pMonth,$pDay) { return date("w", mktime(0, 0, 0,$pMonth, $pDay, $pYear)); } //------------------------------------------------------------------------------ /** * @function: fn_lastweek($pYear,$pMonth) * @return : integer * @brief: 해당년/월의 마지막날 위치를 반환 ("w" : 0=일요일, 6=토요일) **/ function fn_lastweek($pYear,$pMonth) { return date("w", mktime(0, 0, 0,$pMonth, fn_monthcount($pYear,$pMonth), $pYear)); } //----------------------------------------------------------------------------------- /** * @function: fn_blankweekfirst($pYear,$pMonth) * @return : integer * @brief: 해당년/월의 첫번째주 빈값을 구한다. * @brief: 해당 년/월의 일수시작이 수요일(3) 이라면 일(0)/월(1)/화(2) 즉 3개는 빈값이다. **/ function fn_blankweekfirst($pYear,$pMonth) { return fn_firstweek($pYear,$pMonth); } //-------------------------------------------------------------------------------------- /** * @function: fn_blankweeklast($pYear,$pMonth) * @return : integer * @brief: 해당년/월의 마지막주 빈값을 구한다. * @brief: 해당 년/월의 일수끝이 목요일(4) 이라면 금(5)/토(6) 즉 2개는 빈값이다. **/ function fn_blankweeklast($pYear,$pMonth) { return 6 - fn_lastweek($pYear,$pMonth); } //-------------------------------------------------------------------------------------- /** * @function: fn_weekcountofmonth($pYear,$pMonth,$pDay) * @return : integer * @brief: 해당 년/월/일이 당월 몇번째 주에 해당 되는지를 구한다. * @brief: 해당 년/월/일이 당월 2번째 주에 포함된다면 2를 반환. **/ function fn_weekcountofmonth($pYear,$pMonth,$pDay) { $wrkday = $pDay + date("w", mktime(0, 0, 0,$pMonth, 1, $pYear)); //1일의 요일번호(일=0, 토=6) $weekcount = floor($wrkday/7); //소숫점이하 절사 if ( $wrkday % 7 > 0 ) { $weekcount = $weekcount + 1; } return $weekcount; // n번째 주 } //-------------------------------------------------------------------------------------- /** * @function: fn_weekdaycountofmonth($pYear,$pMonth,$pDay) * @return : integer * @brief: 해당 년/월/일의 요일이 당월 몇번째 요일에 해당되는지 구한다. * @brief: 해당 년/월/일의 요일이 당월 2번째요일 이면 2를 반환. **/ function fn_weekdaycountofmonth($pYear,$pMonth,$pDay) { $k=0; // 카운터 $pYoil = date("w", mktime(0, 0, 0,$pMonth, $pDay, $pYear)); //해당일의 요일번호(일=0, 토=6) for ($i=1; $i<=$pDay; $i++) { // 1일 부터 말일까지 수행 $wrk1 = date("w", mktime(0, 0, 0,$pMonth, $i, $pYear)); if ($wrk1 == $pYoil) { // 요일 일치 $k=$k+1; } } return $k; // n번째 요일 } //-------------------------------------------------------------------------------------- /** * @function: fn_nsweekday($pYear, $pMonth, $pCount, $pYoil) * @return : string * @brief: 해당년/월 n번째 x요일의 일자를 구한다 * @brief: pCount: 숫자, pYoil: 숫자 (일요일(0) ... 토요일(6)). **/ function fn_nsweekday($pYear, $pMonth, $pCount, $pYoil) { $k=0; // 카운터 $j = date("t", mktime(0, 0, 0, $pMonth, 1, $pYear)); // 해당월의 날자수(말일) 값 for ($i=1; $i<=$j; $i++) { // 1일 부터 말일까지 수행 $wrk1 = date("w", mktime(0, 0, 0,$pMonth, $i, $pYear)); if ($wrk1 == $pYoil) { // 요일 일치 $k=$k+1; if ($k == $pCount) { // 횟수 일치 $wrkYmd =date("Y-n-j", mktime(0, 0, 0,$pMonth, $i, $pYear)); } } } return $wrkYmd; } //-------------------------------------------------------------------------------------- /** * @function: fn_nsweeknsweekday($pYear, $pMonth, $pCount, $pYoil) * @return : string * @brief: 해당년/월 n번째 주 x요일의 일자를 구한다 * @brief: pCount: 숫자, pYoil: 숫자 (일요일(0) ... 토요일(6)). **/ function fn_nsweeknsweekday($pYear, $pMonth, $pCount, $pYoil) { $k=1; // 주 카운터 $j = date("t", mktime(0, 0, 0, $pMonth, 1, $pYear)); // 해당월의 날자수(말일) 값 for ($i=1; $i<=$j; $i++) { // 1일 부터 말일까지 수행 $wrk1 = date("w", mktime(0, 0, 0,$pMonth, $i, $pYear)); // 요일 if ($i != 1 && $wrk1==0) { // 첫날이 아니면서 일요일 이면 주 카운터 증가 $k = $k + 1; } if ($wrk1 == $pYoil) { // 요일 일치 if ($k == $pCount) { // 횟수 일치 $wrkYmd =date("Y-n-j", mktime(0, 0, 0,$pMonth, $i, $pYear)); } } } return $wrkYmd; } //-------------------------------------------------------------------------------------- /** * @function: fn_nslastweekday($pYear, $pMonth, $pCount, $pYoil) * @return : string * @brief: 해당년/월 끝에서 n번째 x요일의 일자를 구한다 * @brief: pCount: 숫자, pYoil: 숫자 (일요일(0) ... 토요일(6)). **/ function fn_nslastweekday($pYear, $pMonth, $pCount, $pYoil) { $k=0; // 주 카운터 $j = date("t", mktime(0, 0, 0, $pMonth, 1, $pYear)); // 해당월의 날자수(말일) 값 for ($i=$j; $i>=1; $i--) { // 말일 부터 1일까지 수행 $wrk1 = date("w", mktime(0, 0, 0,$pMonth, $i, $pYear)); // 요일 if ($wrk1 == $pYoil) { // 요일 일치 $k = $k + 1; if ($k == $pCount) { // 횟수 일치 $wrkYmd =date("Y-n-j", mktime(0, 0, 0,$pMonth, $i, $pYear)); } } } return $wrkYmd; } //-------------------------------------------------------------------------------- /** * @function: fn_CalMain($pYear,$pMonth) * @return : array * @brief: 주어진 년/월의 달력을 만든다. * @brief: 2차원배열을 사용하여 틀을 만든다. * @brief: 가로(1주)는 무조건 7이 되므로 세로값만 알면 된다. * @brief: 빈칸은 null 값으로한다 * @brief: 형태예제 * @brief: |일|월|화|수|목|금|토| * @brief: | n| n| n| n| n| n| 1| * @brief: | 2| 3| 4| 5| 6| 7| 8| * @brief: | 9|10|11|12|13|14|15| * @brief: |16|17|18|19|20|21|22| * @brief: |23|24|25|26|27|28|29| * @brief: |30|31| n| n| n| n| n| **/ function fn_CalMain($pYear,$pMonth) { //$aCal[][]; //달력의 틀을 위한 2차원배열 //$intVertical; //세로줄값 //$intWeekcnt; //주일수 //$i; //$j; //$k; //루프전체 합 //$intDay; //일수 값 //초기값 셋팅 $k=0; $intDay=1; //일 //세로값얻는 방법 (그달의 일수 + 첫째주빈값 + 마지막주빈값)/7=세로값 $intVertical = (fn_monthcount($pYear,$pMonth)+fn_blankweekfirst($pYear,$pMonth)+fn_blankweeklast($pYear,$pMonth))/7; $intWeekcnt = 7; //배열셋팅 // array[세로사이즈][가로사이즈] $aCal[$intVertical][$intWeekcnt]; //배열에 값 삽입 for ($i=0; $i<$intVertical; $i++ ) { for ($j=0; $j<$intWeekcnt; $j++ ){ $k=$k+1; //k의값이 첫번째주 빈값보다 작거나 같을경우는 *을 삽입 if ($k<=fn_blankweekfirst($pYear,$pMonth)) { $aCal[$i][$j] = "*"; } //k의값이 첫번째주빈값이상이며, 일자가 해당월의 마지막 일자 값과 작거나같을경우는 일수를 삽입 else { if ($intDay<=fn_monthcount($pYear,$pMonth)) { $aCal[$i][$j] = $intDay; $intDay = $intDay+1; } //이외의 값은 *로 채운다 else { $aCal[$i][$j] = "*"; } } } } return $aCal; } //-------------------------------------------------------------------------------------- /** * @function: fn_smallcalendar() * @return : string * @brief: 소형 당월 칼런다 HTML코드 출력 * @brief: **/ function fn_smallcalendar(){ $year = date("Y"); $month = date("n"); $day = date("d"); $day_max = date("t",mktime(0,0,0,$month,1,$year)); $week_start = date("w",mktime(0,0,0,$month,1,$year)); $i = 0; $j = 0; $html = "
| Sun | Mon | Tue | Wed | Thu | Fri | Sat | bgcolor="{$today_bgcolor}" bgcolor="{$day_bgcolor}" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#ddfffa'">
| \n");
}
echo ("\n");
}
?>
|---|