﻿function g_isValidMonth(mm){var str=((typeof mm=="object")? mm.value:mm);var m=parseInt(str,10);return(m>=1&&m<=12)};function g_isValidDay(yyyy,mm,dd){var m=parseInt(mm,10)-1;var d=parseInt(dd,10);var end=[31,28,31,30,31,30,31,31,30,31,30,31];if((yyyy % 4==0&&yyyy % 100!=0)||yyyy % 400==0){end[1]=29};return(d>=1&&d<=end[m])};function g_isValidDate(obj){var str=((typeof obj=="object")? obj.value:obj);str=g_setReplace(str,"-","");var year=str.substr(0,4);var month=str.substr(4,2);var day=str.substr(6,2);return g_isValidDay(year,month,day)};function g_isValidHour(hh){var str=((typeof hh=="object")? hh.value:hh);var h=parseInt(str,10);return(h>=1&&h<=24)};function g_isValidMin(mi){var str=((typeof mi=="object")? mi.value:mi);var m=parseInt(str,10);return(m>=1&&m<=60)};function g_isValidTimeFormat(time){return(!isNaN(time)&&time.length==12)};function g_isValidTime(time){var str=((typeof time=="object")? time.value:time);var year=str.substring(0,4);var month=str.substring(4,6);var day=str.substring(6,8);var hour=str.substring(8,10);var min=str.substring(10,12);if(parseInt(year,10)>=1900&&g_isValidMonth(month)&&g_isValidDay(year,month,day)&&g_isValidHour(hour)&&g_isValidMin(min)){return true};return false};function g_isFutureTime(time){return(g_toTimeObject(time)>new Date())};function g_isPastTime(time){return(g_toTimeObject(time)<new Date())};function g_toTimeObject(time){var str=((typeof time=="object")? time.value:time);var year=str.substr(0,4);var month=str.substr(4,2)-1;var day=str.substr(6,2);var hour=str.substr(8,2);var min=str.substr(10,2);return new Date(year,month,day,hour,min)};function g_toTimeString(date){var str=date;var year=str.getFullYear();var month=str.getMonth()+1;var day=str.getDate();var hour=str.getHours();var min=str.getMinutes();if((""+month).length==1){month="0"+month};if((""+day).length==1){day="0"+day};if((""+hour).length==1){hour="0"+hour};if((""+min).length==1){min="0"+min};return(""+year+month+day+hour+min)};function g_getAddTime(time,y,m,d,h){var date=g_toTimeObject(time);date.setFullYear(date.getFullYear()+y);date.setMonth(date.getMonth()+m);date.setDate(date.getDate()+d);date.setHours(date.getHours()+h);return g_toTimeString(date)};function g_getAddMonth(time1,time2){var date1=g_toTimeObject(time1);var date2=g_toTimeObject(time2);var years=date2.getFullYear()-date1.getFullYear();var months=date2.getMonth()-date1.getMonth();var days=date2.getDate()-date1.getDate();return(years*12+months+(days>=0 ? 0:-1))};function g_getAddDay(time1,time2){var date1=g_toTimeObject(time1);var date2=g_toTimeObject(time2);var day=1000*3600*24;return parseInt((date2-date1)/ day,10)};function g_getAddmin(time1,time2){var date1=g_toTimeObject(time1);var date2=g_toTimeObject(time2);var min=1000*60;return parseInt((date2-date1)/ min,10)};function g_getAddHour(time1,time2){var date1=g_toTimeObject(time1);var date2=g_toTimeObject(time2);var hour=1000*3600;return parseInt((date2-date1)/ hour,10)};function g_getToDay(){var date=new Date();var year=date.getFullYear();var month=date.getMonth()+1; var day=date.getDate();if((""+month).length==1){month="0"+month};if((""+day).length==1){day="0"+day};return(""+year+month+day)};function g_getCurrentTime(){return g_toTimeString(new Date())};function g_getDiffTime(y,m,d,h){return g_getAddTime(getCurrentTime(),y,m,d,h)};function g_getYear(){return g_getCurrentTime().substr(0,4)};function g_getMonth(){return g_getCurrentTime().substr(4,2)};function g_getDay(){return g_getCurrentTime().substr(6,2)};function g_getHour(){return g_getCurrentTime().substr(8,2)};function g_getDate(sDate){var str=((typeof sDate=="object")? sDate.value:sDate);if(str=="")return"";var returnDate=str.substring(0,4)+"."+str.substring(4,6)+"."+str.substring(6,8);return returnDate};function g_getDate(sDate,sGubun){var str=((typeof sDate=="object")? sDate.value:sDate);if(str=="")return"";var returnDate=str.substring(0,4)+sGubun+str.substring(4,6)+sGubun+str.substring(6,8);return returnDate};function g_getEndDate(sDate){ if(g_isEmpty(sDate)){return null}; if(!g_isNum(sDate)){return null}; if(sDate.length!=6){return null};var str=((typeof sDate=="object")? sDate.value:sDate);var yy=Number(str.substring(0,4));var mm=Number(str.substring(4,6)); var boundDay="";if(mm!=2){var mon=[31,28,31,30,31,30,31,31,30,31,30,31];boundDay=mon[mm-1]}else{if(yy%4==0&&yy%100!=0||yy%400==0){boundDay=29}else{boundDay=28}};return boundDay};function g_getDayOfWeek(){var now=new Date();var day=now.getDay();var week=["SUN","MON","TUE","WED","THU","FRI","SAT"];return week[day]};function g_getDayOfWeek(time){var now=g_toTimeObject(time);var day=now.getDay();var week=["SUN","MON","TUE","WED","THU","FRI","SAT"];return week[day]};