diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 13a645117c9..0a02613a674 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -797,6 +797,14 @@ PHP_RSHUTDOWN_FUNCTION(date) #define DATE_FORMAT_ISO8601 "Y-m-d\\TH:i:sO" +/* + * This comes from various sources that like to contradict. I'm going with the + * format here because of: + * http://msdn.microsoft.com/en-us/library/windows/desktop/aa384321%28v=vs.85%29.aspx + * and http://curl.haxx.se/rfc/cookie_spec.html + */ +#define DATE_FORMAT_COOKIE "l, d-M-Y H:i:s T" + #define DATE_TZ_ERRMSG \ "It is not safe to rely on the system's timezone settings. You are " \ "*required* to use the date.timezone setting or the " \ @@ -827,7 +835,7 @@ PHP_MINIT_FUNCTION(date) * with the variations that the only legal time zone is GMT * and the separators between the elements of the date must be dashes." */ - REGISTER_STRING_CONSTANT("DATE_COOKIE", DATE_FORMAT_RFC850, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("DATE_COOKIE", DATE_FORMAT_COOKIE, CONST_CS | CONST_PERSISTENT); REGISTER_STRING_CONSTANT("DATE_ISO8601", DATE_FORMAT_ISO8601, CONST_CS | CONST_PERSISTENT); REGISTER_STRING_CONSTANT("DATE_RFC822", DATE_FORMAT_RFC822, CONST_CS | CONST_PERSISTENT); REGISTER_STRING_CONSTANT("DATE_RFC850", DATE_FORMAT_RFC850, CONST_CS | CONST_PERSISTENT); @@ -2002,7 +2010,7 @@ static void date_register_classes(TSRMLS_D) zend_declare_class_constant_stringl(date_ce_date, const_name, sizeof(const_name)-1, value, sizeof(value)-1 TSRMLS_CC); REGISTER_DATE_CLASS_CONST_STRING("ATOM", DATE_FORMAT_RFC3339); - REGISTER_DATE_CLASS_CONST_STRING("COOKIE", DATE_FORMAT_RFC850); + REGISTER_DATE_CLASS_CONST_STRING("COOKIE", DATE_FORMAT_COOKIE); REGISTER_DATE_CLASS_CONST_STRING("ISO8601", DATE_FORMAT_ISO8601); REGISTER_DATE_CLASS_CONST_STRING("RFC822", DATE_FORMAT_RFC822); REGISTER_DATE_CLASS_CONST_STRING("RFC850", DATE_FORMAT_RFC850); diff --git a/ext/date/tests/DateTime_format_basic2.phpt b/ext/date/tests/DateTime_format_basic2.phpt index d7adaa5df88..016fa7b6b28 100644 --- a/ext/date/tests/DateTime_format_basic2.phpt +++ b/ext/date/tests/DateTime_format_basic2.phpt @@ -31,7 +31,7 @@ var_dump( $date->format( DateTime::W3C) ) ; --EXPECT-- *** Testing date_format() : basic functionality - formatting coinstants *** string(25) "2005-07-14T22:30:41+01:00" -string(32) "Thursday, 14-Jul-05 22:30:41 BST" +string(34) "Thursday, 14-Jul-2005 22:30:41 BST" string(24) "2005-07-14T22:30:41+0100" string(29) "Thu, 14 Jul 05 22:30:41 +0100" string(32) "Thursday, 14-Jul-05 22:30:41 BST" diff --git a/ext/date/tests/DateTime_verify.phpt b/ext/date/tests/DateTime_verify.phpt index a03911f5c82..c7909747292 100644 --- a/ext/date/tests/DateTime_verify.phpt +++ b/ext/date/tests/DateTime_verify.phpt @@ -160,7 +160,7 @@ array(11) { ["ATOM"]=> string(13) "Y-m-d\TH:i:sP" ["COOKIE"]=> - string(16) "l, d-M-y H:i:s T" + string(16) "l, d-M-Y H:i:s T" ["ISO8601"]=> string(13) "Y-m-d\TH:i:sO" ["RFC822"]=> @@ -180,4 +180,4 @@ array(11) { ["W3C"]=> string(13) "Y-m-d\TH:i:sP" } -===DONE=== \ No newline at end of file +===DONE=== diff --git a/ext/date/tests/bug52063.phpt b/ext/date/tests/bug52063.phpt index af9da9e429d..7364a806122 100644 --- a/ext/date/tests/bug52063.phpt +++ b/ext/date/tests/bug52063.phpt @@ -11,5 +11,5 @@ echo $a->format(DateTime::COOKIE); echo "\n"; ?> --EXPECTF-- -Thursday, 01-Jan-09 00:00:00 WET -Thursday, 01-Jan-09 00:00:00 WET +Thursday, 01-Jan-2009 00:00:00 WET +Thursday, 01-Jan-2009 00:00:00 WET diff --git a/ext/date/tests/bug53879.phpt b/ext/date/tests/bug53879.phpt new file mode 100644 index 00000000000..64c0f18fefd --- /dev/null +++ b/ext/date/tests/bug53879.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #53879 (DateTime::createFromFormat() fails to parse cookie expiration date) +--FILE-- + +--EXPECTF-- +DateTime Object +( + [date] => 2041-01-21 15:24:52 + [timezone_type] => 2 + [timezone] => GMT +) diff --git a/ext/date/tests/date_constants.phpt b/ext/date/tests/date_constants.phpt index 132e24159bf..b9fce8c78bd 100644 --- a/ext/date/tests/date_constants.phpt +++ b/ext/date/tests/date_constants.phpt @@ -41,8 +41,8 @@ Date constants --EXPECT-- string(25) "2006-07-01T14:27:30+02:00" string(25) "2006-05-30T14:32:13+02:00" -string(33) "Saturday, 01-Jul-06 14:27:30 CEST" -string(32) "Tuesday, 30-May-06 14:32:13 CEST" +string(35) "Saturday, 01-Jul-2006 14:27:30 CEST" +string(34) "Tuesday, 30-May-2006 14:32:13 CEST" string(24) "2006-07-01T14:27:30+0200" string(24) "2006-05-30T14:32:13+0200" string(29) "Sat, 01 Jul 06 14:27:30 +0200" diff --git a/ext/date/tests/gmdate_variation13.phpt b/ext/date/tests/gmdate_variation13.phpt index 5a19ae268e0..1d1f434ecee 100644 --- a/ext/date/tests/gmdate_variation13.phpt +++ b/ext/date/tests/gmdate_variation13.phpt @@ -45,7 +45,7 @@ string(25) "2008-08-08T08:08:08+00:00" string(%d) "%s" --DATE_COOKIE Constant-- -string(30) "Friday, 08-Aug-08 08:08:08 GMT" +string(32) "Friday, 08-Aug-2008 08:08:08 GMT" string(%d) "%s" --DATE_RFC822 Constant-- @@ -79,4 +79,4 @@ string(%d) "%s" --DATE_W3C Constant-- string(25) "2008-08-08T08:08:08+00:00" string(%d) "%s" -===DONE=== \ No newline at end of file +===DONE=== diff --git a/ext/date/tests/test-parse-from-format.phpt b/ext/date/tests/test-parse-from-format.phpt index 2bf9c4e1b82..5bb5fe53256 100644 --- a/ext/date/tests/test-parse-from-format.phpt +++ b/ext/date/tests/test-parse-from-format.phpt @@ -32,8 +32,8 @@ object(DateTime)#2 (3) { string(6) "+02:00" } -string(16) "l, d-M-y H:i:s T" -string(36) "Tuesday, 08-Jul-08 22:14:12 GMT+0200" +string(16) "l, d-M-Y H:i:s T" +string(38) "Tuesday, 08-Jul-2008 22:14:12 GMT+0200" object(DateTime)#1 (3) { ["date"]=> string(19) "2008-07-08 22:14:12"