derick          Tue May 30 13:12:21 2006 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/date/tests     bug37616.phpt date_constants.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/date   php_date.c 
  Log:
  - MFH: Fixed bug #37616: DATE_RFC822 does not product RFC 822 dates. (Patch by
    Hannes Magnusson)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.547.2.63&r2=1.2027.2.547.2.64&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.63 php-src/NEWS:1.2027.2.547.2.64
--- php-src/NEWS:1.2027.2.547.2.63      Mon May 29 20:07:39 2006
+++ php-src/NEWS        Tue May 30 13:12:21 2006
@@ -48,6 +48,8 @@
 - Fixed memory leaks in openssl streams context options (Pierre)
 - Fixed handling of extremely long paths inside tempnam() function. (Ilia)
 - Fixed bug #37632 (Protected method access problem). (Marcus)
+- Fixed bug #37616: DATE_RFC822 does not product RFC 822 dates. (Hannes
+  Magnusson, Derick)
 - Fixed bug #37620 (mysqli_ssl_set validation is innappropriate). (Georg)
 - Fixed bug #37614 (Class name lowercased in error message). (Johannes)
 - Fixed bug #37587 (var without attribute causes segfault). (Marcus)
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/php_date.c?r1=1.43.2.45.2.3&r2=1.43.2.45.2.4&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.45.2.3 
php-src/ext/date/php_date.c:1.43.2.45.2.4
--- php-src/ext/date/php_date.c:1.43.2.45.2.3   Sun May 14 17:35:56 2006
+++ php-src/ext/date/php_date.c Tue May 30 13:12:21 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_date.c,v 1.43.2.45.2.3 2006/05/14 17:35:56 derick Exp $ */
+/* $Id: php_date.c,v 1.43.2.45.2.4 2006/05/30 13:12:21 derick Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -237,11 +237,87 @@
 
 #define DATE_TIMEZONEDB      php_date_global_timezone_db ? 
php_date_global_timezone_db : timelib_builtin_db()
 
+/*
+ * RFC822, Section 5.1: http://www.ietf.org/rfc/rfc822.txt
+ *  date-time   =  [ day "," ] date time        ; dd mm yy hh:mm:ss zzz
+ *  day         =  "Mon"  / "Tue" /  "Wed"  / "Thu"  /  "Fri"  / "Sat" /  "Sun"
+ *  date        =  1*2DIGIT month 2DIGIT        ; day month year e.g. 20 Jun 82
+ *  month       =  "Jan"  /  "Feb" /  "Mar"  /  "Apr"  /  "May"  /  "Jun" /  
"Jul"  /  "Aug"  /  "Sep"  /  "Oct" /  "Nov"  /  "Dec"
+ *  time        =  hour zone                    ; ANSI and Military
+ *  hour        =  2DIGIT ":" 2DIGIT [":" 2DIGIT] ; 00:00:00 - 23:59:59
+ *  zone        =  "UT"  / "GMT"  /  "EST" / "EDT"  /  "CST" / "CDT"  /  "MST" 
/ "MDT"  /  "PST" / "PDT"  /  1ALPHA  / ( ("+" / "-") 4DIGIT )
+ */
+#define DATE_FORMAT_RFC822   "D, d M y H:i:s O"
+
+/*
+ * RFC850, Section 2.1.4: http://www.ietf.org/rfc/rfc850.txt
+ *  Format must be acceptable both to the ARPANET and to the getdate routine.
+ *  One format that is acceptable to both is Weekday, DD-Mon-YY HH:MM:SS 
TIMEZONE
+ *  TIMEZONE can be any timezone name (3 or more letters)
+ */
+#define DATE_FORMAT_RFC850   "l, d-M-y H:i:s T"
+
+/*
+ * RFC1036, Section 2.1.2: http://www.ietf.org/rfc/rfc1036.txt
+ *  Its format must be acceptable both in RFC-822 and to the getdate(3)
+ *  Wdy, DD Mon YY HH:MM:SS TIMEZONE
+ *  There is no hope of having a complete list of timezones.  Universal
+ *  Time (GMT), the North American timezones (PST, PDT, MST, MDT, CST,
+ *  CDT, EST, EDT) and the +/-hhmm offset specifed in RFC-822 should be 
supported.
+ */
+#define DATE_FORMAT_RFC1036  "D, d M y H:i:s O"
+
+/*
+ * RFC1123, Section 5.2.14: http://www.ietf.org/rfc/rfc1123.txt
+ *  RFC-822 Date and Time Specification: RFC-822 Section 5
+ *  The syntax for the date is hereby changed to: date = 1*2DIGIT month 
2*4DIGIT
+ */
+#define DATE_FORMAT_RFC1123  "D, d M Y H:i:s O"
+
+/*
+ * RFC2822, Section 3.3: http://www.ietf.org/rfc/rfc2822.txt
+ *  FWS             =       ([*WSP CRLF] 1*WSP) /   ; Folding white space
+ *  CFWS            =       *([FWS] comment) (([FWS] comment) / FWS)
+ *  
+ *  date-time       =       [ day-of-week "," ] date FWS time [CFWS]
+ *  day-of-week     =       ([FWS] day-name)
+ *  day-name        =       "Mon" / "Tue" / "Wed" / "Thu" / "Fri" / "Sat" / 
"Sun"
+ *  date            =       day month year
+ *  year            =       4*DIGIT
+ *  month           =       (FWS month-name FWS)
+ *  month-name      =       "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 
"Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"
+ *  day             =       ([FWS] 1*2DIGIT)
+ *  time            =       time-of-day FWS zone
+ *  time-of-day     =       hour ":" minute [ ":" second ]
+ *  hour            =       2DIGIT
+ *  minute          =       2DIGIT
+ *  second          =       2DIGIT
+ *  zone            =       (( "+" / "-" ) 4DIGIT)
+ */
+#define DATE_FORMAT_RFC2822  "D, d M Y H:i:s O"
+/*
+ * RFC3339, Section 5.6: http://www.ietf.org/rfc/rfc3339.txt
+ *  date-fullyear   = 4DIGIT
+ *  date-month      = 2DIGIT  ; 01-12
+ *  date-mday       = 2DIGIT  ; 01-28, 01-29, 01-30, 01-31 based on month/year
+ *  
+ *  time-hour       = 2DIGIT  ; 00-23
+ *  time-minute     = 2DIGIT  ; 00-59
+ *  time-second     = 2DIGIT  ; 00-58, 00-59, 00-60 based on leap second rules
+ *  
+ *  time-secfrac    = "." 1*DIGIT
+ *  time-numoffset  = ("+" / "-") time-hour ":" time-minute
+ *  time-offset     = "Z" / time-numoffset
+ *  
+ *  partial-time    = time-hour ":" time-minute ":" time-second [time-secfrac]
+ *  full-date       = date-fullyear "-" date-month "-" date-mday
+ *  full-time       = partial-time time-offset
+ *  
+ *  date-time       = full-date "T" full-time
+ */
 #define DATE_FORMAT_RFC3339  "Y-m-d\\TH:i:sP"
+
 #define DATE_FORMAT_ISO8601  "Y-m-d\\TH:i:sO"
-#define DATE_FORMAT_RFC1036  "l, d-M-y H:i:s T"
-#define DATE_FORMAT_RFC1123  "D, d M Y H:i:s T"
-#define DATE_FORMAT_RFC2822  "D, d M Y H:i:s O"
 
 #define DATE_TZ_ERRMSG \
        "It is not safe to rely on the system's timezone settings. Please use " 
\
@@ -266,8 +342,8 @@
        REGISTER_STRING_CONSTANT("DATE_ATOM",    DATE_FORMAT_RFC3339, CONST_CS 
| CONST_PERSISTENT);
        REGISTER_STRING_CONSTANT("DATE_COOKIE",  DATE_FORMAT_RFC1123, CONST_CS 
| CONST_PERSISTENT);
        REGISTER_STRING_CONSTANT("DATE_ISO8601", DATE_FORMAT_ISO8601, CONST_CS 
| CONST_PERSISTENT);
-       REGISTER_STRING_CONSTANT("DATE_RFC822",  DATE_FORMAT_RFC1123, CONST_CS 
| CONST_PERSISTENT);
-       REGISTER_STRING_CONSTANT("DATE_RFC850",  DATE_FORMAT_RFC1036, 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);
        REGISTER_STRING_CONSTANT("DATE_RFC1036", DATE_FORMAT_RFC1036, CONST_CS 
| CONST_PERSISTENT);
        REGISTER_STRING_CONSTANT("DATE_RFC1123", DATE_FORMAT_RFC1123, CONST_CS 
| CONST_PERSISTENT);
        REGISTER_STRING_CONSTANT("DATE_RFC2822", DATE_FORMAT_RFC2822, CONST_CS 
| CONST_PERSISTENT);
@@ -1211,14 +1287,14 @@
        REGISTER_DATE_CLASS_CONST_STRING("ATOM",    DATE_FORMAT_RFC3339);
        REGISTER_DATE_CLASS_CONST_STRING("COOKIE",  DATE_FORMAT_RFC1123);
        REGISTER_DATE_CLASS_CONST_STRING("ISO8601", DATE_FORMAT_ISO8601);
-       REGISTER_DATE_CLASS_CONST_STRING("RFC822",  DATE_FORMAT_RFC1123);
-       REGISTER_DATE_CLASS_CONST_STRING("RFC850",  DATE_FORMAT_RFC1036);
+       REGISTER_DATE_CLASS_CONST_STRING("RFC822",  DATE_FORMAT_RFC822);
+       REGISTER_DATE_CLASS_CONST_STRING("RFC850",  DATE_FORMAT_RFC850);
        REGISTER_DATE_CLASS_CONST_STRING("RFC1036", DATE_FORMAT_RFC1036);
        REGISTER_DATE_CLASS_CONST_STRING("RFC1123", DATE_FORMAT_RFC1123);
        REGISTER_DATE_CLASS_CONST_STRING("RFC2822", DATE_FORMAT_RFC2822);
        REGISTER_DATE_CLASS_CONST_STRING("RFC3339", DATE_FORMAT_RFC3339);
        REGISTER_DATE_CLASS_CONST_STRING("RSS",     DATE_FORMAT_RFC1123);
-       REGISTER_DATE_CLASS_CONST_STRING("W3C",     DATE_FORMAT_ISO8601);
+       REGISTER_DATE_CLASS_CONST_STRING("W3C",     DATE_FORMAT_RFC3339);
 
 
        INIT_CLASS_ENTRY(ce_timezone, "timezone", date_funcs_timezone);

http://cvs.php.net/viewcvs.cgi/php-src/ext/date/tests/bug37616.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/bug37616.phpt
+++ php-src/ext/date/tests/bug37616.phpt
<code><span style="color: #000000">
--TEST--<br 
/>Bug&nbsp;#37616&nbsp;(DATE_RFC822&nbsp;does&nbsp;not&nbsp;product&nbsp;RFC&nbsp;822&nbsp;dates)<br
 />--FILE--<br /><span style="color: #0000BB">&lt;?php<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;date_default_timezone_set</span><span style="color: 
#007700">(</span><span style="color: #DD0000">"Europe/Oslo"</span><span 
style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span 
style="color: #0000BB">var_dump</span><span style="color: 
#007700">(</span><span style="color: #0000BB">date</span><span style="color: 
#007700">(</span><span style="color: #0000BB">DATE_RFC822</span><span 
style="color: #007700">,&nbsp;</span><span style="color: 
#0000BB">strtotime</span><span style="color: #007700">(</span><span 
style="color: 
#DD0000">"1&nbsp;Jul&nbsp;06&nbsp;14:27:30&nbsp;+0200"</span><span 
style="color: #007700">)));<br /></span><span style="color: #0000BB">?&gt;<br 
/></span>--EXPECT--<br 
/>string(29)&nbsp;"Sat,&nbsp;01&nbsp;Jul&nbsp;06&nbsp;14:27:30&nbsp;+0200"<br 
/></span>
</code>
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/tests/date_constants.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/date_constants.phpt
+++ php-src/ext/date/tests/date_constants.phpt
<code><span style="color: #000000">
--TEST--<br />Date&nbsp;constants<br />--FILE--<br /><span style="color: 
#0000BB">&lt;?php<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;date_default_timezone_set</span><span style="color: 
#007700">(</span><span style="color: #DD0000">"Europe/Oslo"</span><span 
style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span 
style="color: #0000BB">$constants&nbsp;</span><span style="color: 
#007700">=&nbsp;array(<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#0000BB">DATE_ATOM</span><span style="color: #007700">,<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#0000BB">DATE_COOKIE</span><span style="color: #007700">,<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#0000BB">DATE_ISO8601</span><span style="color: #007700">,<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#0000BB">DATE_RFC822</span><span style="color: #007700">,<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n!
 bsp;&nbsp;&nbsp;</span><span style="color: #0000BB">DATE_RFC850</span><span 
style="color: #007700">,<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#0000BB">DATE_RFC1036</span><span style="color: #007700">,<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#0000BB">DATE_RFC1123</span><span style="color: #007700">,<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#0000BB">DATE_RFC2822</span><span style="color: #007700">,<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#0000BB">DATE_RSS</span><span style="color: #007700">,<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#0000BB">DATE_W3C<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;foreach(</span><span style="color: 
#0000BB">$constants&nbsp;</span><span style="color: #007700">as&nbsp;</span!
 ><span style="color: #0000BB">$const</span><span style="color: #007700
">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span 
style="color: #0000BB">var_dump</span><span style="color: 
#007700">(</span><span style="color: #0000BB">date</span><span style="color: 
#007700">(</span><span style="color: #0000BB">$const</span><span style="color: 
#007700">,&nbsp;</span><span style="color: #0000BB">strtotime</span><span 
style="color: #007700">(</span><span style="color: 
#DD0000">"1&nbsp;Jul&nbsp;06&nbsp;14:27:30&nbsp;+0200"</span><span 
style="color: #007700">)));<br 
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: 
#0000BB">var_dump</span><span style="color: #007700">(</span><span 
style="color: #0000BB">date</span><span style="color: #007700">(</span><span 
style="color: #0000BB">$const</span><span style="color: 
#007700">,&nbsp;</span><span style="color: #0000BB">strtotime</span><span 
style="color: #007700">(</span><span style="color: 
#DD0000">"2006-05-30T14:32:13+02:00"</span><span style="color: #007700">)!
 ));<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: 
#0000BB">?&gt;<br /></span>--EXPECT--<br 
/>string(25)&nbsp;"2006-07-01T14:27:30+02:00"<br 
/>string(25)&nbsp;"2006-05-30T14:32:13+02:00"<br 
/>string(31)&nbsp;"Sat,&nbsp;01&nbsp;Jul&nbsp;2006&nbsp;14:27:30&nbsp;+0200"<br 
/>string(31)&nbsp;"Tue,&nbsp;30&nbsp;May&nbsp;2006&nbsp;14:32:13&nbsp;+0200"<br 
/>string(24)&nbsp;"2006-07-01T14:27:30+0200"<br 
/>string(24)&nbsp;"2006-05-30T14:32:13+0200"<br 
/>string(29)&nbsp;"Sat,&nbsp;01&nbsp;Jul&nbsp;06&nbsp;14:27:30&nbsp;+0200"<br 
/>string(29)&nbsp;"Tue,&nbsp;30&nbsp;May&nbsp;06&nbsp;14:32:13&nbsp;+0200"<br 
/>string(33)&nbsp;"Saturday,&nbsp;01-Jul-06&nbsp;14:27:30&nbsp;CEST"<br 
/>string(32)&nbsp;"Tuesday,&nbsp;30-May-06&nbsp;14:32:13&nbsp;CEST"<br 
/>string(29)&nbsp;"Sat,&nbsp;01&nbsp;Jul&nbsp;06&nbsp;14:27:30&nbsp;+0200"<br 
/>string(29)&nbsp;"Tue,&nbsp;30&nbsp;May&nbsp;06&nbsp;14:32:13&nbsp;+0200"<br 
/>string(31)&nbsp;"Sat,&nbsp;01&nbsp;Jul&nbsp;2006&nbsp;14:27:30&nbsp;+!
 0200"<br />string(31)&nbsp;"Tue,&nbsp;30&nbsp;May&nbsp;2006&nbsp;14:32
:13&nbsp;+0200"<br 
/>string(31)&nbsp;"Sat,&nbsp;01&nbsp;Jul&nbsp;2006&nbsp;14:27:30&nbsp;+0200"<br 
/>string(31)&nbsp;"Tue,&nbsp;30&nbsp;May&nbsp;2006&nbsp;14:32:13&nbsp;+0200"<br 
/>string(31)&nbsp;"Sat,&nbsp;01&nbsp;Jul&nbsp;2006&nbsp;14:27:30&nbsp;+0200"<br 
/>string(31)&nbsp;"Tue,&nbsp;30&nbsp;May&nbsp;2006&nbsp;14:32:13&nbsp;+0200"<br 
/>string(25)&nbsp;"2006-07-01T14:27:30+02:00"<br 
/>string(25)&nbsp;"2006-05-30T14:32:13+02:00"<br /></span>
</code>
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to