1// Title: Tigra Calendar 2// URL: http://www.softcomplex.com/products/tigra_calendar/ 3// Version: 3.2 (American date format) 4// Date: 10/14/2002 (mm/dd/yyyy) 5// Note: Permission given to use this script in ANY kind of applications if 6// header lines are left unchanged. 7// Note: Script consists of two files: calendar?.js and calendar.html 8 9// if two digit year input dates after this year considered 20 century. 10var NUM_CENTYEAR = 30; 11// is time input control required by default 12var BUL_TIMECOMPONENT = false; 13// are year scrolling buttons required by default 14var BUL_YEARSCROLL = true; 15 16var calendars = []; 17var RE_NUM = /^\-?\d+$/; 18 19function calendar2(obj_target) { 20 21 // assigning methods 22 this.gen_date = cal_gen_date2; 23 this.gen_time = cal_gen_time2; 24 this.gen_tsmp = cal_gen_tsmp2; 25 this.prs_date = cal_prs_date2; 26 this.prs_time = cal_prs_time2; 27 this.prs_tsmp = cal_prs_tsmp2; 28 this.popup = cal_popup2; 29 30 // validate input parameters 31 if (!obj_target) 32 return cal_error("Error calling the calendar: no target control specified"); 33 if (obj_target.value == null) 34 return cal_error("Error calling the calendar: parameter specified is not valid target control"); 35 this.target = obj_target; 36 this.time_comp = BUL_TIMECOMPONENT; 37 this.year_scroll = BUL_YEARSCROLL; 38 39 // register in global collections 40 this.id = calendars.length; 41 calendars[this.id] = this; 42} 43 44function cal_popup2 (str_datetime) { 45 this.dt_current = this.prs_tsmp(str_datetime ? str_datetime : this.target.value); 46 if (!this.dt_current) return; 47 48 var obj_calwindow = window.open( 49 '/scripts/calendar/calendar.html?datetime=' + this.dt_current.valueOf()+ '&id=' + this.id, 50 'Calendar', 'width=200,height='+(this.time_comp ? 215 : 190)+ 51 ',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes' 52 ); 53 obj_calwindow.opener = window; 54 obj_calwindow.focus(); 55} 56 57// timestamp generating function 58function cal_gen_tsmp2 (dt_datetime) { 59 return(this.gen_date(dt_datetime) + ' ' + this.gen_time(dt_datetime)); 60} 61 62// date generating function 63function cal_gen_date2 (dt_datetime) { 64 return ( 65 (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "/" 66 + (dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "/" 67 + dt_datetime.getFullYear() 68 ); 69} 70// time generating function 71function cal_gen_time2 (dt_datetime) { 72 var hours = dt_datetime.getHours(); 73 if (hours >= 12) { 74 ampm = "PM"; 75 if (hours > 12) hours = hours - 12; 76 } else { 77 ampm = "AM"; 78 if (hours < 10) hours = "0" + hours; 79 } 80 81 return (hours + ":" 82 + (dt_datetime.getMinutes() < 10 ? '0' : '') + (dt_datetime.getMinutes()) + " " + ampm 83 ); 84} 85 86// timestamp parsing function 87function cal_prs_tsmp2 (str_datetime) { 88 // if no parameter specified return current timestamp 89 if (!str_datetime) 90 return (new Date()); 91 92 // if positive integer treat as milliseconds from epoch 93 if (RE_NUM.exec(str_datetime)) 94 return new Date(str_datetime); 95 96 // else treat as date in string format 97 var arr_datetime = str_datetime.split(' '); 98 return this.prs_time(arr_datetime[1], this.prs_date(arr_datetime[0])); 99} 100 101// date parsing function 102function cal_prs_date2 (str_date) { 103 104 var arr_date = str_date.split('/'); 105 106 if (arr_date.length != 3) return alert ("Invalid date format: '" + str_date + "'.\nFormat accepted is dd-mm-yyyy."); 107 if (!arr_date[1]) return alert ("Invalid date format: '" + str_date + "'.\nNo day of month value can be found."); 108 if (!RE_NUM.exec(arr_date[1])) return alert ("Invalid day of month value: '" + arr_date[1] + "'.\nAllowed values are unsigned integers."); 109 if (!arr_date[0]) return alert ("Invalid date format: '" + str_date + "'.\nNo month value can be found."); 110 if (!RE_NUM.exec(arr_date[0])) return alert ("Invalid month value: '" + arr_date[0] + "'.\nAllowed values are unsigned integers."); 111 if (!arr_date[2]) return alert ("Invalid date format: '" + str_date + "'.\nNo year value can be found."); 112 if (!RE_NUM.exec(arr_date[2])) return alert ("Invalid year value: '" + arr_date[2] + "'.\nAllowed values are unsigned integers."); 113 114 var dt_date = new Date(); 115 dt_date.setDate(1); 116 117 if (arr_date[0] < 1 || arr_date[0] > 12) return alert ("Invalid month value: '" + arr_date[0] + "'.\nAllowed range is 01-12."); 118 dt_date.setMonth(arr_date[0]-1); 119 120 if (arr_date[2] < 100) arr_date[2] = Number(arr_date[2]) + (arr_date[2] < NUM_CENTYEAR ? 2000 : 1900); 121 dt_date.setFullYear(arr_date[2]); 122 123 var dt_numdays = new Date(arr_date[2], arr_date[0], 0); 124 dt_date.setDate(arr_date[1]); 125 if (dt_date.getMonth() != (arr_date[0]-1)) return alert ("Invalid day of month value: '" + arr_date[1] + "'.\nAllowed range is 01-"+dt_numdays.getDate()+"."); 126 127 return (dt_date) 128} 129 130// time parsing function 131function cal_prs_time2 (str_time, dt_date) { 132 return dt_date; 133 134 if (!dt_date) return null; 135 var arr_time = String(str_time ? str_time : '').split(':'); 136 137 if (!arr_time[0]) dt_date.setHours(0);
138 else if (RE_NUM.exec(arr_time[0])) 139 if (arr_time[0] < 24) dt_date.setHours(arr_time[0]); 140 else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed range is 00-12."); 141 else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed values are unsigned integers."); 142 143 if (!arr_time[1]) dt_date.setMinutes(0); 144 else if (RE_NUM.exec(arr_time[1])) 145 if (arr_time[1] < 60) dt_date.setMinutes(arr_time[1]); 146 else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed range is 00-59."); 147 else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed values are unsigned integers."); 148 149 if (!arr_time[2]) dt_date.setSeconds(0); 150 else if (RE_NUM.exec(arr_time[2])) 151 if (arr_time[2] < 60) dt_date.setSeconds(arr_time[2]); 152 else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed range is 00-59."); 153 else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed values are unsigned integers."); 154 155 dt_date.setMilliseconds(0); 156 return dt_date; 157} 158 159function cal_error (str_message) { 160 alert (str_message); 161 return null; 162}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.