PageSourceSearch

https://www.unitedcollective.org/sysfiles/member/check_date.js

js unitedcollective.org collected 2026-09-28 17:16:50 UTC 4,273 bytes, 193 lines download raw bytes

1function _CF_checkdate(object_value)
2    {
3    //Returns true if value is a date format or is NULL
4    //otherwise returns false	
5
6    if (object_value.length == 0)
7        return true;
8
9    //Returns true if value is a date in the mm/dd/yyyy format
10	isplit = object_value.indexOf('/');
11
12	if (isplit == -1 || isplit == object_value.length)
13		return false;
14
15    sMonth = object_value.substring(0, isplit);
16
17	if (sMonth.length == 0)
18        return false;
19
20	isplit = object_value.indexOf('/', isplit + 1);
21
22	if (isplit == -1 || (isplit + 1 ) == object_value.length)
23		return false;
24
25    sDay = object_value.substring((sMonth.length + 1), isplit);
26
27	if (sDay.length == 0)
28        return false;
29
30	sYear = object_value.substring(isplit + 1);
31
32	if (!_CF_checkinteger(sMonth)) //check month
33		return false;
34	else
35	if (!_CF_checkrange(sMonth, 1, 12)) //check month
36		return false;
37	else
38	if (!_CF_checkinteger(sYear)) //check year
39		return false;
40	else
41	if (!_CF_checkrange(sYear, 0, 9999)) //check year
42		return false;
43	else
44	if (!_CF_checkinteger(sDay)) //check day
45		return false;
46	else
47	if (!_CF_checkday(sYear, sMonth, sDay)) // check day
48		return false;
49	else
50		return true;
51    }
52
53function _CF_checkday(checkYear, checkMonth, checkDay)
54    {
55
56	maxDay = 31;
57
58	if (checkMonth == 4 || checkMonth == 6 ||
59			checkMonth == 9 || checkMonth == 11)
60		maxDay = 30;
61	else
62	if (checkMonth == 2)
63	{
64		if (checkYear % 4 > 0)
65			maxDay =28;
66		else
67		if (checkYear % 100 == 0 && checkYear % 400 > 0)
68			maxDay = 28;
69		else
70			maxDay = 29;
71	}
72
73	return _CF_checkrange(checkDay, 1, maxDay); //check day
74}
75
76function _CF_checkinteger(object_value)
77    {
78    //Returns true if value is a number or is NULL
79    //otherwise returns false	
80
81    if (object_value.length == 0)
82        return true;
83
84    //Returns true if value is an integer defined as
85    //   having an optional leading + or -.
86    //   otherwise containing only the characters 0-9.
87	var decimal_format = ".";
88	var check_char;
89
90    //The first character can be + -  blank or a digit.
91	check_char = object_value.indexOf(decimal_format)
92    //Was it a decimal?
93    if (check_char < 1)
94	return _CF_checknumber(object_value);
95    else
96	return false;
97    }
98
99function _CF_numberrange(object_value, min_value, max_value)
100    {
101    // check minimum
102    if (min_value != null)
103	{
104        if (object_value < min_value)
105		return false;
106	}
107
108    // check maximum
109    if (max_value != null)
110	{
111	if (object_value > max_value)
112		return false;
113	}
114	
115    //All tests passed, so...
116    return true;
117}
118
119function _CF_checknumber(object_value)
120    {
121    //Returns true if value is a number or is NULL
122    //otherwise returns false	
123
124    if (object_value.length == 0)
125        return true;
126
127    //Returns true if value is a number defined as
128    //   having an optional leading + or -.
129    //   having at most 1 decimal point.
130    //   otherwise containing only the characters 0-9.
131	var start_format = " .+-0123456789";
132	var number_format = " .0123456789";
133	var check_char;
134	var decimal = false;
135	var trailing_blank = false;
136	var digits = false;
137
138    //The first character can be + - .  blank or a digit.
139	check_char = start_format.indexOf(object_value.charAt(0))
140    //Was it a decimal?
141	if (check_char == 1)
142	    decimal = true;
143	else if (check_char < 1)
144		return false;
145        
146	//Remaining characters can be only . or a digit, but only one decimal.
147	for (var i = 1; i < object_value.length; i++)
148	{
149		check_char = number_format.indexOf(object_value.charAt(i))
150		if (check_char < 0)
151			return false;
152		else if (check_char == 1)
153		{
154			if (decimal)		// Second decimal.
155				return false;
156			else
157				decimal = true;
158		}
159		else if (check_char == 0)
160		{
161			if (decimal || digits)	
162				trailing_blank = true;
163        // ignore leading blanks
164
165		}
166	        else if (trailing_blank)
167			return false;
168		else
169			digits = true;
170	}	
171    //All tests passed, so...
172    return true
173}
174
175function _CF_checkrange(object_value, min_value, max_value)
176    {
177    //if value is in range then return true else return false
178
179    if (object_value.length == 0)
180        return true;
181
182    if (!_CF_checknumber(object_value))
183	{
184	return false;
185	}
186    else
187	{
188	return (_CF_numberrange((eval(object_value)), min_value, max_value));
189	}
190	
191    //All tests passed, so...
192    return true;
193}

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.