function show_calendar(str_datetime) { tmpAId = ''; var arr_months = ["Yanvar", "Fevral", "Mart", "Aprel", "May", "İyun", "İyul", "Avqust", "Sentyabr", "Oktyabr", "Noyabr", "Dekabr"]; // var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]; var n_weekstart = 1; // day week starts from (normally 0 or 1) var fer_date = new Date(); var fer_mn = fer_date.getMonth(); var fer_yr = fer_date.getFullYear(); var from_day = '22'; var from_mn = '10'; var from_yr = '2006'; var dt_datetime = (str_datetime == null || str_datetime =="" ? new Date() : str2dt(str_datetime)); var dt_prev_month = new Date(dt_datetime); dt_prev_month.setMonth(dt_datetime.getMonth()-1); var dt_next_month = new Date(dt_datetime); dt_next_month.setMonth(dt_datetime.getMonth()+1); var dt_firstday = new Date(dt_datetime); dt_firstday.setDate(1); dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7); var dt_lastday = new Date(dt_next_month); dt_lastday.setDate(0); // html generation (feel free to tune it for your particular application) // print calendar header var dt_current_day = new Date(dt_firstday); var str_buffer = "
\n"+ "\n"+ "\n"; // print calendar table while (dt_current_day.getMonth() == dt_datetime.getMonth() || dt_current_day.getMonth() == dt_firstday.getMonth()) { // print row heder str_buffer += "\n"; for (var n_current_wday=0; n_current_wday<7; n_current_wday++) { if (dt_current_day.getDate() == dt_datetime.getDate() && fer_mn == dt_datetime.getMonth()) // print current date str_buffer += " \n"; dt_current_day.setDate(dt_current_day.getDate()+1); } // print row footer str_buffer += "\n"; } // print calendar footer str_buffer += "
   "; if (from_mn == dt_datetime.getMonth() && from_yr == dt_datetime.getFullYear()) { } else { str_buffer += "\n"; } str_buffer += ""+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"\n"+ ""; if (fer_mn == dt_datetime.getMonth() && fer_yr == dt_datetime.getFullYear()) { }else { str_buffer += ""; } str_buffer += "
B.eÇ.aÇC.aCŞВ
"; else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6) // weekend days str_buffer += " "; else // print working days of current month str_buffer += " "; if ( (dt_datetime.getDate() < dt_current_day.getDate() && fer_mn == dt_datetime.getMonth() && fer_yr == dt_datetime.getFullYear() ) || ( dt_current_day.getDate() < from_day && from_mn == dt_datetime.getMonth() && from_yr == dt_datetime.getFullYear() ) ) str_buffer += "
"; else if (dt_current_day.getMonth() == dt_datetime.getMonth()) // print days of current month var tey_day; var tey_moth; if (dt_current_day.getDate()<10) { tey_day="0"+dt_current_day.getDate(); } else { tey_day=dt_current_day.getDate(); } if (eval(dt_current_day.getMonth()+1)<10) { tey_moth="0"+(eval(dt_current_day.getMonth()+1)); } else { tey_moth=(eval(dt_current_day.getMonth()+1)); } if ((n_current_wday==5) || (n_current_wday==6)) { str_buffer += ""; } else { str_buffer += ""; } // else // // print days of other months // str_buffer += ""; if (dt_current_day.getMonth() == dt_datetime.getMonth()) str_buffer += dt_current_day.getDate(); else str_buffer += " "; if ( (dt_datetime.getDate() < dt_current_day.getDate() && fer_mn == dt_datetime.getMonth() ) || ( dt_current_day.getDate() < from_day && from_mn == dt_datetime.getMonth()) ) str_buffer += "
"; else if (dt_current_day.getMonth() == dt_datetime.getMonth()) str_buffer += ""; str_buffer += "
"; document.getElementById('t_calendar').innerHTML = str_buffer; } // datetime parsing and formatting routimes. modify them if you wish other datetime format function str2dt(str_datetime) { var re_date = /^(\d+)\-(\d+)\-(\d+)$/; if (!re_date.exec(str_datetime)) return alert("Invalid Date format: "+ str_datetime); return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6)); } function dt2dtstr(dt_datetime) { return (new String ( dt_datetime.getDate()+"-"+(dt_datetime.getMonth()+1)+"-"+dt_datetime.getFullYear()+"")); } function dt2tmstr(dt_datetime) { return (new String ( dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds())); } show_calendar();