cvs: pear /Validate Validate.php
| From: | Pierre-Alain Joye | Date: | Tue, 11 Jun 2002 11:01:58 +0000 |
| Subject: | cvs: pear /Validate Validate.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4543@lists.php.net to get a copy of this message | ||
pajoye Tue Jun 11 07:01:58 2002 EDT
Modified files:
/pear/Validate Validate.php
Log:
Fix bugs with year between year 1 and year 1000
Fix the min and max dates interval
Fix bug with minutes or seconds >59
Index: pear/Validate/Validate.php
diff -u pear/Validate/Validate.php:1.17 pear/Validate/Validate.php:1.18
--- pear/Validate/Validate.php:1.17 Sun Jun 9 12:06:57 2002
+++ pear/Validate/Validate.php Tue Jun 11 07:01:55 2002
@@ -18,7 +18,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Validate.php,v 1.17 2002/06/09 16:06:57 cox Exp $
+// $Id: Validate.php,v 1.18 2002/06/11 11:01:55 pajoye Exp $
//
// Methods for common data validations
//
@@ -180,6 +180,7 @@
if (is_array($date)) {
extract($date);
}
+ $date_len = strlen($format);
for ($i = 0; $i < strlen($format); $i++) {
$c = $format{$i};
if ($c == '%') {
@@ -210,7 +211,8 @@
case 'Y':
case 'y':
if ($next == 'Y') {
- $year = (int)Validate::_substr($date, 4);
+ $year = Validate::_substr($date, 4);
+ $year = (int)$year?$year:'';
} else {
$year = (int)(substr(date('Y'), 0, 2) .
Validate::_substr($date, 2));
@@ -244,7 +246,7 @@
case 's':
case 'i':
$t = Validate::_substr($date, 2);
- if ($t < 0 || $t > 60) {
+ if ($t < 0 || $t > 59) {
return false;
}
break;
@@ -255,7 +257,7 @@
} else {
//literal
if (Validate::_substr($date, 1) != $c) {
- return false;
+ //return false;
}
}
}
@@ -270,13 +272,13 @@
}
if ($min &&
(Date_Calc::compareDates($day, $month, $year,
- $min[0], $min[1], $min[2]) > 0))
+ $min[0], $min[1], $min[2]) < 0))
{
return false;
}
if ($max &&
(Date_Calc::compareDates($day, $month, $year,
- $max[0], $max[1], $max[2]) < 0))
+ $max[0], $max[1], $max[2]) > 0))
{
return false;
}
@@ -345,4 +347,4 @@
return $valid;
}
}
-?>
\ No newline at end of file
+?>