cvs: php4 /pear/Date Calc.php
| From: | Pierre-Alain Joye | Date: | Tue, 11 Jun 2002 14:53:27 +0000 |
| Subject: | cvs: php4 /pear/Date Calc.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4555@lists.php.net to get a copy of this message | ||
pajoye Tue Jun 11 10:53:27 2002 EDT
Modified files:
/php4/pear/Date Calc.php
Log:
Remove regexp and months checks and use the native php function checkdate()
Keep year check, only 4 digits allowed
Index: php4/pear/Date/Calc.php
diff -u php4/pear/Date/Calc.php:1.20 php4/pear/Date/Calc.php:1.21
--- php4/pear/Date/Calc.php:1.20 Thu Jun 6 07:45:12 2002
+++ php4/pear/Date/Calc.php Tue Jun 11 10:53:27 2002
@@ -62,27 +62,12 @@
function isValidDate($day, $month, $year)
{
-
- if(empty($year) || empty($month) || empty($day))
- return false;
-
- // must be digits only
- if(preg_match("/\D/",$year))
- return false;
- if(preg_match("/\D/",$month))
- return false;
- if(preg_match("/\D/",$day))
- return false;
-
if($year < 0 || $year > 9999)
return false;
- if($month < 1 || $month > 12)
- return false;
- if($day < 1 || $day > 31 || $day > Date_Calc::daysInMonth($month,$year))
+ if(!checkdate($day,$month,$year))
return false;
return true;
-
} // end func isValidDate
function isLeapYear($year="")
@@ -805,7 +790,6 @@
return 30;
else
return 31;
-
} // end func daysInMonth
/**
@@ -1196,7 +1180,7 @@
floor(( 1461 * $year) / 4 ) +
floor(( 153 * $month + 2) / 5 ) +
$day + 1721119);
-
+ // 17 November 185
} // end func dateToDays
/**
@@ -1595,4 +1579,4 @@
} // end class Date_calendar
-?>
\ No newline at end of file
+?>