]> granicus.if.org Git - php/commitdiff
be rfc compliant...
authorSterling Hughes <sterling@php.net>
Fri, 14 Dec 2001 11:43:20 +0000 (11:43 +0000)
committerSterling Hughes <sterling@php.net>
Fri, 14 Dec 2001 11:43:20 +0000 (11:43 +0000)
RFC 822 *only* supports four digits for the year in order to have a compliant
header.
RFC 850 supports two digits for the year (y2k_incompliant :) so use that when
y2k_compliance is turned off.

In either case, both of these formats require that GMT be appended to the header,
so we do this as well

pear/HTTP.php

index b81cd0d6e30d4c344358efe316b7f09fb8585efa..594642c8bbf4092a205dc75df294eb10c1e3a905 100644 (file)
@@ -27,8 +27,7 @@ $GLOBALS['USED_PACKAGES']['HTTP'] = true;
 
 class HTTP {
     /**
-     * Format a date according to RFC-XXXX (can't remember the HTTP
-     * RFC number off-hand anymore, shame on me).  This function
+     * Format a RFC compliant HTTP header.  This function
      * honors the "y2k_compliance" php.ini directive.
      *
      * @param $time int UNIX timestamp
@@ -36,10 +35,18 @@ class HTTP {
      * @return HTTP date string, or false for an invalid timestamp.
      *
      * @author Stig Bakken <ssb@fast.no>
+     * @author Sterling Hughes <sterling@php.net>
      */
     function Date($time) {
-       $y = ini_get("y2k_compliance") ? "Y" : "y";
-       return gmdate("D, d M $y H:i:s", $time);
+        /* If we're y2k compliant, use the newer, reccomended RFC 822
+           format */
+        if (ini_get("y2k_compliance") == true) {
+            return gmdate("D, d M Y H:i:s \G\M\T", $time);
+        }
+        /* Use RFC-850 which supports two character year numbers */
+        else {
+            return gmdate("F, d-D-y H:i:s \G\M\T", $time);
+        }
     }
 
     /**