Bug #15210 Updated: strtotime() doesn't work with ordinal suffixes

From: Date: Thu, 24 Jan 2002 22:25:52 +0000
Subject: Bug #15210 Updated: strtotime() doesn't work with ordinal suffixes
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-78044@lists.php.net to get a copy of this message
ID: 15210 Updated by: markonen Old Summary: strtotime() doesn't work with ordinal suffixes Reported By: basil.hussain@kodakweddings.com Old Status: Open Status: Closed Bug Type: Feature/Change Request Operating System: Linux 2.2.16enterprise PHP Version: 4.0.5 Assigned To: markonen New Comment: Feature added in CVS. Previous Comments: ------------------------------------------------------------------------ [2002-01-24 14:32:59] markonen@php.net Nah, wrong approach. Assigning to myself. ------------------------------------------------------------------------ [2002-01-24 14:16:25] markonen@php.net 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] derick@php.net Not a bug (it is not supposed to work), making it a feature request. Derick ------------------------------------------------------------------------ [2002-01-24 13:35:26] basil.hussain@kodakweddings.com 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

« previous php.dev (#78044) next »