From: Sterling Hughes Date: Fri, 14 Dec 2001 11:43:20 +0000 (+0000) Subject: be rfc compliant... X-Git-Tag: PRE_ISSET_PATCH~550 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a98c093d449218766618800cb14643ac69ed634e;p=php be rfc compliant... 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 --- diff --git a/pear/HTTP.php b/pear/HTTP.php index b81cd0d6e3..594642c8bb 100644 --- a/pear/HTTP.php +++ b/pear/HTTP.php @@ -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 + * @author Sterling Hughes */ 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); + } } /**