둘러보기 메뉴
검색
바뀐글
임의글
개인 도구
가입하기
로그인
모바일 환경 설정
도움말
도움말
질문게시판
자주 묻는 질문
커뮤니티
실시간 채팅방
가입인사게시판
자유게시판
뉴스게시판
제재안게시판
최근 토론
페미위키
공지사항
개선 요청
바뀐글
임의글
파일 올리기
다면 분류 목록
특수 문서 목록
모듈:Calendar 문서 원본 보기
이름공간
모듈
토론
주시
도구
여기를 가리키는 문서
가리키는 글의 최근 바뀜
문서 정보
위키베이스 항목
행위
보기
읽기
원본 보기
역사 보기
←
모듈:Calendar
문서 편집 권한이 없습니다. 다음 이유를 확인해주세요.
요청한 명령은 다음 중 하나의 권한을 가진 사용자에게 제한됩니다:
사용자
,
Seeders
.
문서를 고치려면 이메일 인증 절차가 필요합니다.
사용자 환경 설정
에서 이메일 주소를 입력하고 이메일 주소 인증을 해주시기 바랍니다.
문서의 원본을 보거나 복사할 수 있습니다.
local p = {} local function is_leap_year(year) return year % 4 == 0 and (year % 100 ~= 0 or year % 400 == 0) end local function get_days_in_month(year, month) if month == 2 and is_leap_year(year) then return 29 end local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} return days_in_month[month] end function p.tabular(frame) local year = frame.args.year + 0 local month = frame.args.month + 0 local previous_month = month - 1 if(previous_month<=0) then previous_month = previous_month + 12 end local next_month = month + 1 if(next_month >12) then next_month = next_month - 12 end local days = get_days_in_month(year, month) local first_day_of_week = os.date("*t", os.time{year=year,month=month,day=1})["wday"] local n_cells = first_day_of_week - 1 + days local n_trailing_cells = 7 - (n_cells % 7) -- Generate date cells local cells = {} -- 1. Prepend place holders if needed for i = 1, first_day_of_week - 1 do table.insert(cells, "X") end -- 2. Insert date cells for i = 1, days do table.insert(cells, i) end -- 3. Append place holders if needed for i = 1, n_trailing_cells do table.insert(cells, "X") end -- Render as a table local html = { '<table class="fw-calendar">\n', '<tr>', '<td colspan=\"2\" style=\'border-top: 0;border-left: 0;border-right: 0\'>' .. '[[' .. previous_month .. '월]]</td>', '<td colspan=\"3\" style=\'border-top: 0;border-left: 0;border-right: 0\'>' .. '[[' .. month .. '월|\'\'\'' .. month .. '월\'\'\']]</td>', '<td colspan=\"2\" style=\'border-top: 0;border-left: 0;border-right: 0\'>' .. '[[' .. next_month .. '월]]</td>', '</tr>\n', '<tr>', '<th class="sun">일</th>', '<th class="mon">월</th>', '<th class="tue">화</th>', '<th class="wed">수</th>', '<th class="thu">목</th>', '<th class="fri">금</th>', '<th class="sat">토</th>', '</tr>\n' } local day_names = {'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'} local index = 1 while cells[index] do table.insert(html, '<tr>') for i = 1, 7 do local cell = cells[index] local is_placeholder = cell == "X" if is_placeholder then table.insert(html, '<td class="placeholder ' .. day_names[i] .. '"> </td>') else table.insert(html, '<td class="' .. day_names[i] .. '">[[' .. month .. '월 ' .. cell .. '일|' .. cell .. ']]</td>') end index = index + 1 end table.insert(html, '</tr>\n') end table.insert(html, '</table>\n') return table.concat(html, "") end return p
이 문서에서 사용한 틀:
모듈:Calendar/설명문서
(
원본 보기
)
모듈:Calendar
문서로 돌아갑니다.
다른 언어