Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.8.6

Bug #11073 date() %d validates \d{1,2} as correct
Submitted: 2007-05-18 14:52 UTC
From: epte Assigned: amir
Status: Closed Package: Validate (version 0.7.0)
PHP Version: 4.4.4 OS: linux
Roadmaps: 0.8.0    
Subscription  


 [2007-05-18 14:52 UTC] epte (Erich Enke)
Description: ------------ Simply, the %d format of the date() validation should only validate a two-digit day as true. However, 1 digit days also get validated as true. I would go after making a patch, but that _substr function is a bit cryptic, and could really use a leading comment. I didn't want to break anything. Bug #6034 was the similar thing for months, I'm assuming, but I didn't see one for days. Test script: --------------- $validate = new Validate(); echo $validate->date('2007-1-1', array('format' => '%Y-%m-%d')) ? 'True' : 'False'; echo "\n"; echo $validate->date('2007-1-01', array('format' => '%Y-%m-%d')) ? 'True' : 'False'; echo "\n"; echo $validate->date('2007-01-1', array('format' => '%Y-%m-%d')) ? 'True' : 'False'; echo "\n"; echo $validate->date('2007-01-01', array('format' => '%Y-%m-%d')) ? 'True' : 'False'; echo "\n"; Expected result: ---------------- False False False True Actual result: -------------- False False True True

Comments

 [2007-06-01 07:56 UTC] amir (Amir Mohammad Saied)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.