var nowDate = new Date(); var class_uno; function showCalendar(date,class_uno,class_id,textdate) { var destDate = getCalendarStringToDate(date); getCalendarTags(destDate,class_uno,class_id,textdate); } function getCalendarStringToDate(strDate) { var di = new Array("-", ".", ","); var returnDate = new Date(); var arrDate; for(var i = 0 ; i < di.length; i++){ arrDate = strDate.split(di[i]); if(arrDate.length ==3){ returnDate.setYear(arrDate[0]); returnDate.setMonth(arrDate[1] - 1); returnDate.setDate(arrDate[2]); break; } } if(!isNaN(strDate) && strDate.length ==8) { returnDate.setYear(strDate.substring(0,4)); returnDate.setMonth(strDate.substring(4,6) -1); returnDate.setDate(strDate.substring(6)); } return returnDate; } function getCalendarFirstDateOfWeek(tDate) { var sunDay = new Date(); var firstDateOfMonth = new Date(); firstDateOfMonth.setYear(tDate.getUTCFullYear()); firstDateOfMonth.setMonth(tDate.getMonth()); firstDateOfMonth.setDate(1); sunDay.setTime(dayPlus(firstDateOfMonth, firstDateOfMonth.getDay() * -1)); return sunDay; } function dayPlus(tDate,cnt) { var rtnDate = new Date(); rtnDate.setTime(tDate.getTime() + ( cnt * 24 * 60 * 60 * 1000 ) ); return rtnDate; } function getCalendarLastDate(tDate) { rtnDate = getMonthLastDay(tDate) rtnDate = dayPlus(rtnDate,6 - rtnDate.getDay()) return rtnDate; } function getMonthLastDay(tDate) { var Mon2 var rtnDate = new Date(); var arrLastDay = new Array(31,29,31,30,31,30,31,31,30,31,30,31); if(tDate.getYear() % 4 ==0) Mon2 = true; else Mon2 =false; arrLastDay[1] = (Mon2) ? 29 : 28; rtnDate.setYear(tDate.getUTCFullYear()); rtnDate.setMonth(tDate.getMonth()); rtnDate.setDate(arrLastDay[tDate.getMonth()]); return rtnDate; } function getCalendarTags(destDate,class_uno,class_id,textdate) { var arrLastDay = new Array(31,29,31,30,31,30,31,31,30,31,30,31); var strTag = ''; var destYear = destDate.getUTCFullYear(); var destMonth = destDate.getMonth() + 1; var destDay = destDate.getDate(); var startDate = getCalendarFirstDateOfWeek(destDate); var endDate = getCalendarLastDate(destDate); var preYear = destYear - 1; var preMonth = destMonth - 1; var nextYear = destYear + 1; var nextMonth = destMonth + 1; if(preMonth <10) { preMonth = "0" + preMonth; } if(nextMonth <10) { nextMonth = "0" + nextMonth; } if(destDay <10) { destDay = "0" + destDay; } var preYear_value = preYear + '-' + destMonth + '-' + destDay; if(destMonth == 1) { var preMonth_value = preYear + '-12' + '-' + destDay; } else { var preMonth_value = destYear + '-' + preMonth + '-' + destDay; } var nextYear_value = nextYear + '-' + destMonth + '-' + destDay; if(destMonth == 12) { var nextMonth_value = nextYear + '-01' + '-' + destDay; } else { var nextMonth_value = destYear + '-' + nextMonth + '-' + destDay; } var pDate = new Date(); pDate = startDate; strTag = "
" + destYear + "." + destMonth + "
"; strTag += "
"; strTag += " "; strTag += " "; strTag += " "; strTag += " "; s_num = 1; while(pDate <= endDate) { y = pDate.getFullYear(); m = pDate.getMonth() + 1; d = pDate.getDate(); ed = arrLastDay[nowDate.getMonth()]; if(s_num < d || s_num > d) { date_title = ' '; } else { date_title = pDate.getDate(); s_num ++; } if(m <10) { m = "0" + m; } if(d <10) { d = "0" + d; } d_value = y + '-' + m + '-' + d; if(pDate.getFullYear() == nowDate.getFullYear() && pDate.getDate() == nowDate.getDate() && pDate.getMonth() == nowDate.getMonth()) { var todayclass = "today"; } else if(pDate.getFullYear() == destDate.getFullYear() && pDate.getDate() == destDate.getDate() && pDate.getMonth() == destDate.getMonth()) { var todayclass = "targetday"; } else { var todayclass = ""; if(textdate[d_value] == 'Y') { todayclass = "textday"; } } switch(pDate.getDay()) { case 0: //ÀÏ¿äÀÏÀ̸é strTag += " "; strTag += " "; break; case 6: //Åä¿äÀÏÀ̸é strTag += " "; strTag += " "; break; default: strTag += " "; break; } pDate = dayPlus(pDate, 1); //ÇÏ·ç ´õÇÑ´Ù } strTag += "
"; strTag += " "; strTag += " "; strTag += " "; strTag += " "; strTag += " "; strTag += " "; strTag += " "; strTag += " "; strTag += " "; strTag += " "; strTag += "
ÀÏ¿ùÈ­¼ö¸ñ±ÝÅä
"; strTag += "
" + date_title + "" + date_title + "
" + date_title + "
"; strTag += "
"; document.write(strTag); }