[-] CORE: Fix regex for isDate and isDateFormat (0000-00-00 00:00:00 is now allowed)

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9471 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vSchoener
2011-10-19 15:22:11 +00:00
parent 2a22c9a502
commit eb9654e1ea
+2 -2
View File
@@ -428,7 +428,7 @@ class ValidateCore
*/
public static function isDateFormat($date)
{
return (bool)preg_match('/^([0-9]{4})-((0?[0-9])|(1[0-2]))-((0?[1-9])|([0-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date);
return (bool)preg_match('/^([0-9]{4})-((0?[0-9])|(1[0-2]))-((0?[0-9])|([1-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date);
}
/**
@@ -439,7 +439,7 @@ class ValidateCore
*/
public static function isDate($date)
{
if (!preg_match('/^([0-9]{4})-((0?[1-9])|(1[0-2]))-((0?[1-9])|([1-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date, $matches))
if (!preg_match('/^([0-9]{4})-((0?[0-9])|(1[0-2]))-((0?[0-9])|([1-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date, $matches))
return false;
return checkdate((int)$matches[2], (int)$matches[5], (int)$matches[0]);
}