전체, 1개월,1주일,3개월,6개월,1년,2년...
해서 달력 초기값 세팅하는 것 만들어 봤는데,
좀 지저분하군요..
//상세검색 달력세팅
function setCalendar(val,mode){
var form = document.search;
if (val=='all')
{
form.fromdate.value="";
form.todate.value="";
}else {
var year = "";
var month = "";
var day = "";
var searchDay1 = "";
var searchDay2 = "";
var nTerm = 0;
var nNextMonth = 0;
var EndDayarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
fromDate = new Date();
toDate = new Date();
year = toDate.getYear();
month = toDate.getMonth()+1;
day = toDate.getDate();
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) EndDayarr[1] = "29";
//from 초기값
/*nTerm = ( 7*24*60*60*1000);
var tempDate = fromDate.getTime() - nTerm;
fromDate.setTime(tempDate);
*/
year = fromDate.getYear();
month = fromDate.getMonth() +1;
day = fromDate.getDate();
if (val=='1w'){
nTerm = ( 7*24*60*60*1000);
} else if (val=='2w'){
nTerm = ( 14*24*60*60*1000);
}else if (val=='1m') {
nTerm = ( EndDayarr[month-1]*24*60*60*1000);
}else if (val=='3m'){
for (i=0; i<3 ;i++ )
{
if (month+i>12){
nNextMonth = (month+i)%12 -1;
} else {
nNextMonth = month+i-1;
}
nTerm += (EndDayarr[nNextMonth]*24*60*60*1000);
}
}else if (val=='6m') {
for (i=0; i<6 ;i++ )
{
if (month+i>12){
nNextMonth = (month+i)%12 -1;
} else {
nNextMonth = month+i-1;
}
nTerm += (EndDayarr[nNextMonth]*24*60*60*1000);
}
}else if (val=='1y') {
for (i=0; i<12 ;i++ )
{
if (month+i>12){
nNextMonth = (month+i)%12 -1;
} else {
nNextMonth = month+i-1;
}
nTerm += (EndDayarr[nNextMonth]*24*60*60*1000);
}
}else if (val=='2y') {
nTerm = (730*24*60*60*1000);
}
if (mode=='bef')
{
tempDate = toDate.getTime() - nTerm;
}
else if (mode=='aft')
{
tempDate = toDate.getTime() + nTerm;
}
toDate.setTime(tempDate);
if (month<10) month = '0'+month;
if (day<10) day ='0'+day;
searchDay1 = year + "-" + month + "-" + day;
year = toDate.getYear();
month = toDate.getMonth() +1;
day = toDate.getDate();
if (month<10) month = '0'+month;
if (day<10) day ='0'+day;
searchDay2 = year + "-" + month + "-" + day;
if (mode=='bef')
{
form.fromdate.value = searchDay2;
form.todate.value = searchDay1;
}
else if (mode=='aft')
{
form.fromdate.value = searchDay1;
form.todate.value = searchDay2;
}
}
// goSearchDetail();
}
eWEEK 랩 선정 ''2008년 가장 영향력 큰 기술 10선'' (0) | 2008.04.22 |
---|---|
문자 메시지 실패에도 왜 과금되는가? (0) | 2008.04.21 |
문자열 검색하기 (0) | 2007.12.27 |
CPU, MEM 정보 구하기 (0) | 2007.12.11 |
VC++ 헤더 및 라이브러리 설명 (0) | 2007.12.05 |