//Javascript name: My Date Time Picker //Date created: 16-Nov-2003 23:19 //Scripter: TengYong Ng //Website: http://www.rainforestnet.com //Copyright (c) 2003 TengYong Ng //FileName: DateTimePicker.js //Version: 1.8.2 //Contact: contact@rainforestnet.com // Note: Permission given to use and modify this script in ANY kind of applications if // header lines are left unchanged. // // upgraded from version .8 in response to trouble ticket 8196 M. Bernaldo // // //Global variables var winCal; var dtToday=new Date(); var Cal; var YearName = [1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015] var MonthName=["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"]; var WeekDayName1=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; var WeekDayName2=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; var exDateTime;//Existing Date and Time var selDate;//selected date. version 1.7 //Configurable parameters var cnTop="200";//top coordinate of calendar window. var cnLeft="500";//left coordinate of calendar window var WindowTitle ="DateTime Picker";//Date Time Picker title. var WeekChar=2;//number of character for week day. if 2 then Mo,Tu,We. if 3 then Mon,Tue,Wed. var CellWidth=20;//Width of day cell. var DateSeparator="/";//Date Separator, you can change it to "/" if you want. var TimeMode=24;//default TimeMode value. 12 or 24 var ShowLongMonth=true;//Show long month name in Calendar header. example: "January". var ShowMonthYear=true;//Show Month and Year in Calendar header. var MonthYearColor="#cc0033";//Font Color of Month and Year in Calendar header. var WeekHeadColor="#0099CC";//Background Color in Week header. var SundayColor="#6699FF";//Background color of Sunday. var SaturdayColor="#CCCCFF";//Background color of Saturday. var WeekDayColor="white";//Background color of weekdays. var FontColor="blue";//color of font in Calendar day cell. var TodayColor="#FFFF33";//Background color of today. var SelDateColor="FFFF99";//Backgrond color of selected date in textbox. var YrSelColor="#cc0033";//color of font of Year selector. var MthSelColor="#cc0033";//color of font of Month selector if "MonthSelector" is "arrow". var ThemeBg="";//Background image of Calendar window. var PrecedeZero=true;//Preceding zero [true|false] var MondayFirstDay=false;//true:Use Monday as first day; false:Sunday as first day. [true|false] //added in version 1.7 //end Configurable parameters //end Global variable function NewCal(pCtrl,pFormat,pShowTime,pTimeMode,pScroller,pHideSeconds) { Cal=new Calendar(dtToday); if ((pShowTime!=null) && (pShowTime)) { Cal.ShowTime=true; if ((pTimeMode!=null) &&((pTimeMode=='12')||(pTimeMode=='24'))) { TimeMode=pTimeMode; } if ((pHideSeconds!=null)&&(pHideSeconds)) { Cal.ShowSeconds=false; } } if (pCtrl!=null) Cal.Ctrl=pCtrl; if (pFormat!=null) Cal.Format=pFormat.toUpperCase(); if (pScroller!=null) { if (pScroller.toUpperCase()=="ARROW") Cal.Scroller="ARROW"; else Cal.Scroller="DROPDOWN"; } exDateTime=document.getElementById(pCtrl).value; if (exDateTime!="")//Parse existing Date String { var Sp1;//Index of Date Separator 1 var Sp2;//Index of Date Separator 2 var tSp1;//Index of Time Separator 1 var tSp1;//Index of Time Separator 2 var strMonth; var strDate; var strYear; var intMonth; var YearPattern; var strHour; var strMinute; var strSecond; var winHeight; //parse month Sp1=exDateTime.indexOf(DateSeparator,0) Sp2=exDateTime.indexOf(DateSeparator,(parseInt(Sp1)+1)); var offset=parseInt(Cal.Format.toUpperCase().lastIndexOf("M"))-parseInt(Cal.Format.toUpperCase().indexOf("M"))-1; if ((Cal.Format.toUpperCase()=="DDMMYYYY") || (Cal.Format.toUpperCase()=="DDMMMYYYY")) { if (DateSeparator=="") { strMonth=exDateTime.substring(2,4+offset); strDate=exDateTime.substring(0,2); strYear=exDateTime.substring(4+offset,8+offset); } else { strMonth=exDateTime.substring(Sp1+1,Sp2); strDate=exDateTime.substring(0,Sp1); strYear=exDateTime.substring(Sp2+1,Sp2+5); } } else if ((Cal.Format.toUpperCase()=="MMDDYYYY") || (Cal.Format.toUpperCase()=="MMMDDYYYY")) { if (DateSeparator=="") { strMonth=exDateTime.substring(0,2+offset); strDate=exDateTime.substring(2+offset,4+offset); strYear=exDateTime.substring(4+offset,8+offset); } else { strMonth=exDateTime.substring(0,Sp1); strDate=exDateTime.substring(Sp1+1,Sp2); strYear=exDateTime.substring(Sp2+1,Sp2+5); } } else if ((Cal.Format.toUpperCase()=="YYYYMMDD") || (Cal.Format.toUpperCase()=="YYYYMMMDD")) { if (DateSeparator=="") { strMonth=exDateTime.substring(4,6+offset); strDate=exDateTime.substring(6+offset,8+offset); strYear=exDateTime.substring(0,4); } else { strMonth=exDateTime.substring(Sp1+1,Sp2); strDate=exDateTime.substring(Sp2+1,Sp2+3); strYear=exDateTime.substring(0,Sp1); } } if (isNaN(strMonth)) intMonth=Cal.GetMonthIndex(strMonth); else intMonth=parseInt(strMonth,10)-1; if ((parseInt(intMonth,10)>=0) && (parseInt(intMonth,10)<12)) Cal.Month=intMonth; //end parse month //parse Date if ((parseInt(strDate,10)<=Cal.GetMonDays()) && (parseInt(strDate,10)>=1)) Cal.Date=strDate; //end parse Date //parse year YearPattern=/^\d{4}$/; if (YearPattern.test(strYear)) Cal.Year=parseInt(strYear,10); //end parse year //parse time if (Cal.ShowTime==true) { //parse AM or PM if (TimeMode==12) { strAMPM=exDateTime.substring(exDateTime.length-2,exDateTime.length) Cal.AMorPM=strAMPM; } tSp1=exDateTime.indexOf(":",0) tSp2=exDateTime.indexOf(":",(parseInt(tSp1)+1)); if (tSp1>0) { strHour=exDateTime.substring(tSp1,(tSp1)-2); Cal.SetHour(strHour); strMinute=exDateTime.substring(tSp1+1,tSp1+3); Cal.SetMinute(strMinute); strSecond=exDateTime.substring(tSp2+1,tSp2+3); Cal.SetSecond(strSecond); } //window.status=strHour+":"+strMinute+":"+strSecond; } } selDate=new Date(Cal.Year,Cal.Month,Cal.Date);//version 1.7 winCal=window.open("","DateTimePicker","toolbar=0,status=0,menubar=0,width=200,height=200,resizable=0,top="+cnTop+",left="+cnLeft); RenderCal(); winCal.focus(); } function RenderCal() { var vCalHeader; var vCalData; var vCalTime; var i; var j; var SelectStr; var vDayCount=0; var vFirstDay; winCal.document.open(); winCal.document.writeln("