ID: 15210
Updated by: markonen
Old Summary: strtotime() doesn't work with ordinal suffixes
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Feature/Change Request
Operating System: Linux 2.2.16enterprise
PHP Version: 4.0.5
Old Assigned To:
Assigned To: markonen
New Comment:
Nah, wrong approach. Assigning to myself.
Previous Comments:
------------------------------------------------------------------------
[2002-01-24 14:16:25] [EMAIL PROTECTED]
Could someone sanity check this patch?
diff -c -r1.29 parsedate.y
*** parsedate.y 2 Dec 2001 11:35:28 -0000 1.29
--- parsedate.y 24 Jan 2002 19:14:52 -0000
***************
*** 721,726 ****
--- 721,740 ----
int i;
int abbrev;
+ /* Strip ordinal suffixes from dates */
+ if ((strlen (buff) == 3 || strlen (buff) == 4) &&
ISDIGIT(buff[0])) {
+ i = strlen (buff) - 2;
+ if (buff[i] == 's' && buff[i+1] == 't') {
+ buff[i] = '\0';
+ } else if (buff[i] == 'n' && buff[i+1] == 'd') {
+ buff[i] = '\0';
+ } else if (buff[i] == 'r' && buff[i+1] == 'd') {
+ buff[i] = '\0';
+ } else if (buff[i] == 't' && buff[i+1] == 'h') {
+ buff[i] = '\0';
+ }
+ }
+
/* Make it lowercase. */
for (p = buff; *p; p++)
if (ISUPPER ((unsigned char) *p))
------------------------------------------------------------------------
[2002-01-24 13:44:21] [EMAIL PROTECTED]
Not a bug (it is not supposed to work), making it a feature request.
Derick
------------------------------------------------------------------------
[2002-01-24 13:35:26] [EMAIL PROTECTED]
PHP does not correctly parse ordinal date suffixes in the strtotime()
function. For example:
<?php
echo strtotime("10th August 2002");
echo strtotime("22nd January 1998");
echo strtotime("November 3rd 1980");
?>
They will all fail, returning -1.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=15210&edit=1
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]