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

Bug #1236 bad regexp avoid format date
Submitted: 2004-04-18 09:46 UTC
From: chief at php dot net Assigned: pajoye
Status: No Feedback Package: Date
PHP Version: Irrelevant OS: n/a
Roadmaps: (Not assigned)    
Subscription  


 [2004-04-18 09:46 UTC] chief at php dot net
Description: ------------ I discovered that if you try to create new date with this format: $date = new Date('2003-07-15 22:53:37+01'); the current regexp doesn't match this. The correct regexop should be: preg_match('/^(\d{4})-?(\d{2})-?(\d{2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})(Z|[\+\-]\d{2}):?(\d{2})?)?$/i', $date, $regs) best regards, Radek here is a full patch: Index: Date.php =================================================================== RCS file: /repository/pear/Date/Date.php,v retrieving revision 1.27 diff -r1.27 Date.php 147c147 < preg_match('/^(\d{4})-?(\d{2})-?(\d{2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})(Z|[\+\-]\d{2}:?\d{2})?)?$/i', $date, $regs) --- > preg_match('/^(\d{4})-?(\d{2})-?(\d{2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})(Z|[\+\-]\d{2}):?(\d{2})?)?$/i', $date, $regs) 165a166,168 > if(isset($regs[9])) { > $regs[8] += ':'.$regs[9]; > }

Comments

 [2004-05-12 10:06 UTC] aashley at optimiser dot com
umm sorry if this seems obvious to you, but how is this considered a bug? The ISO8601 standard says that timezone offset must be represented by 4 digits if it is present. IMHO the bug is actually in whatever code is trying to load a date with that format.
 [2004-05-16 11:41 UTC] paj at pearfr dot org
Hello, Please point me to the RFC related to this format. If there is none I do not see the point to allow this format. --Pierre
 [2005-03-07 04:00 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!